border-radius fixes for state-badge (#23212)

This commit is contained in:
ildar170975 2024-12-20 17:06:03 +03:00 committed by GitHub
parent 6b230b6142
commit d71b29d089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,7 +113,9 @@ export class StateBadge extends LitElement {
this.icon = true; this.icon = true;
if (stateObj && this.overrideImage === undefined) { if (stateObj) {
const domain = computeDomain(stateObj.entity_id);
if (this.overrideImage === undefined) {
// hide icon if we have entity picture // hide icon if we have entity picture
if ( if (
(stateObj.attributes.entity_picture_local || (stateObj.attributes.entity_picture_local ||
@ -126,17 +128,11 @@ export class StateBadge extends LitElement {
if (this.hass) { if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl); imageUrl = this.hass.hassUrl(imageUrl);
} }
const domain = computeDomain(stateObj.entity_id);
if (domain === "camera") { if (domain === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80); imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
} }
backgroundImage = `url(${imageUrl})`; backgroundImage = `url(${imageUrl})`;
this.icon = false; this.icon = false;
if (domain === "update") {
this.style.borderRadius = "0";
} else if (domain === "media_player") {
this.style.borderRadius = "8%";
}
} else if (this.color) { } else if (this.color) {
// Externally provided overriding color wins over state color // Externally provided overriding color wins over state color
iconStyle.color = this.color; iconStyle.color = this.color;
@ -180,6 +176,13 @@ export class StateBadge extends LitElement {
this.icon = false; this.icon = false;
} }
if (domain === "update") {
this.style.borderRadius = "0";
} else if (domain === "media_player" || domain === "camera") {
this.style.borderRadius = "8%";
}
}
this._iconStyle = iconStyle; this._iconStyle = iconStyle;
this.style.backgroundImage = backgroundImage; this.style.backgroundImage = backgroundImage;
} }