Skip to content

Commit

Permalink
Force dark (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Jun 20, 2021
1 parent 5efd0e7 commit a552db2
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { html, TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators";
import { atLeastVersion } from "../homeassistant-frontend/src/common/config/version";
import { applyThemesOnElement } from "../homeassistant-frontend/src/common/dom/apply_themes_on_element";
import { navigate } from "../homeassistant-frontend/src/common/navigate";
import { makeDialogManager } from "../homeassistant-frontend/src/dialogs/make-dialog-manager";
Expand Down Expand Up @@ -214,28 +213,25 @@ class HacsFrontend extends HacsElement {
}

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

if (atLeastVersion(this.hass.config.version, 0, 114)) {
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,
dark: this.hass.themes.darkMode,
};
}
} else {
themeName = (this.hass.selectedTheme as unknown as string) || this.hass.themes.default_theme;
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,
};
}

applyThemesOnElement(this.parentElement, this.hass.themes, themeName, options);
applyThemesOnElement(this.parentElement, this.hass.themes, themeName, {
...options,
dark: this.hass.themes.darkMode,
});
this.parentElement.style.backgroundColor = "var(--primary-background-color)";
}
}

0 comments on commit a552db2

Please sign in to comment.