diff --git a/apps/web/src/app.html b/apps/web/src/app.html index 0121188ca..1a5717bd8 100644 --- a/apps/web/src/app.html +++ b/apps/web/src/app.html @@ -14,6 +14,22 @@ %sveltekit.head% +
%sveltekit.body% diff --git a/apps/web/src/lib/features/theme/ThemeHead.svelte b/apps/web/src/lib/features/theme/ThemeHead.svelte index a3aff0106..addc05c13 100644 --- a/apps/web/src/lib/features/theme/ThemeHead.svelte +++ b/apps/web/src/lib/features/theme/ThemeHead.svelte @@ -8,34 +8,13 @@ interface Props { let { theme }: Props = $props(); +// when following the system theme the blocking script in app.html corrects +// this before first paint const metaColorScheme = $derived( theme === "light" ? "light dark" : "dark light", ); - -// applied before first paint when no explicit theme is set, so the page -// never flashes the wrong theme; the html class is otherwise SSR'd -const CLIENT_THEME_SCRIPT = ` -;(() => { - const theme = window.matchMedia("(prefers-color-scheme: light)").matches - ? 'light' - : 'dark'; - const cl = document.documentElement.classList; - const themeAlreadyApplied = cl.contains('light') || cl.contains('dark'); - if (!themeAlreadyApplied) { - cl.add(theme); - } - const meta = document.querySelector('meta[name=color-scheme]'); - if (meta) { - meta.content = theme === 'dark' ? 'dark light' : 'light dark'; - } -})(); -`;