fix: add theme initialization script in head and toast feedback for theme changes

This commit is contained in:
nmemmert committed 2026-01-15 16:33:21 -05:00
1 parent bd7b9bea1a
commit 58480cd630
2 files changed
+35 -5

No files matched your search

+27
View File
@@ -30,6 +30,33 @@ export default function RootLayout({
}>) {
return (
<html lang="en" suppressHydrationWarning={true}>
<head>
<script dangerouslySetInnerHTML={{
__html: `
(function() {
const theme = localStorage.getItem('theme-mode') || 'dark';
const html = document.documentElement;
if (theme === 'light') {
html.classList.remove('dark');
html.style.colorScheme = 'light';
} else if (theme === 'system') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (prefersDark) {
html.classList.add('dark');
html.style.colorScheme = 'dark';
} else {
html.classList.remove('dark');
html.style.colorScheme = 'light';
}
} else {
html.classList.add('dark');
html.style.colorScheme = 'dark';
}
})();
`
}} />
</head>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>