fix: Prevent blinding FOUC in dark mode (#1054)

This commit is contained in:
Mufeed Ali
2025-10-27 01:10:25 +05:30
committed by GitHub
parent c9308472a9
commit 8f98d8c0b4
3 changed files with 27 additions and 21 deletions

View File

@@ -6,7 +6,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" />
<link rel="manifest" href="/app.webmanifest" />
<link rel="apple-touch-icon" href="/img/static-logo-512.png">
<link rel="apple-touch-icon" href="/img/static-logo-512.png" />
<script>
try {
const mode = localStorage.getItem('mode-watcher-mode') || 'system';
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const isDark = mode === 'dark' || (mode === 'system' && prefersDark);
document.documentElement.classList.toggle('dark', isDark);
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light';
} catch (e) {
// Ignore errors
// Failing to set theme is not critical
}
</script>
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">