Fixing dark mode on load.

This commit is contained in:
Bradley Shellnut 2022-08-30 17:36:04 -05:00
parent 2e389309ce
commit 7b9e1cdaa2

View file

@ -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>