fix(theme): align initial theme and visual tokens

This commit is contained in:
2026-09-06 21:58:55 +03:30
parent 463e72a404
commit 05c304adf4
4 changed files with 44 additions and 28 deletions

View File

@@ -15,13 +15,24 @@ export const metadata: Metadata = {
],
};
const themeScript = `
try {
const savedTheme = localStorage.getItem('portfolio-theme');
const systemTheme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.documentElement.dataset.theme = savedTheme || systemTheme;
} catch {}
`;
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" data-theme="light">
<html lang="en" suppressHydrationWarning>
<head>
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
</head>
<body>
<ThemeProvider>{children}</ThemeProvider>
</body>