Properly lock theme into themes dark or light mode
This commit is contained in:
@@ -829,7 +829,7 @@
|
||||
},
|
||||
"info": {
|
||||
"creating_theme": "Create a custom theme with the <2>MUI Theme Creator</2>, copy everything after \"themeOptions\" from \"{\" to \"}\" and paste it into the \"theme\" text field.",
|
||||
"theme_mode_lock": "In case the \"mode\" is defined in the \"palette\" object, the theme will be locked into this mode and will not change regardless of the apps device theme"
|
||||
"theme_mode_lock": "In case \"mode\" or \"type\" is defined in the \"palette\" object, the theme will be locked into this mode and will not change regardless of the selected apps device theme"
|
||||
},
|
||||
"theme_name": "Name"
|
||||
},
|
||||
|
||||
@@ -29,8 +29,9 @@ export const createTheme = (
|
||||
) => {
|
||||
const systemMode = MediaQuery.getSystemThemeMode();
|
||||
|
||||
const isStaticThemeMode = !!appTheme.muiTheme.palette?.mode;
|
||||
const appThemeMode = appTheme.muiTheme.palette?.mode === 'dark' ? ThemeMode.DARK : ThemeMode.LIGHT;
|
||||
const appThemeType = (appTheme.muiTheme.palette as any)?.type ?? appTheme.muiTheme.palette?.mode;
|
||||
const isStaticThemeMode = !!appThemeType;
|
||||
const appThemeMode = appThemeType === 'dark' ? ThemeMode.DARK : ThemeMode.LIGHT;
|
||||
const staticThemeMode = isStaticThemeMode ? appThemeMode : undefined;
|
||||
|
||||
const mode = staticThemeMode ?? (themeMode === ThemeMode.SYSTEM ? systemMode : themeMode);
|
||||
|
||||
Reference in New Issue
Block a user