feat: light mode support

This commit is contained in:
Timothy J. Baek 2023-11-05 15:01:55 -08:00
parent 983593d8f9
commit f0e1ec75d8
7 changed files with 177 additions and 94 deletions

View file

@ -4,6 +4,18 @@
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
if (
localStorage.theme === 'light' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: light)').matches)
) {
document.documentElement.classList.add('light');
} else {
document.documentElement.classList.add('dark');
}
</script>
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">