Skip to content

Commit

Permalink
Handle custom themes (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored May 29, 2022
1 parent 3340044 commit 528def0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class HacsFrontend extends HacsElement {
}
});

mainWindow
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", (_) => this._applyTheme());

makeDialogManager(this, this.shadowRoot!);
}

Expand Down Expand Up @@ -236,9 +240,14 @@ class HacsFrontend extends HacsElement {
applyThemesOnElement(
this.parentElement,
this.hass.themes,
(this.hass.selectedTheme as unknown as string) || this.hass.themes.default_theme,
undefined,
true
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),
{
...this.hass.selectedTheme,
dark: this.hass.themes.darkMode,
}
);
this.parentElement!.style.backgroundColor = "var(--primary-background-color)";
this.parentElement!.style.color = "var(--primary-text-color)";
Expand Down

0 comments on commit 528def0

Please sign in to comment.