mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
Fixing dark mode on load.
This commit is contained in:
parent
2e389309ce
commit
7b9e1cdaa2
1 changed files with 43 additions and 34 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="description" content="Bored? Find a game! Bored Game!" />
|
<meta name="description" content="Bored? Find a game! Bored Game!" />
|
||||||
|
|
@ -10,6 +11,13 @@
|
||||||
const userTheme = localStorage.theme;
|
const userTheme = localStorage.theme;
|
||||||
const userFont = localStorage.font;
|
const userFont = localStorage.font;
|
||||||
|
|
||||||
|
const prefersDarkMode = window.matchMedia(
|
||||||
|
'prefers-color-scheme: dark'
|
||||||
|
).matches;
|
||||||
|
const prefersLightMode = window.matchMedia(
|
||||||
|
'prefers-color-scheme: light'
|
||||||
|
).matches;
|
||||||
|
|
||||||
// check if the user set a theme
|
// check if the user set a theme
|
||||||
if (userTheme) {
|
if (userTheme) {
|
||||||
htmlElement.dataset.theme = userTheme;
|
htmlElement.dataset.theme = userTheme;
|
||||||
|
|
@ -38,4 +46,5 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="svelte">%sveltekit.body%</div>
|
<div id="svelte">%sveltekit.body%</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in a new issue