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');
|
||||
} else if (theme === 'system') {
|
||||
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);
|
||||
localStorage.setItem('theme-mode', newTheme);
|
||||
|
||||
const html = document.documentElement;
|
||||
|
||||
if (newTheme === 'dark') {
|
||||
html.classList.add('dark');
|
||||
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');
|
||||
}
|
||||
toast.success('🔄 Applying theme...');
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 800);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user