+
{children}
diff --git a/apps/v4/app/layout.tsx b/apps/v4/app/layout.tsx
index 68fbd3221e..213c282303 100644
--- a/apps/v4/app/layout.tsx
+++ b/apps/v4/app/layout.tsx
@@ -1,9 +1,9 @@
import type { Metadata } from "next"
-import { cookies } from "next/headers"
import { META_THEME_COLORS, siteConfig } from "@/lib/config"
import { fontVariables } from "@/lib/fonts"
import { cn } from "@/lib/utils"
+import { LayoutProvider } from "@/hooks/use-layout"
import { ActiveThemeProvider } from "@/components/active-theme"
import { Analytics } from "@/components/analytics"
import { TailwindIndicator } from "@/components/tailwind-indicator"
@@ -63,9 +63,6 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode
}>) {
- const cookieStore = await cookies()
- const activeThemeValue = cookieStore.get("active_theme")?.value
-
return (
@@ -76,6 +73,9 @@ export default async function RootLayout({
if (localStorage.theme === 'dark' || ((!('theme' in localStorage) || localStorage.theme === 'system') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${META_THEME_COLORS.dark}')
}
+ if (localStorage.layout) {
+ document.documentElement.classList.add('layout-' + localStorage.layout)
+ }
} catch (_) {}
`,
}}
@@ -84,18 +84,19 @@ export default async function RootLayout({
-
- {children}
-
-
-
-
+
+
+ {children}
+
+
+
+
+
diff --git a/apps/v4/components/active-theme.tsx b/apps/v4/components/active-theme.tsx
index f0348e2035..1bc94c6138 100644
--- a/apps/v4/components/active-theme.tsx
+++ b/apps/v4/components/active-theme.tsx
@@ -8,15 +8,8 @@ import {
useState,
} from "react"
-const COOKIE_NAME = "active_theme"
const DEFAULT_THEME = "default"
-function setThemeCookie(theme: string) {
- if (typeof window === "undefined") return
-
- document.cookie = `${COOKIE_NAME}=${theme}; path=/; max-age=31536000; SameSite=Lax; ${window.location.protocol === "https:" ? "Secure;" : ""}`
-}
-
type ThemeContextType = {
activeTheme: string
setActiveTheme: (theme: string) => void
@@ -36,8 +29,6 @@ export function ActiveThemeProvider({
)
useEffect(() => {
- setThemeCookie(activeTheme)
-
Array.from(document.body.classList)
.filter((className) => className.startsWith("theme-"))
.forEach((className) => {
diff --git a/apps/v4/components/charts-nav.tsx b/apps/v4/components/charts-nav.tsx
index 722c081c52..0b2f78fbd2 100644
--- a/apps/v4/components/charts-nav.tsx
+++ b/apps/v4/components/charts-nav.tsx
@@ -51,7 +51,7 @@ export function ChartsNav({
{item.name}
diff --git a/apps/v4/components/mode-switcher.tsx b/apps/v4/components/mode-switcher.tsx
index 8262b68aba..d603805076 100644
--- a/apps/v4/components/mode-switcher.tsx
+++ b/apps/v4/components/mode-switcher.tsx
@@ -24,6 +24,7 @@ export function ModeSwitcher() {
size="icon"
className="group/toggle extend-touch-target size-8"
onClick={toggleTheme}
+ title="Toggle theme"
>