From e83fd2dff5e0f22451bd2504476190755bd4fcd2 Mon Sep 17 00:00:00 2001 From: DefectingCat Date: Fri, 10 Nov 2023 09:42:35 +0800 Subject: [PATCH] fix darkmode --- components/pages/dark-mode-btn.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/pages/dark-mode-btn.tsx b/components/pages/dark-mode-btn.tsx index c1eea54..24ac8d2 100644 --- a/components/pages/dark-mode-btn.tsx +++ b/components/pages/dark-mode-btn.tsx @@ -8,6 +8,14 @@ const DarkModeBtn = () => { const { mounted } = useMounted(); const { systemTheme, theme, setTheme } = useTheme(); const currentTheme = theme === 'system' ? systemTheme : theme; + const handleTheme = (type: 'light' | 'dark') => () => { + const map = { + light: 'latte', + dark: 'mocha', + }; + document.body.className = map[type]; + setTheme(type); + }; if (!mounted) { return ( @@ -26,11 +34,11 @@ const DarkModeBtn = () => { <> {currentTheme === 'dark' ? ( ) : ( )}