fix: add page reload back to apply theme changes
This commit is contained in:
1 parent
c18a3268fc
commit
a6fcf0eb7b
2 files changed
+9
-18
No files matched your search
+5
-1
@@ -62,7 +62,11 @@ export default function RootLayout({
|
|||||||
html.classList.remove('dark');
|
html.classList.remove('dark');
|
||||||
} else if (theme === 'system') {
|
} else if (theme === 'system') {
|
||||||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
if (isDark) html.classList.add('dark');
|
if (isDark) {
|
||||||
|
html.classList.add('dark');
|
||||||
|
} else {
|
||||||
|
html.classList.remove('dark');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -28,23 +28,10 @@ export default function SettingsPage({ userEmail }: SettingsPageProps) {
|
|||||||
setCurrentTheme(newTheme);
|
setCurrentTheme(newTheme);
|
||||||
localStorage.setItem('theme-mode', newTheme);
|
localStorage.setItem('theme-mode', newTheme);
|
||||||
|
|
||||||
const html = document.documentElement;
|
toast.success('🔄 Applying theme...');
|
||||||
|
setTimeout(() => {
|
||||||
if (newTheme === 'dark') {
|
window.location.reload();
|
||||||
html.classList.add('dark');
|
}, 800);
|
||||||
toast.success('🌙 Dark theme');
|
|
||||||
} else if (newTheme === 'light') {
|
|
||||||
html.classList.remove('dark');
|
|
||||||
toast.success('☀️ Light theme');
|
|
||||||
} else if (newTheme === 'system') {
|
|
||||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
||||||
if (prefersDark) {
|
|
||||||
html.classList.add('dark');
|
|
||||||
} else {
|
|
||||||
html.classList.remove('dark');
|
|
||||||
}
|
|
||||||
toast.success('🔄 System');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user