From 491cc0ee0bd4454d56675168d6ee7a58d50300a7 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 10 Jul 2024 12:17:44 +0200 Subject: [PATCH] Clean code --- src/components/ha-grid-size-picker.ts | 4 ++-- .../lovelace/card-features/hui-card-feature.ts | 16 ++++++---------- .../lovelace/card-features/hui-card-features.ts | 2 +- src/panels/lovelace/cards/hui-tile-card.ts | 5 +---- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/components/ha-grid-size-picker.ts b/src/components/ha-grid-size-picker.ts index 6ae6b7b37d75..f62fc5c01dc5 100644 --- a/src/components/ha-grid-size-picker.ts +++ b/src/components/ha-grid-size-picker.ts @@ -20,7 +20,7 @@ export class HaGridSizeEditor extends LitElement { @property({ attribute: false }) public value?: GridSizeValue; - @property({ attribute: false }) public rows = 6; + @property({ attribute: false }) public rows = 8; @property({ attribute: false }) public columns = 4; @@ -205,7 +205,7 @@ export class HaGridSizeEditor extends LitElement { .preview { position: relative; grid-area: preview; - aspect-ratio: 1 / 1; + aspect-ratio: 1 / 1.2; } .preview > div { position: absolute; diff --git a/src/panels/lovelace/card-features/hui-card-feature.ts b/src/panels/lovelace/card-features/hui-card-feature.ts index 2df5fcf143ce..a65fbd5ad587 100644 --- a/src/panels/lovelace/card-features/hui-card-feature.ts +++ b/src/panels/lovelace/card-features/hui-card-feature.ts @@ -1,5 +1,5 @@ import type { HassEntity } from "home-assistant-js-websocket"; -import { CSSResultGroup, LitElement, css, html, nothing } from "lit"; +import { LitElement, html, nothing } from "lit"; import { customElement, property } from "lit/decorators"; import { HomeAssistant } from "../../../types"; import type { HuiErrorCard } from "../cards/hui-error-card"; @@ -17,15 +17,15 @@ export class HuiCardFeature extends LitElement { @property({ attribute: false }) public color?: string; - private _featuresElement?: LovelaceCardFeature | HuiErrorCard; + private _element?: LovelaceCardFeature | HuiErrorCard; private _getFeatureElement(feature: LovelaceCardFeatureConfig) { - if (!this._featuresElement) { - this._featuresElement = createCardFeatureElement(feature); - return this._featuresElement; + if (!this._element) { + this._element = createCardFeatureElement(feature); + return this._element; } - return this._featuresElement; + return this._element; } protected render() { @@ -42,10 +42,6 @@ export class HuiCardFeature extends LitElement { } return html`${element}`; } - - static get styles(): CSSResultGroup { - return css``; - } } declare global { diff --git a/src/panels/lovelace/card-features/hui-card-features.ts b/src/panels/lovelace/card-features/hui-card-features.ts index 9c0a789315c4..c0c8bb94292a 100644 --- a/src/panels/lovelace/card-features/hui-card-features.ts +++ b/src/panels/lovelace/card-features/hui-card-features.ts @@ -52,7 +52,7 @@ export class HuiCardFeatures extends LitElement { flex-direction: column; padding: var(--feature-padding); padding-top: 0px; - gap: 12px; + gap: var(--feature-padding); width: 100%; height: 100%; box-sizing: border-box; diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts index d35e1b153401..d6e0bd826375 100644 --- a/src/panels/lovelace/cards/hui-tile-card.ts +++ b/src/panels/lovelace/cards/hui-tile-card.ts @@ -442,9 +442,6 @@ export class HuiTileCard extends LitElement implements LovelaceCard { .stateObj=${stateObj} .color=${this._config.color} .features=${this._config.features} - style=${styleMap({ - "--feature-count": this._config.features.length.toString(), - })} > ` : nothing} @@ -475,7 +472,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard { border-color 180ms ease-in-out; display: flex; flex-direction: column; - justify-content: space-evenly; + justify-content: space-between; } ha-card.active { --tile-color: var(--state-icon-color);