Skip to content

Commit

Permalink
Improve sensor card graph inside section grid (#21289)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Jul 5, 2024
1 parent f995f19 commit f7072c2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/panels/lovelace/cards/hui-entity-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
PropertyValues,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { ifDefined } from "lit/directives/if-defined";
import { styleMap } from "lit/directives/style-map";
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
Expand Down Expand Up @@ -73,6 +74,8 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {

@property({ attribute: false }) public hass?: HomeAssistant;

@property() public layout?: string;

@state() private _config?: EntityCardConfig;

private _footerElement?: HuiErrorCard | LovelaceHeaderFooter;
Expand Down Expand Up @@ -132,8 +135,15 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {

const colored = stateObj && this.getStateColor(stateObj, this._config);

const fixedFooter =
this.layout === "grid" || this._footerElement !== undefined;

return html`
<ha-card @click=${this._handleClick} tabindex="0">
<ha-card
@click=${this._handleClick}
tabindex="0"
class=${classMap({ "with-fixed-footer": fixedFooter })}
>
<div class="header">
<div class="name" .title=${name}>${name}</div>
<div class="icon">
Expand Down Expand Up @@ -188,7 +198,7 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
`
: ""}
</div>
${this._footerElement}
<div class="footer">${this._footerElement}</div>
</ha-card>
`;
}
Expand Down Expand Up @@ -309,6 +319,16 @@ export class HuiEntityCard extends LitElement implements LovelaceCard {
font-size: 18px;
color: var(--secondary-text-color);
}
.with-fixed-footer {
justify-content: flex-start;
}
.with-fixed-footer .footer {
position: absolute;
right: 0;
left: 0;
bottom: 0;
}
`,
];
}
Expand Down

0 comments on commit f7072c2

Please sign in to comment.