Skip to content

Commit c808ebf

Browse files
committed
fix: Flash of inAccurate coloR Theme (FART)
1 parent 22cc475 commit c808ebf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sites/svelte.dev/src/app.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
%sveltekit.head%
3131
</head>
3232
<body data-sveltekit-preload-code="hover">
33+
<script>
34+
const themeValue = JSON.parse(localStorage.getItem('svelte:theme'))?.current;
35+
const systemPreferredTheme = window.matchMedia('(prefers-color-scheme: dark)').matches
36+
? 'dark'
37+
: 'light';
38+
39+
document.body.classList.remove('light', 'dark');
40+
document.body.classList.add(themeValue ?? systemPreferredTheme);
41+
</script>
42+
3343
<div style="height: 100%">%sveltekit.body%</div>
3444
</body>
3545
</html>

0 commit comments

Comments
 (0)