Simplify config

This commit is contained in:
Paul Bottein 2024-05-27 14:04:04 +02:00
parent fb499f09fb
commit 0dd290cd85
No known key found for this signature in database
4 changed files with 7 additions and 13 deletions

View File

@ -75,7 +75,7 @@ export class HuiCardFeatures extends LitElement {
return nothing;
}
if (this.layout?.type === "compact") {
if (this.layout === "compact") {
const currentFeature = this.features[this._currentFeatureIndex];
return html`
<div class="container horizontal">
@ -95,7 +95,7 @@ export class HuiCardFeatures extends LitElement {
`;
}
const containerClass = this.layout?.type ? ` ${this.layout.type}` : "";
const containerClass = this.layout ? ` ${this.layout}` : "";
return html`
<div class="container${containerClass}">

View File

@ -126,12 +126,12 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
grid_columns: 2,
grid_rows: 1,
};
const featureLayoutType = this._config?.feature_layout?.type || "vertical";
const featureLayout = this._config?.feature_layout || "vertical";
if (this._config?.features?.length) {
if (featureLayoutType === "compact") {
if (featureLayout === "compact") {
options.grid_rows += 1;
} else if (featureLayoutType === "horizontal") {
} else if (featureLayout === "horizontal") {
options.grid_rows += 1;
options.grid_columns = 4;
} else {

View File

@ -24,9 +24,7 @@ export type AlarmPanelCardConfigState =
| "arm_vacation"
| "arm_custom_bypass";
export type LovelaceCardFeatureLayout = {
type?: "vertical" | "horizontal" | "compact";
};
export type LovelaceCardFeatureLayout = "vertical" | "horizontal" | "compact";
export interface AlarmPanelCardConfig extends LovelaceCardConfig {
entity: string;

View File

@ -2,9 +2,5 @@ import { any, array, enums, object, optional } from "superstruct";
export const cardFeatureConfig = object({
features: optional(array(any())),
feature_layout: optional(
object({
type: enums(["vertical", "horizontal", "compact"]),
})
),
feature_layout: optional(enums(["vertical", "horizontal", "compact"])),
});