feat: Add Dark Theme Support
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useAppStore } from '@/store';
|
||||
|
||||
export function useTheme() {
|
||||
const theme = useAppStore(state => state.theme);
|
||||
const setTheme = useAppStore(state => state.setTheme);
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
if (theme === 'dark') {
|
||||
root.classList.add('dark');
|
||||
} else {
|
||||
root.classList.remove('dark');
|
||||
}
|
||||
}, [theme]);
|
||||
|
||||
return { theme, setTheme };
|
||||
}
|
||||
Reference in New Issue
Block a user