mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-01-22 18:21:39 +01:00
themeVariant is optional
This commit is contained in:
parent
a639fc5467
commit
0dac00f327
@ -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 }, () => {
|
this._platform.logger.wrapOrRun(log, { l: "change theme", name: themeName, variant: themeVariant }, () => {
|
||||||
let cssLocation: string;
|
let cssLocation: string;
|
||||||
let themeDetails = this._themeMapping[themeName];
|
let themeDetails = this._themeMapping[themeName];
|
||||||
@ -139,7 +139,10 @@ export class ThemeLoader {
|
|||||||
cssLocation = themeDetails.cssLocation;
|
cssLocation = themeDetails.cssLocation;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cssLocation = themeDetails[themeVariant ?? "default"].cssLocation;
|
if (!themeVariant) {
|
||||||
|
throw new Error("themeVariant is undefined!");
|
||||||
|
}
|
||||||
|
cssLocation = themeDetails[themeVariant].cssLocation;
|
||||||
}
|
}
|
||||||
this._platform.replaceStylesheet(cssLocation);
|
this._platform.replaceStylesheet(cssLocation);
|
||||||
this._platform.settingsStorage.setString("theme-name", themeName);
|
this._platform.settingsStorage.setString("theme-name", themeName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user