mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: save the dark mode in local storage
This commit is contained in:
parent
b2d6876347
commit
1b69f7841c
@ -9,7 +9,11 @@ export const ThemeModeContext = createContext<
|
||||
>(undefined);
|
||||
|
||||
export function useAppThemeMode() {
|
||||
const [isDark, setIsDark] = useState<boolean>(false);
|
||||
const [isDark, setIsDark] = useState<boolean>(() => {
|
||||
const darkMode = localStorage.getItem('dark-mode');
|
||||
|
||||
return darkMode === 'true';
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
function detectColorScheme() {
|
||||
@ -28,6 +32,7 @@ export function useAppThemeMode() {
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.setAttribute('data-dark-mode', isDark ? 'true' : 'false');
|
||||
localStorage.setItem('dark-mode', isDark ? 'true' : 'false');
|
||||
}, [isDark]);
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user