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;
@ -54,6 +54,13 @@ export class HuiPictureCard extends LitElement implements LovelaceCard {
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 {
super.updated(changedProps);
if (!this._config || !this.hass) {

View File

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