From 4d291e9e99f4bccc7394220ca262f31aad0e4f07 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 19 Aug 2024 09:26:52 +0200 Subject: [PATCH] Rename to grid density --- src/data/lovelace/config/section.ts | 2 +- .../card-editor/hui-card-layout-editor.ts | 4 +- .../hui-section-settings-editor.ts | 38 +++++++++---------- .../lovelace/sections/hui-grid-section.ts | 4 +- src/translations/en.json | 4 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/data/lovelace/config/section.ts b/src/data/lovelace/config/section.ts index 5e3b899fff41..928c1231424a 100644 --- a/src/data/lovelace/config/section.ts +++ b/src/data/lovelace/config/section.ts @@ -13,7 +13,7 @@ export interface LovelaceSectionConfig extends LovelaceBaseSectionConfig { } export interface LovelaceGridSectionConfig extends LovelaceSectionConfig { - column_base?: number; + grid_base?: number; } export interface LovelaceStrategySectionConfig diff --git a/src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts b/src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts index f15d784c6560..c36c85326d26 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts @@ -23,7 +23,7 @@ import { HomeAssistant } from "../../../../types"; import { HuiCard } from "../../cards/hui-card"; import { computeSizeOnGrid, - DEFAULT_COLUMN_BASE, + DEFAULT_GRID_BASE, } from "../../sections/hui-grid-section"; import { LovelaceLayoutOptions } from "../../types"; import { LovelaceGridSectionConfig } from "../../../../data/lovelace/config/section"; @@ -142,7 +142,7 @@ export class HuiCardLayoutEditor extends LitElement { .rowMax=${options.grid_max_rows} .columnMin=${options.grid_min_columns} .columnMax=${options.grid_max_columns} - .columns=${this.sectionConfig.column_base || DEFAULT_COLUMN_BASE} + .columns=${this.sectionConfig.grid_base || DEFAULT_GRID_BASE} > `} `; diff --git a/src/panels/lovelace/editor/section-editor/hui-section-settings-editor.ts b/src/panels/lovelace/editor/section-editor/hui-section-settings-editor.ts index 17a4f31d41b3..efc45d59b238 100644 --- a/src/panels/lovelace/editor/section-editor/hui-section-settings-editor.ts +++ b/src/panels/lovelace/editor/section-editor/hui-section-settings-editor.ts @@ -13,13 +13,13 @@ import { LovelaceSectionRawConfig, } from "../../../../data/lovelace/config/section"; import { HomeAssistant } from "../../../../types"; -import { DEFAULT_COLUMN_BASE } from "../../sections/hui-grid-section"; +import { DEFAULT_GRID_BASE } from "../../sections/hui-grid-section"; -type ColumnDensity = "default" | "dense" | "custom"; +type GridDensity = "default" | "dense" | "custom"; type SettingsData = { title: string; - column_density?: ColumnDensity; + grid_density?: GridDensity; }; @customElement("hui-section-settings-editor") @@ -32,7 +32,7 @@ export class HuiDialogEditSection extends LitElement { ( localize: LocalizeFunc, type?: string | undefined, - columnDensity?: ColumnDensity, + columnDensity?: GridDensity, columnBase?: number ) => [ @@ -43,7 +43,7 @@ export class HuiDialogEditSection extends LitElement { ...(type === "grid" ? ([ { - name: "column_density", + name: "grid_density", default: "default", selector: { select: { @@ -51,14 +51,14 @@ export class HuiDialogEditSection extends LitElement { options: [ { label: localize( - `ui.panel.lovelace.editor.edit_section.settings.column_density_options.default`, + `ui.panel.lovelace.editor.edit_section.settings.grid_density_options.default`, { count: 4 } ), value: "default", }, { label: localize( - `ui.panel.lovelace.editor.edit_section.settings.column_density_options.dense`, + `ui.panel.lovelace.editor.edit_section.settings.grid_density_options.dense`, { count: 6 } ), value: "dense", @@ -67,7 +67,7 @@ export class HuiDialogEditSection extends LitElement { ? [ { label: localize( - `ui.panel.lovelace.editor.edit_section.settings.column_density_options.custom`, + `ui.panel.lovelace.editor.edit_section.settings.grid_density_options.custom`, { count: columnBase } ), value: "custom", @@ -90,16 +90,16 @@ export class HuiDialogEditSection extends LitElement { } render() { - const columnBase = this._isGridSectionConfig(this.config) - ? this.config.column_base || DEFAULT_COLUMN_BASE + const gridBase = this._isGridSectionConfig(this.config) + ? this.config.grid_base || DEFAULT_GRID_BASE : undefined; const columnDensity = - columnBase === 6 ? "dense" : columnBase === 4 ? "default" : "custom"; + gridBase === 6 ? "dense" : gridBase === 4 ? "default" : "custom"; const data: SettingsData = { title: this.config.title || "", - column_density: columnDensity, + grid_density: columnDensity, }; const type = "type" in this.config ? this.config.type : undefined; @@ -108,7 +108,7 @@ export class HuiDialogEditSection extends LitElement { this.hass.localize, type, columnDensity, - columnBase + gridBase ); return html` @@ -141,7 +141,7 @@ export class HuiDialogEditSection extends LitElement { ev.stopPropagation(); const newData = ev.detail.value as SettingsData; - const { title, column_density } = newData; + const { title, grid_density } = newData; const newConfig: LovelaceSectionRawConfig = { ...this.config, @@ -149,15 +149,15 @@ export class HuiDialogEditSection extends LitElement { }; if (this._isGridSectionConfig(newConfig)) { - const column_base = - column_density === "default" + const gridBase = + grid_density === "default" ? 4 - : column_density === "dense" + : grid_density === "dense" ? 6 : undefined; - if (column_base) { - (newConfig as LovelaceGridSectionConfig).column_base = column_base; + if (gridBase) { + (newConfig as LovelaceGridSectionConfig).grid_base = gridBase; } } diff --git a/src/panels/lovelace/sections/hui-grid-section.ts b/src/panels/lovelace/sections/hui-grid-section.ts index e52307be8917..98e271eedc7f 100644 --- a/src/panels/lovelace/sections/hui-grid-section.ts +++ b/src/panels/lovelace/sections/hui-grid-section.ts @@ -61,7 +61,7 @@ export const computeSizeOnGrid = ( }; }; -export const DEFAULT_COLUMN_BASE = 4; +export const DEFAULT_GRID_BASE = 4; export class GridSection extends LitElement implements LovelaceSectionElement { @property({ attribute: false }) public hass!: HomeAssistant; @@ -100,7 +100,7 @@ export class GridSection extends LitElement implements LovelaceSectionElement { const editMode = Boolean(this.lovelace?.editMode && !this.isStrategy); - const columnCount = this._config.column_base ?? DEFAULT_COLUMN_BASE; + const columnCount = this._config.grid_base ?? DEFAULT_GRID_BASE; return html` ${this._config.title || this.lovelace?.editMode diff --git a/src/translations/en.json b/src/translations/en.json index dc750feee31a..ebc7bb743d29 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5646,8 +5646,8 @@ "settings": { "title": "Title", "title_helper": "The title will appear at the top of section. Leave empty to hide the title.", - "column_density": "Column density", - "column_density_options": { + "grid_density": "Grid density", + "grid_density_options": { "default": "Default ({count} columns)", "dense": "Dense ({count} columns)", "custom": "Custom ({count} {count, plural,\n one {column}\n other {columns}\n})"