mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Use slot for tile card info (#27046)
This commit is contained in:
@@ -1,20 +1,21 @@
|
|||||||
import type { TemplateResult } from "lit";
|
import { css, html, LitElement } from "lit";
|
||||||
import { html, css, LitElement, nothing } from "lit";
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
|
||||||
@customElement("ha-tile-info")
|
@customElement("ha-tile-info")
|
||||||
export class HaTileInfo extends LitElement {
|
export class HaTileInfo extends LitElement {
|
||||||
@property() public primary?: string;
|
@property() public primary?: string;
|
||||||
|
|
||||||
@property() public secondary?: string | TemplateResult<1>;
|
@property() public secondary?: string;
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
return html`
|
return html`
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="primary">${this.primary}</span>
|
<slot name="primary" class="primary">
|
||||||
${this.secondary
|
<span>${this.primary}</span>
|
||||||
? html`<span class="secondary">${this.secondary}</span>`
|
</slot>
|
||||||
: nothing}
|
<slot name="secondary" class="secondary">
|
||||||
|
<span>${this.secondary}</span>
|
||||||
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -27,7 +28,8 @@ export class HaTileInfo extends LitElement {
|
|||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
span {
|
span,
|
||||||
|
::slotted(*) {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -325,11 +325,12 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
|
|||||||
></ha-state-icon>
|
></ha-state-icon>
|
||||||
${renderTileBadge(stateObj, this.hass)}
|
${renderTileBadge(stateObj, this.hass)}
|
||||||
</ha-tile-icon>
|
</ha-tile-icon>
|
||||||
<ha-tile-info
|
<ha-tile-info id="info">
|
||||||
id="info"
|
<span slot="primary" class="primary">${name}</span>
|
||||||
.primary=${name}
|
${stateDisplay
|
||||||
.secondary=${stateDisplay}
|
? html`<span slot="secondary">${stateDisplay}</span>`
|
||||||
></ha-tile-info>
|
: nothing}
|
||||||
|
</ha-tile-info>
|
||||||
</div>
|
</div>
|
||||||
${features.length > 0
|
${features.length > 0
|
||||||
? html`
|
? html`
|
||||||
|
|||||||
Reference in New Issue
Block a user