Fix picture card (#5922)

This commit is contained in:
Bram Kragten 2020-05-18 20:05:00 +02:00 committed by GitHub
parent a66d2ca1b9
commit c9e8bd2e5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -38,7 +38,7 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
}; };
} }
public hass?: HomeAssistant; @property() public hass?: HomeAssistant;
@property() protected _config?: PictureCardConfig; @property() protected _config?: PictureCardConfig;
@ -54,6 +54,13 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
this._config = config; this._config = config;
} }
protected shouldUpdate(changedProps: PropertyValues): boolean {
if (changedProps.size === 1 && changedProps.has("hass")) {
return !changedProps.get("hass");
}
return true;
}
protected updated(changedProps: PropertyValues): void { protected updated(changedProps: PropertyValues): void {
super.updated(changedProps); super.updated(changedProps);
if (!this._config || !this.hass) { if (!this._config || !this.hass) {

View File

@ -250,17 +250,17 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
hasAction(entityConf.tap_action) ? "0" : undefined hasAction(entityConf.tap_action) ? "0" : undefined
)} )}
.config=${entityConf} .config=${entityConf}
class="${classMap({ class=${classMap({
"state-on": !STATES_OFF.has(stateObj.state), "state-on": !STATES_OFF.has(stateObj.state),
})}" })}
.icon="${entityConf.icon || stateIcon(stateObj)}" .icon=${entityConf.icon || stateIcon(stateObj)}
title="${` title=${`
${computeStateName(stateObj)} : ${computeStateDisplay( ${computeStateName(stateObj)} : ${computeStateDisplay(
this.hass!.localize, this.hass!.localize,
stateObj, stateObj,
this.hass!.language this.hass!.language
)} )}
`}" `}
></ha-icon> ></ha-icon>
${this._config!.show_state !== true && entityConf.show_state !== true ${this._config!.show_state !== true && entityConf.show_state !== true
? html` <div class="state"></div> ` ? html` <div class="state"></div> `
@ -328,19 +328,12 @@ class HuiPictureGlanceCard extends LitElement implements LovelaceCard {
ha-icon { ha-icon {
cursor: pointer; cursor: pointer;
padding: 8px;
color: #a9a9a9; color: #a9a9a9;
} }
ha-icon.state-on { ha-icon.state-on {
color: white; color: white;
} }
ha-icon.show-state {
width: 20px;
height: 20px;
padding-bottom: 4px;
padding-top: 4px;
}
ha-icon:focus { ha-icon:focus {
outline: none; outline: none;
background: var(--divider-color); background: var(--divider-color);