From 1e51fc1006c612c9159dd9659cfb680f9ca6d776 Mon Sep 17 00:00:00 2001 From: poyrazavsever Date: Thu, 16 Jul 2026 10:50:50 +0300 Subject: [PATCH] fix: fixed ataturk-widget-modal dark/light problem --- components/app-shell.tsx | 24 +++++++++++++++--- components/ataturk-widget-modal.tsx | 11 ++++++--- components/site-navbar.tsx | 38 +++++++++-------------------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/components/app-shell.tsx b/components/app-shell.tsx index 7d00ddb..4476a12 100644 --- a/components/app-shell.tsx +++ b/components/app-shell.tsx @@ -1,5 +1,5 @@ "use client"; - +import { useEffect, useState } from "react"; import { Icon } from "@iconify/react"; import { usePathname } from "@/i18n/routing"; import { AnnouncementBar } from "poyraz-ui/organisms"; @@ -19,13 +19,31 @@ type AppShellProps = { children: React.ReactNode; }; +export type ThemeMode = "light" | "dark"; + +function getInitialTheme(): ThemeMode { + if (typeof window === "undefined") return "light"; + + const storedTheme = localStorage.getItem("poyraz-theme"); + if (storedTheme === "dark" || storedTheme === "light") return storedTheme; + + return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; +} + export function AppShell({ children }: AppShellProps) { const pathname = usePathname(); const locale = useLocale(); const announcement = ANNOUNCEMENT_ITEMS[0]; + const [theme, setTheme] = useState(getInitialTheme); const isStandaloneLinksPage = pathname === "/links" || pathname.startsWith("/links/"); + useEffect(() => { + document.documentElement.dataset.poyrazTheme = theme; + document.documentElement.style.colorScheme = theme; + localStorage.setItem("poyraz-theme", theme); + }, [theme]); + if (isStandaloneLinksPage) { return children; } @@ -34,10 +52,10 @@ export function AppShell({ children }: AppShellProps) { return ( <> - + {ENABLE_NEKO_FOLLOWER ? : null}
- + {announcement ? ( -
+