forked from mystiq/hydrogen-web
Move code to ThemeLoader
This commit is contained in:
parent
654e83a5f9
commit
0984aeb570
2 changed files with 4 additions and 15 deletions
|
@ -316,15 +316,6 @@ export class Platform {
|
|||
return this._themeLoader;
|
||||
}
|
||||
|
||||
get preferredColorScheme() {
|
||||
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||
return COLOR_SCHEME_PREFERENCE.DARK;
|
||||
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
||||
return COLOR_SCHEME_PREFERENCE.LIGHT;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
replaceStylesheet(newPath) {
|
||||
const head = document.querySelector("head");
|
||||
// remove default theme
|
||||
|
|
|
@ -64,12 +64,10 @@ export class ThemeLoader {
|
|||
return theme;
|
||||
}
|
||||
// return default theme
|
||||
const preference = this._platform.preferredColorScheme;
|
||||
switch (preference) {
|
||||
case COLOR_SCHEME_PREFERENCE.DARK:
|
||||
return this._platform.config["defaultTheme"].dark;
|
||||
case COLOR_SCHEME_PREFERENCE.LIGHT:
|
||||
return this._platform.config["defaultTheme"].light;
|
||||
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||
return this._platform.config["defaultTheme"].dark;
|
||||
} else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
|
||||
return this._platform.config["defaultTheme"].light;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue