Skip to content

Commit

Permalink
Use icon in area card if there is no image (#19933)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Mar 4, 2024
1 parent b9a7a7c commit b99072d
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions src/panels/lovelace/cards/hui-area-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,24 @@ export class HuiAreaCard
})}
>
${area.picture || cameraEntityId
? html`<hui-image
.config=${this._config}
.hass=${this.hass}
.image=${area.picture ? area.picture : undefined}
.cameraImage=${cameraEntityId}
.cameraView=${this._config.camera_view}
.aspectRatio=${this._config.aspect_ratio || DEFAULT_ASPECT_RATIO}
></hui-image>`
: ""}
? html`
<hui-image
.config=${this._config}
.hass=${this.hass}
.image=${area.picture ? area.picture : undefined}
.cameraImage=${cameraEntityId}
.cameraView=${this._config.camera_view}
.aspectRatio=${this._config.aspect_ratio ||
DEFAULT_ASPECT_RATIO}
></hui-image>
`
: area.icon
? html`
<div class="icon-container">
<ha-icon icon=${area.icon}></ha-icon>
</div>
`
: nothing}
<div
class="container ${classMap({
Expand Down Expand Up @@ -559,6 +568,22 @@ export class HuiAreaCard
opacity: 0.12;
}
.icon-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
}
.icon-container ha-icon {
--mdc-icon-size: 60px;
color: var(--sidebar-selected-icon-color);
}
.sensors {
color: #e3e3e3;
font-size: 16px;
Expand Down

0 comments on commit b99072d

Please sign in to comment.