Cache brand images (#17840)

This commit is contained in:
Steve Repsher
2023-10-25 03:28:28 -04:00
committed by GitHub
parent 80112bb662
commit 01f51f3247
26 changed files with 94 additions and 40 deletions

View File

@@ -112,9 +112,7 @@ export class StateBadge extends LitElement {
const stateObj = this.stateObj;
const iconStyle: { [name: string]: string } = {};
const hostStyle: Partial<CSSStyleDeclaration> = {
backgroundImage: "",
};
let backgroundImage = "";
this._showIcon = true;
@@ -135,13 +133,12 @@ export class StateBadge extends LitElement {
if (domain === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
if (domain === "update") {
hostStyle.borderRadius = "0";
}
if (domain === "media_player") {
hostStyle.borderRadius = "8%";
this.style.borderRadius = "0";
} else if (domain === "media_player") {
this.style.borderRadius = "8%";
}
} else if (this.color) {
// Externally provided overriding color wins over state color
@@ -182,12 +179,12 @@ export class StateBadge extends LitElement {
if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
}
this._iconStyle = iconStyle;
Object.assign(this.style, hostStyle);
this.style.backgroundImage = backgroundImage;
}
static get styles(): CSSResultGroup {