Temat har nu tre lägen (automatiskt, ljust, mörkt) och följer webbläsarens eller systemets inställning som standard. Ett skript i <head> sätter temat innan sidan ritas så att mörkt läge inte blinkar till ljust. Kartplattorna dämpas i mörkt läge. Tester och README ingår. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { cookies } from "next/headers";
|
|
import "@fontsource-variable/inter";
|
|
import "@tabler/core/dist/css/tabler.min.css";
|
|
import "./globals.css";
|
|
import { I18nProvider } from "@/i18n/client";
|
|
import { dictionaries } from "@/i18n/core";
|
|
import { getLocale } from "@/i18n/server";
|
|
import { TablerJs } from "@/components/tabler-js";
|
|
import { THEME_BOOT_SCRIPT, parseThemeMode, serverTheme } from "@/lib/theme";
|
|
|
|
export const metadata: Metadata = {
|
|
title: { default: "Bokplanerare", template: "%s · Bokplanerare" },
|
|
description: "Planeringsverktyg för författare",
|
|
};
|
|
|
|
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
const locale = await getLocale();
|
|
const theme = serverTheme(parseThemeMode((await cookies()).get("theme")?.value));
|
|
|
|
return (
|
|
// suppressHydrationWarning: skriptet i <head> kan byta tema till mörkt före hydreringen när valet är auto
|
|
<html lang={locale} data-bs-theme={theme} suppressHydrationWarning>
|
|
<head>
|
|
<script dangerouslySetInnerHTML={{ __html: THEME_BOOT_SCRIPT }} />
|
|
</head>
|
|
<body>
|
|
<I18nProvider locale={locale} dict={dictionaries[locale]}>
|
|
<TablerJs />
|
|
{children}
|
|
</I18nProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|