fix: commit untracked theme.ts
parent
358e95621d
commit
ccd430bf0c
@ -0,0 +1,18 @@
|
|||||||
|
import { ThemeStateType } from '../themes/constants/colors';
|
||||||
|
|
||||||
|
export function getOppositeTheme(themeName: string): ThemeStateType {
|
||||||
|
if (themeName.includes('dark')) {
|
||||||
|
return themeName.replace('dark', 'light') as ThemeStateType;
|
||||||
|
}
|
||||||
|
if (themeName.includes('light')) {
|
||||||
|
return themeName.replace('light', 'dark') as ThemeStateType;
|
||||||
|
}
|
||||||
|
// If neither 'dark' nor 'light' is in the theme name, return the original theme name.
|
||||||
|
return themeName as ThemeStateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isThemeMismatched(themeName: string, prefersDark: boolean): boolean {
|
||||||
|
const isLightTheme = themeName.includes('light');
|
||||||
|
const isDarkTheme = themeName.includes('dark');
|
||||||
|
return (prefersDark && isLightTheme) || (!prefersDark && isDarkTheme);
|
||||||
|
}
|
Loading…
Reference in New Issue