setting up dark/white mode. fixed some other small things
This commit is contained in:
+22
-9
@@ -2,7 +2,6 @@
|
||||
import "./globals.css";
|
||||
import type { ReactNode } from "react";
|
||||
import { AuthProvider } from "@/context/AuthContext";
|
||||
|
||||
import { Banner } from "@/components/Banner";
|
||||
|
||||
export const metadata = {
|
||||
@@ -13,17 +12,31 @@ export const metadata = {
|
||||
description: "Build rifles smarter, not harder.",
|
||||
};
|
||||
|
||||
const themeScript = `
|
||||
(function () {
|
||||
try {
|
||||
const storedTheme = localStorage.getItem("theme");
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
const theme = storedTheme || (prefersDark ? "dark" : "light");
|
||||
document.documentElement.classList.toggle("dark", theme === "dark");
|
||||
} catch (_) {}
|
||||
})();
|
||||
`;
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className="bg-black text-zinc-50">
|
||||
|
||||
<AuthProvider>
|
||||
<Banner />
|
||||
{children}
|
||||
</AuthProvider>
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<head>
|
||||
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
||||
</head>
|
||||
|
||||
<body className="bg-white text-zinc-950 dark:bg-black dark:text-zinc-50">
|
||||
{" "}
|
||||
<AuthProvider>
|
||||
<Banner />
|
||||
{children}
|
||||
</AuthProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user