Skip to content

Commit

Permalink
update app.html to apply stored theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mskocik committed Dec 14, 2024
1 parent f95f1f3 commit 3c56c84
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
</style>
<script>
let mode = 'light';
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
const storedTheme = localStorage.getItem('theme');
if (!storedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
mode = 'dark';
}
document.documentElement.classList.add(mode);
document.documentElement.classList.add(storedTheme || mode);
</script>
%sveltekit.head%
</head>
Expand Down

0 comments on commit 3c56c84

Please sign in to comment.