mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16:39 +00:00
Simplify config
This commit is contained in:
parent
fb499f09fb
commit
0dd290cd85
@ -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}">
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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"])),
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user