themeVariant is optional
This commit is contained in:
parent
a639fc5467
commit
0dac00f327
1 changed files with 5 additions and 2 deletions
|
@ -131,7 +131,7 @@ export class ThemeLoader {
|
|||
}
|
||||
}
|
||||
|
||||
setTheme(themeName: string, themeVariant: "light" | "dark" | "default", log?: ILogItem) {
|
||||
setTheme(themeName: string, themeVariant?: "light" | "dark" | "default", log?: ILogItem) {
|
||||
this._platform.logger.wrapOrRun(log, { l: "change theme", name: themeName, variant: themeVariant }, () => {
|
||||
let cssLocation: string;
|
||||
let themeDetails = this._themeMapping[themeName];
|
||||
|
@ -139,7 +139,10 @@ export class ThemeLoader {
|
|||
cssLocation = themeDetails.cssLocation;
|
||||
}
|
||||
else {
|
||||
cssLocation = themeDetails[themeVariant ?? "default"].cssLocation;
|
||||
if (!themeVariant) {
|
||||
throw new Error("themeVariant is undefined!");
|
||||
}
|
||||
cssLocation = themeDetails[themeVariant].cssLocation;
|
||||
}
|
||||
this._platform.replaceStylesheet(cssLocation);
|
||||
this._platform.settingsStorage.setString("theme-name", themeName);
|
||||
|
|
Reference in a new issue