Skip to content

Commit

Permalink
Override custom panel defaults (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored May 29, 2022
1 parent 27b24e1 commit 4e34df8
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,27 +233,14 @@ class HacsFrontend extends HacsElement {
}

private _applyTheme() {
let options: Partial<HomeAssistant["selectedTheme"]> | undefined;

const themeName =
this.hass.selectedTheme?.theme ||
(this.hass.themes.darkMode && this.hass.themes.default_dark_theme
? this.hass.themes.default_dark_theme!
: this.hass.themes.default_theme);

options = this.hass.selectedTheme;
if (themeName === "default" && options?.dark === undefined) {
options = {
...this.hass.selectedTheme,
};
}

if (this.parentElement) {
applyThemesOnElement(this.parentElement, this.hass.themes, themeName, {
...options,
dark: this.hass.themes.darkMode,
});
this.parentElement.style.backgroundColor = "var(--primary-background-color)";
}
applyThemesOnElement(
this.parentElement,
this.hass.themes,
(this.hass.selectedTheme as unknown as string) || this.hass.themes.default_theme,
undefined,
true
);
this.parentElement!.style.backgroundColor = "var(--primary-background-color)";
this.parentElement!.style.color = "var(--primary-text-color)";
}
}

0 comments on commit 4e34df8

Please sign in to comment.