Refactor theme selection

This commit is contained in:
Nicola Benaglia 2025-06-20 15:49:13 +02:00
parent 52f2ce5de0
commit 3ff3c4d69b

View File

@ -41,21 +41,16 @@ export const ThemeProvider = ({ children }) => {
userThemes.find((theme) => theme.id === currentThemeId) || defaultTheme; userThemes.find((theme) => theme.id === currentThemeId) || defaultTheme;
const muiTheme = useMemo(() => { const muiTheme = useMemo(() => {
if (themeMode === 'light') { const baseThemeOptions =
return createTheme({ themeMode === 'light' ? lightThemeOptions : darkThemeOptions;
...lightThemeOptions,
palette: { const palette =
...currentTheme.light, themeMode === 'light' ? currentTheme.light : currentTheme.dark;
},
}); return createTheme({
} else { ...baseThemeOptions,
return createTheme({ palette,
...lightThemeOptions, });
palette: {
...currentTheme.dark,
},
});
}
}, [themeMode, currentTheme]); }, [themeMode, currentTheme]);
const saveSettings = ( const saveSettings = (