Skip to content

Commit

Permalink
oe-build-perf-report: Add dark mode
Browse files Browse the repository at this point in the history
Update css to add dark mode when window prefers-color-scheme is dark.

Signed-off-by: Ninette Adhikari <[email protected]>
  • Loading branch information
ninetteadhikari committed May 3, 2024
1 parent 9d154af commit 5c0c415
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
15 changes: 11 additions & 4 deletions scripts/lib/build_perf/html/measurement_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@

// Draw chart
const chart_div = document.getElementById('{{ chart_elem_id }}');
const measurement_chart= echarts.init(chart_div, null, {
height: 320
});
// Set dark mode
let measurement_chart
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
measurement_chart= echarts.init(chart_div, 'dark', {
height: 320
});
} else {
measurement_chart= echarts.init(chart_div, null, {
height: 320
});
}
// Change chart size with browser resize
window.addEventListener('resize', function() {
measurement_chart.resize();
});
measurement_chart.setOption(option);
</script>

34 changes: 28 additions & 6 deletions scripts/lib/build_perf/html/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

{# Styles #}
<style>
:root {
--text: #000;
--bg: #fff;
--h2heading: #707070;
--link: #0000EE;
--trtopborder: #9ca3af;
--trborder: #e5e7eb;
--chartborder: #f0f0f0;
}
.meta-table {
font-size: 14px;
text-align: left;
Expand All @@ -31,7 +40,7 @@
}
.measurement {
padding: 8px 0px 8px 8px;
border: 2px solid #f0f0f0;
border: 2px solid var(--chartborder);
margin: 1.5rem 0;
}
.details {
Expand Down Expand Up @@ -61,20 +70,22 @@
body {
font-family: 'Helvetica', sans-serif;
margin: 3rem 8rem;
background-color: var(--bg);
color: var(--text);
}
h1 {
text-align: center;
}
h2 {
font-size: 1.5rem;
margin-bottom: 0px;
color: #707070;
color: var(--h2heading);
padding-top: 1.5rem;
}
h3 {
font-size: 1.3rem;
margin: 0px;
color: #707070;
color: var(--h2heading);
padding: 1.5rem 0;
}
h4 {
Expand All @@ -89,22 +100,33 @@
line-height: 2rem;
}
tr {
border-bottom: 1px solid #e5e7eb;
border-bottom: 1px solid var(--trborder);
}
tr:first-child {
border-bottom: 1px solid #9ca3af;
border-bottom: 1px solid var(--trtopborder);
}
tr:last-child {
border-bottom: none;
}
a {
text-decoration: none;
font-weight: bold;
color: #0000EE;
color: var(--link);
}
a:hover {
color: #8080ff;
}
@media (prefers-color-scheme: dark) {
:root {
--text: #e9e8fa;
--bg: #0F0C28;
--h2heading: #B8B7CB;
--link: #87cefa;
--trtopborder: #394150;
--trborder: #212936;
--chartborder: #b1b0bf;
}
}
</style>

<title>{{ title }}</title>
Expand Down

0 comments on commit 5c0c415

Please sign in to comment.