Match TallStackUI's theme fallback before first paint

The inline theme script treated an unknown stored "dark-theme" value as
light, while tallstackui_darkTheme() treats it as "system", so a dark OS
could flash the light theme. Also move an inline comment in
AppServiceProvider into the method's PHPDoc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-22 12:27:02 +02:00
co-authored by Claude Opus 5.5
parent 90d6f5bd66
commit 4b42fd4009
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -14,12 +14,13 @@
Apply the stored theme before the first paint. TallStackUI's
tallstackui_darkTheme() keeps it in localStorage ("dark-theme"),
but only runs once Alpine starts, which would flash the light theme.
Like the package, any value other than dark/light (true/false) means "system".
--}}
<script>
(() => {
const stored = localStorage.getItem('dark-theme');
const dark = stored === 'dark' || stored === 'true'
|| ((stored === null || stored === 'system') && window.matchMedia('(prefers-color-scheme: dark)').matches);
|| (stored !== 'light' && stored !== 'false' && window.matchMedia('(prefers-color-scheme: dark)').matches);
document.documentElement.classList.toggle('dark', dark);
})();
</script>