mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 05:57:54 +00:00
Theme Addition (#2178)
This commit is contained in:
parent
1d7f574b9b
commit
8274284294
@ -13,6 +13,7 @@ import { LovelaceCardConfig } from "../../../data/lovelace";
|
|||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
|
|
||||||
|
import applyThemesOnElement from "../../../common/dom/apply_themes_on_element";
|
||||||
import computeStateName from "../../../common/entity/compute_state_name";
|
import computeStateName from "../../../common/entity/compute_state_name";
|
||||||
import stateIcon from "../../../common/entity/state_icon";
|
import stateIcon from "../../../common/entity/state_icon";
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ interface Config extends LovelaceCardConfig {
|
|||||||
graph?: string;
|
graph?: string;
|
||||||
unit?: string;
|
unit?: string;
|
||||||
detail?: number;
|
detail?: number;
|
||||||
|
theme?: string;
|
||||||
hours_to_show?: number;
|
hours_to_show?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +165,7 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const cardConfig = {
|
const cardConfig = {
|
||||||
detail: 1,
|
detail: 1,
|
||||||
|
theme: "default",
|
||||||
hours_to_show: 24,
|
hours_to_show: 24,
|
||||||
...config,
|
...config,
|
||||||
};
|
};
|
||||||
@ -262,10 +265,15 @@ class HuiSensorCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
protected updated(changedProps: PropertyValues) {
|
||||||
if (this._config && this._config.graph !== "line") {
|
if (!this._config || this._config.graph !== "line" || !this.hass) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
|
||||||
|
if (!oldHass || oldHass.themes !== this.hass.themes) {
|
||||||
|
applyThemesOnElement(this, this.hass.themes, this._config!.theme);
|
||||||
|
}
|
||||||
|
|
||||||
const minute = 60000;
|
const minute = 60000;
|
||||||
if (changedProps.has("_config")) {
|
if (changedProps.has("_config")) {
|
||||||
this._getHistory();
|
this._getHistory();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user