Skip to content

Commit 8dcc26e

Browse files
committed
Revert "fix: do not hardcode color"
This reverts commit 7157004.
1 parent 7157004 commit 8dcc26e

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

public/index.html

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,15 @@
33
<head>
44
<script>
55
(function () {
6-
try {
7-
const savedTheme = localStorage.getItem('theme') || 'light';
8-
const isDarkThemePreferred = window?.matchMedia?.(
9-
'(prefers-color-scheme:dark)',
10-
)?.matches;
11-
12-
let theme;
13-
if (!savedTheme || savedTheme === 'system') {
14-
theme = isDarkThemePreferred ? 'dark' : 'light';
15-
} else {
16-
theme = savedTheme;
17-
}
18-
19-
const observer = new MutationObserver((mutations, obs) => {
20-
if (document.body) {
21-
try {
22-
const themeClass = [...document.body.classList].find((cl) =>
23-
cl.startsWith('g-root_theme'),
24-
);
25-
if (themeClass) {
26-
document.body.classList.remove(themeClass);
27-
}
28-
document.body.classList.add(`g-root_theme_${theme}`);
29-
} catch (e) {
30-
} finally {
31-
obs.disconnect();
32-
}
33-
}
34-
});
35-
36-
observer.observe(document.documentElement, {
37-
childList: true,
38-
});
39-
} catch (e) {}
6+
const savedTheme = localStorage.getItem('theme') || 'light';
7+
if (
8+
savedTheme.includes('dark') ||
9+
(savedTheme === 'system' &&
10+
window.matchMedia &&
11+
window.matchMedia('(prefers-color-scheme: dark)').matches)
12+
) {
13+
document.documentElement.style.backgroundColor = '#2d2c33';
14+
}
4015
})();
4116
</script>
4217
<meta charset="utf-8" />

0 commit comments

Comments
 (0)