mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix initial theming (#18296)
This commit is contained in:
parent
16766f8878
commit
ce11301516
@ -41,9 +41,7 @@ export const applyThemesOnElement = (
|
||||
// If there is no explicitly desired dark mode provided, we automatically
|
||||
// use the active one from `themes`.
|
||||
const darkMode =
|
||||
themeSettings && themeSettings?.dark !== undefined
|
||||
? themeSettings?.dark
|
||||
: themes.darkMode;
|
||||
themeSettings?.dark !== undefined ? themeSettings.dark : themes.darkMode;
|
||||
|
||||
let cacheKey = themeToApply;
|
||||
let themeRules: Partial<ThemeVars> = {};
|
||||
@ -135,10 +133,19 @@ export const applyThemesOnElement = (
|
||||
|
||||
// Set and/or reset styles
|
||||
if (element.updateStyles) {
|
||||
// Use updateStyles() method of Polymer elements
|
||||
element.updateStyles(styles);
|
||||
} else if (window.ShadyCSS) {
|
||||
// Implement updateStyles() method of Polymer elements
|
||||
// Use ShadyCSS if available
|
||||
window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */ element, styles);
|
||||
} else {
|
||||
for (const s in styles) {
|
||||
if (s === null) {
|
||||
element.style.removeProperty(s);
|
||||
} else {
|
||||
element.style.setProperty(s, styles[s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -71,7 +71,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
}
|
||||
|
||||
let themeSettings: Partial<HomeAssistant["selectedTheme"]> =
|
||||
this.hass!.selectedTheme;
|
||||
this.hass.selectedTheme;
|
||||
|
||||
const themeName =
|
||||
themeSettings?.theme ||
|
||||
@ -80,7 +80,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
: this.hass.themes.default_theme);
|
||||
|
||||
let darkMode =
|
||||
themeSettings?.dark === undefined ? darkPreferred : themeSettings?.dark;
|
||||
themeSettings?.dark === undefined ? darkPreferred : themeSettings.dark;
|
||||
|
||||
const selectedTheme = themeName
|
||||
? this.hass.themes.themes[themeName]
|
||||
|
Loading…
x
Reference in New Issue
Block a user