diff --git a/app/globals.css b/app/globals.css index d2ea95b..f9fdb11 100644 --- a/app/globals.css +++ b/app/globals.css @@ -73,7 +73,7 @@ } /* Ocean theme */ - .theme-ocean { + .ocean-light { --background: 0 0% 100%; --foreground: 222.2 84% 4.9%; --card: 0 0% 100%; @@ -108,7 +108,7 @@ --tier-gradient-6: linear-gradient(to right, #3C6E8F, #2E8B57); /* Deepest ocean */ } - .dark.theme-ocean { + .ocean-dark { --background: 222.2 84% 4.9%; --foreground: 210 40% 98%; --card: 222.2 84% 4.9%; @@ -143,7 +143,7 @@ } /* Forest theme */ - .theme-forest { + .forest-light { --background: 0 0% 100%; --foreground: 240 10% 3.9%; --card: 0 0% 100%; @@ -178,7 +178,7 @@ --tier-gradient-6: linear-gradient(to right, #fae8cc, #f5c29e); } - .dark.theme-forest { + .forest-dark { --background: 20 14.3% 4.1%; --foreground: 0 0% 95%; --card: 24 9.8% 10%; diff --git a/app/layout.tsx b/app/layout.tsx index c0dcaf8..af25fc7 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -141,6 +141,12 @@ export default function RootLayout({ diff --git a/components/ThemeSelector.tsx b/components/ThemeSelector.tsx index 5285cd1..640a8ea 100644 --- a/components/ThemeSelector.tsx +++ b/components/ThemeSelector.tsx @@ -10,19 +10,14 @@ const colorThemes = ['classic', 'ocean', 'forest']; export function ThemeSelector() { const [mounted, setMounted] = useState(false); - const {setTheme} = useTheme(); + const {theme, setTheme} = useTheme(); useEffect(() => { setMounted(true); }, []); const handleThemeChange = (newTheme: string) => { - const [newColorTheme, newMode] = newTheme.split('-'); - document.documentElement.classList.remove('theme-ocean', 'theme-forest'); - if (newColorTheme !== 'classic') { - document.documentElement.classList.add(`theme-${newColorTheme}`); - } - setTheme(newMode); + setTheme(newTheme.replace('classic-', '')); }; if (!mounted) { @@ -43,7 +38,7 @@ export function ThemeSelector() { {colorThemes.map((colorTheme) => ( handleThemeChange(colorTheme)} + onClick={() => handleThemeChange(`${colorTheme}-${theme && theme.includes('dark') ? 'dark' : 'light'}`)} > {colorTheme.charAt(0).toUpperCase() + colorTheme.slice(1)}