Correct glance card size (#6109)

This commit is contained in:
Bram Kragten 2020-06-05 22:14:39 +02:00 committed by GitHub
parent 67ac3b4ba3
commit 30442b25c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,14 +69,24 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
return (
(this._config!.title ? 1 : 0) +
Math.max(
Math.ceil(this._configEntities!.length / (this._config!.columns || 5)),
((this._config!.show_icon ? 1 : 0) +
(this._config!.show_name && this._config!.show_state ? 1 : 0)) *
Math.ceil(
this._configEntities!.length / (this._config!.columns || 5)
),
1
)
);
}
public setConfig(config: GlanceCardConfig): void {
this._config = { state_color: true, ...config };
this._config = {
show_name: true,
show_state: true,
show_icon: true,
state_color: true,
...config,
};
const entities = processConfigEntities<GlanceConfigEntity>(config.entities);
for (const entity of entities) {
@ -234,7 +244,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
hasAction(entityConf.tap_action) ? "0" : undefined
)}
>
${this._config!.show_name !== false
${this._config!.show_name
? html`
<div class="name">
${"name" in entityConf
@ -243,7 +253,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
</div>
`
: ""}
${this._config!.show_icon !== false
${this._config!.show_icon
? html`
<state-badge
.hass=${this.hass}
@ -256,7 +266,7 @@ export class HuiGlanceCard extends LitElement implements LovelaceCard {
></state-badge>
`
: ""}
${this._config!.show_state !== false && entityConf.show_state !== false
${this._config!.show_state && entityConf.show_state !== false
? html`
<div>
${computeDomain(entityConf.entity) === "sensor" &&