feat(nav): add ThemeToggle component with moon/sun icons and no-flash script
- Inline <script> in app.html applies saved localStorage theme before first paint to prevent flash of wrong theme - ThemeToggle.svelte: moon/sun button, localStorage persistence, sets data-theme on <html>, defaults to system preference on first visit - Placed in +layout.svelte between language selector and user menu - E2E tests cover visibility, toggle, reverse toggle, persistence, and no-flash behaviour — all 6 passing Refs #64 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<script>
|
||||
(function () {
|
||||
var t = localStorage.getItem('theme');
|
||||
if (t === 'dark' || t === 'light') document.documentElement.setAttribute('data-theme', t);
|
||||
})();
|
||||
</script>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
|
||||
Reference in New Issue
Block a user