mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-07 00:14:25 +00:00
Refactor ThemeContext to ensure fallback to light scheme and update color scheme logic
This commit is contained in:
@@ -22,8 +22,10 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
|
||||
|
||||
const updateColorScheme = useCallback(
|
||||
(newTheme: MantineColorScheme): void => {
|
||||
if (setColorScheme) {
|
||||
setColorScheme(newTheme);
|
||||
if (newTheme === 'light' || newTheme === 'dark') {
|
||||
if (setColorScheme) {
|
||||
setColorScheme(newTheme);
|
||||
}
|
||||
}
|
||||
},
|
||||
[setColorScheme]
|
||||
@@ -31,7 +33,8 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
|
||||
|
||||
// Ensure colorScheme is never undefined by falling back to light theme
|
||||
const value: ThemeContextType = {
|
||||
colorScheme: colorScheme || 'light',
|
||||
colorScheme:
|
||||
colorScheme === 'light' || colorScheme === 'dark' ? colorScheme : 'light',
|
||||
updateColorScheme,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user