diff --git a/components/ui/ThemeButton.tsx b/components/ui/ThemeButton.tsx index 38e761b..da1b291 100644 --- a/components/ui/ThemeButton.tsx +++ b/components/ui/ThemeButton.tsx @@ -7,33 +7,22 @@ import {MoonIcon} from '@/components/icons/MoonIcon' export function ThemeButton() { const [mounted, setMounted] = useState(false) - const {theme, setTheme} = useTheme() + const {resolvedTheme, setTheme} = useTheme() + let otherTheme = resolvedTheme === 'dark' ? 'light' : 'dark' useEffect(() => { const timeout = setTimeout(() => setMounted(true), 500) return () => clearTimeout(timeout) }, []) - function toggleTheme() { - let darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)') - let isSystemDarkMode = darkModeMediaQuery.matches - let isDarkMode = theme === 'dark' - - if (isDarkMode === isSystemDarkMode) { - setTheme('light') - } else { - setTheme('dark') - } - } - if (!mounted) return return (