From b26e4a6b3ac2e32a64a8b035230eda761b407cbf Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Wed, 5 Apr 2023 12:13:42 -0700 Subject: [PATCH 1/7] create spacer chip --- src/cards/chips-card/chips-card-editor.ts | 6 ++ src/cards/chips-card/chips/index.ts | 1 + .../chips-card/chips/spacer-chip-editor.ts | 55 +++++++++++++++++++ src/cards/chips-card/chips/spacer-chip.ts | 50 +++++++++++++++++ src/translations/en.json | 1 + src/utils/lovelace/chip/types.ts | 8 ++- 6 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/cards/chips-card/chips/spacer-chip-editor.ts create mode 100644 src/cards/chips-card/chips/spacer-chip.ts diff --git a/src/cards/chips-card/chips-card-editor.ts b/src/cards/chips-card/chips-card-editor.ts index 6463b95bb..ea8790a0a 100644 --- a/src/cards/chips-card/chips-card-editor.ts +++ b/src/cards/chips-card/chips-card-editor.ts @@ -111,6 +111,10 @@ const templateChipConfigStruct = object({ entity_id: optional(union([string(), array(string())])), }); +const spacerChipConfigStruct = object({ + type: literal("spacer"), +}); + const chipsConfigStruct = dynamic((value) => { if (value && typeof value === "object" && "type" in value) { switch ((value as LovelaceChipConfig).type!) { @@ -130,6 +134,8 @@ const chipsConfigStruct = dynamic((value) => { return lightChipConfigStruct; case "template": return templateChipConfigStruct; + case "spacer": + return spacerChipConfigStruct; } } return object(); diff --git a/src/cards/chips-card/chips/index.ts b/src/cards/chips-card/chips/index.ts index 69a4e257f..9bedc0ac3 100644 --- a/src/cards/chips-card/chips/index.ts +++ b/src/cards/chips-card/chips/index.ts @@ -7,3 +7,4 @@ export { TemplateChip } from "./template-chip"; export { ConditionalChip } from "./conditional-chip"; export { LightChip } from "./light-chip"; export { AlarmControlPanelChip } from "./alarm-control-panel-chip"; +export { SpacerChip } from "./spacer-chip"; diff --git a/src/cards/chips-card/chips/spacer-chip-editor.ts b/src/cards/chips-card/chips/spacer-chip-editor.ts new file mode 100644 index 000000000..2b565fa81 --- /dev/null +++ b/src/cards/chips-card/chips/spacer-chip-editor.ts @@ -0,0 +1,55 @@ +import { html, LitElement, TemplateResult } from "lit"; +import { customElement, property, state } from "lit/decorators.js"; +import memoizeOne from "memoize-one"; +import { fireEvent, HomeAssistant } from "../../../ha"; +import setupCustomlocalize from "../../../localize"; +import { GENERIC_LABELS } from "../../../utils/form/generic-fields"; +import { HaFormSchema } from "../../../utils/form/ha-form"; +import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chip-element"; +import { SpacerChipConfig } from "../../../utils/lovelace/chip/types"; +import { LovelaceChipEditor } from "../../../utils/lovelace/types"; + +const computeSchema = memoizeOne((): HaFormSchema[] => []); + +@customElement(computeChipEditorComponentName("spacer")) +export class SpacerChipEditor extends LitElement implements LovelaceChipEditor { + @property({ attribute: false }) public hass?: HomeAssistant; + + @state() private _config?: SpacerChipConfig; + + public setConfig(config: SpacerChipConfig): void { + this._config = config; + } + + private _computeLabel = (schema: HaFormSchema) => { + const customLocalize = setupCustomlocalize(this.hass!); + + if (GENERIC_LABELS.includes(schema.name)) { + return customLocalize(`editor.card.generic.${schema.name}`); + } + return this.hass!.localize(`ui.panel.lovelace.editor.card.generic.${schema.name}`); + }; + + protected render(): TemplateResult { + if (!this.hass || !this._config) { + return html``; + } + + const schema = computeSchema(); + + return html` + +
There are currently no config options for this chip.
+ `; + } + + private _valueChanged(ev: CustomEvent): void { + fireEvent(this, "config-changed", { config: ev.detail.value }); + } +} diff --git a/src/cards/chips-card/chips/spacer-chip.ts b/src/cards/chips-card/chips/spacer-chip.ts new file mode 100644 index 000000000..b70f23e56 --- /dev/null +++ b/src/cards/chips-card/chips/spacer-chip.ts @@ -0,0 +1,50 @@ +import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { customElement, property, state } from "lit/decorators.js"; +import { HomeAssistant } from "../../../ha"; +import { + computeChipComponentName, + computeChipEditorComponentName, +} from "../../../utils/lovelace/chip/chip-element"; +import { SpacerChipConfig, LovelaceChip } from "../../../utils/lovelace/chip/types"; +import { LovelaceChipEditor } from "../../../utils/lovelace/types"; + +@customElement(computeChipComponentName("spacer")) +export class SpacerChip extends LitElement implements LovelaceChip { + public static async getConfigElement(): Promise { + await import("./spacer-chip-editor"); + return document.createElement( + computeChipEditorComponentName("spacer") + ) as LovelaceChipEditor; + } + + public static async getStubConfig(hass: HomeAssistant): Promise { + const entities = Object.keys(hass.states); + return { + type: `spacer`, + }; + } + + @property({ attribute: false }) public hass?: HomeAssistant; + + @state() private _config?: SpacerChipConfig; + + public setConfig(config: SpacerChipConfig): void { + this._config = config; + } + + protected render(): TemplateResult { + if (!this.hass || !this._config) { + return html`
`; + } + + return html`
`; + } + + static get styles(): CSSResultGroup { + return css` + :host { + flex-grow: 1; + } + `; + } +} diff --git a/src/translations/en.json b/src/translations/en.json index ab6b8c0ed..648f6b3f8 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -167,6 +167,7 @@ "entity": "Entity", "light": "Light", "menu": "Menu", + "spacer": "Spacer", "template": "Template", "weather": "Weather" } diff --git a/src/utils/lovelace/chip/types.ts b/src/utils/lovelace/chip/types.ts index b6230c7e2..3cc3d3edc 100644 --- a/src/utils/lovelace/chip/types.ts +++ b/src/utils/lovelace/chip/types.ts @@ -92,6 +92,10 @@ export type LightChipConfig = { double_tap_action?: ActionConfig; }; +export type SpacerChipConfig = { + type: "spacer"; +}; + export type LovelaceChipConfig = | ActionChipConfig | AlarmControlPanelChipConfig @@ -101,7 +105,8 @@ export type LovelaceChipConfig = | WeatherChipConfig | TemplateChipConfig | ConditionalChipConfig - | LightChipConfig; + | LightChipConfig + | SpacerChipConfig; export const CHIP_LIST: LovelaceChipConfig["type"][] = [ "action", @@ -111,6 +116,7 @@ export const CHIP_LIST: LovelaceChipConfig["type"][] = [ "entity", "light", "menu", + "spacer", "template", "weather", ]; From 62b327cd1de70e6ee7b1a5ddbc528afe2f0c6f60 Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Thu, 6 Apr 2023 05:53:52 -0700 Subject: [PATCH 2/7] remove unused code --- .../chips-card/chips/spacer-chip-editor.ts | 53 +++++-------------- src/cards/chips-card/chips/spacer-chip.ts | 22 ++------ 2 files changed, 17 insertions(+), 58 deletions(-) diff --git a/src/cards/chips-card/chips/spacer-chip-editor.ts b/src/cards/chips-card/chips/spacer-chip-editor.ts index 2b565fa81..8d3a66bb0 100644 --- a/src/cards/chips-card/chips/spacer-chip-editor.ts +++ b/src/cards/chips-card/chips/spacer-chip-editor.ts @@ -1,55 +1,28 @@ -import { html, LitElement, TemplateResult } from "lit"; -import { customElement, property, state } from "lit/decorators.js"; -import memoizeOne from "memoize-one"; -import { fireEvent, HomeAssistant } from "../../../ha"; -import setupCustomlocalize from "../../../localize"; -import { GENERIC_LABELS } from "../../../utils/form/generic-fields"; -import { HaFormSchema } from "../../../utils/form/ha-form"; +import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { customElement, property } from "lit/decorators.js"; +import { HomeAssistant } from "../../../ha"; import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chip-element"; -import { SpacerChipConfig } from "../../../utils/lovelace/chip/types"; import { LovelaceChipEditor } from "../../../utils/lovelace/types"; -const computeSchema = memoizeOne((): HaFormSchema[] => []); - @customElement(computeChipEditorComponentName("spacer")) export class SpacerChipEditor extends LitElement implements LovelaceChipEditor { @property({ attribute: false }) public hass?: HomeAssistant; - @state() private _config?: SpacerChipConfig; - - public setConfig(config: SpacerChipConfig): void { - this._config = config; - } - - private _computeLabel = (schema: HaFormSchema) => { - const customLocalize = setupCustomlocalize(this.hass!); - - if (GENERIC_LABELS.includes(schema.name)) { - return customLocalize(`editor.card.generic.${schema.name}`); - } - return this.hass!.localize(`ui.panel.lovelace.editor.card.generic.${schema.name}`); - }; + public setConfig(): void {} protected render(): TemplateResult { - if (!this.hass || !this._config) { + if (!this.hass) { return html``; } - - const schema = computeSchema(); - - return html` - -
There are currently no config options for this chip.
- `; + + return html`
There are currently no config options for this chip.
`; } - private _valueChanged(ev: CustomEvent): void { - fireEvent(this, "config-changed", { config: ev.detail.value }); + static get styles(): CSSResultGroup { + return css` + div { + margin-top: 20px; + } + `; } } diff --git a/src/cards/chips-card/chips/spacer-chip.ts b/src/cards/chips-card/chips/spacer-chip.ts index b70f23e56..a8e00787c 100644 --- a/src/cards/chips-card/chips/spacer-chip.ts +++ b/src/cards/chips-card/chips/spacer-chip.ts @@ -1,6 +1,5 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property, state } from "lit/decorators.js"; -import { HomeAssistant } from "../../../ha"; +import { customElement } from "lit/decorators.js"; import { computeChipComponentName, computeChipEditorComponentName, @@ -17,26 +16,13 @@ export class SpacerChip extends LitElement implements LovelaceChip { ) as LovelaceChipEditor; } - public static async getStubConfig(hass: HomeAssistant): Promise { - const entities = Object.keys(hass.states); - return { - type: `spacer`, - }; + public static async getStubConfig(): Promise { + return { type: `spacer` }; } - @property({ attribute: false }) public hass?: HomeAssistant; - - @state() private _config?: SpacerChipConfig; - - public setConfig(config: SpacerChipConfig): void { - this._config = config; - } + public setConfig(): void {} protected render(): TemplateResult { - if (!this.hass || !this._config) { - return html`
`; - } - return html`
`; } From 283606f8a6b72e65fed13fcc49cb76aee80d1eb5 Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Thu, 6 Apr 2023 05:55:45 -0700 Subject: [PATCH 3/7] add translation --- src/cards/chips-card/chips/spacer-chip-editor.ts | 7 +++++-- src/translations/en.json | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cards/chips-card/chips/spacer-chip-editor.ts b/src/cards/chips-card/chips/spacer-chip-editor.ts index 8d3a66bb0..14e76e7d4 100644 --- a/src/cards/chips-card/chips/spacer-chip-editor.ts +++ b/src/cards/chips-card/chips/spacer-chip-editor.ts @@ -1,6 +1,7 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators.js"; import { HomeAssistant } from "../../../ha"; +import setupCustomlocalize from "../../../localize"; import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chip-element"; import { LovelaceChipEditor } from "../../../utils/lovelace/types"; @@ -14,8 +15,10 @@ export class SpacerChipEditor extends LitElement implements LovelaceChipEditor { if (!this.hass) { return html``; } - - return html`
There are currently no config options for this chip.
`; + + const customLocalize = setupCustomlocalize(this.hass!); + + return html`
${customLocalize(`editor.chip.no_config`)}
`; } static get styles(): CSSResultGroup { diff --git a/src/translations/en.json b/src/translations/en.json index 648f6b3f8..1aeec9b67 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -171,7 +171,8 @@ "template": "Template", "weather": "Weather" } - } + }, + "no_config": "There are currently no config options for this chip." } } } From 67899067d874b27316b58a60cf7e1fa7148e06bc Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Thu, 6 Apr 2023 05:57:39 -0700 Subject: [PATCH 4/7] add spacer chip to docs --- docs/cards/chips.md | 7 +++++++ docs/images/chip_spacer_dark.png | Bin 0 -> 3982 bytes docs/images/chip_spacer_light.png | Bin 0 -> 3385 bytes 3 files changed, 7 insertions(+) create mode 100644 docs/images/chip_spacer_dark.png create mode 100644 docs/images/chip_spacer_light.png diff --git a/docs/cards/chips.md b/docs/cards/chips.md index d0fa9bd96..7b38c8ee0 100644 --- a/docs/cards/chips.md +++ b/docs/cards/chips.md @@ -59,6 +59,13 @@ An light chip allows you to display light. A menu chip allows you to open the drawer in mobile. +### Spacer chip + +![Chip menu light](../images/chip-spacer-light.png) +![Chip menu dark](../images/chip-spacer-dark.png) + +A spacer chip allows you to space chips apart. + ### Template chip ![Chip template light](../images/chip-template-light.png) diff --git a/docs/images/chip_spacer_dark.png b/docs/images/chip_spacer_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..3c6f5b9a19161ec8c09705acb3a57393b0a603b3 GIT binary patch literal 3982 zcmZ`+byO70*QS(Ex)%_n8-Yban%#w6x&%olndi=(Kkm%A^PGF1LFj0yl9B*OaBy%)p=uyK92{IL>{^Tn4~uw5cdl52 z>#e7%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o3h*?ai8N(Nv z(U?jk?4w*SxFWhjfGpKYQS8B~NLnY>lM(81unC9Y%z|FXEGQiOUy%xgREH#uqApOt z#=#WnB{aB3eG|=_}kLbl1L=z%?#kiQ&#cK zVKyR)0a0vF6idX@NbhmH@xA3aHav+Vf(WIcRtU9tTV)mw60SrYQ_#`T;d3KH5&<*< zo2cR(o1#RioJ%D_@S_*-VC0AQX2>znm|O;d7pV$0FNzW!Tn@*>{cu8Dkv+yW#{*P@ zNJJ)Ny(f;uNPEJGg}@Xb6Qo$A3=)czJ?V6syaOG<8VVNnvjMlX;FCnQ6Wi&zMZ zCqc+WAPPM_J;)WN3=9k)B{>@u3b6qVVo-+00KgbNvXesvut8C5aN-5$#6@w`u7W^Z zu&ff2j4lS`OzvU Date: Thu, 6 Apr 2023 06:04:03 -0700 Subject: [PATCH 5/7] fix doc images --- .../{chip_spacer_dark.png => chip-spacer-dark.png} | Bin ...{chip_spacer_light.png => chip-spacer-light.png} | Bin 2 files changed, 0 insertions(+), 0 deletions(-) rename docs/images/{chip_spacer_dark.png => chip-spacer-dark.png} (100%) rename docs/images/{chip_spacer_light.png => chip-spacer-light.png} (100%) diff --git a/docs/images/chip_spacer_dark.png b/docs/images/chip-spacer-dark.png similarity index 100% rename from docs/images/chip_spacer_dark.png rename to docs/images/chip-spacer-dark.png diff --git a/docs/images/chip_spacer_light.png b/docs/images/chip-spacer-light.png similarity index 100% rename from docs/images/chip_spacer_light.png rename to docs/images/chip-spacer-light.png From 0b973eaba4cf5393be6b9720452d6f894604e0a5 Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Fri, 7 Apr 2023 07:03:36 -0700 Subject: [PATCH 6/7] remove editor --- .../chips-card/chips-card-chips-editor.ts | 30 +++++++++++------- .../chips-card/chips/spacer-chip-editor.ts | 31 ------------------- src/cards/chips-card/chips/spacer-chip.ts | 25 ++------------- src/translations/en.json | 3 +- 4 files changed, 22 insertions(+), 67 deletions(-) delete mode 100644 src/cards/chips-card/chips/spacer-chip-editor.ts diff --git a/src/cards/chips-card/chips-card-chips-editor.ts b/src/cards/chips-card/chips-card-chips-editor.ts index ae36f91f9..ab6a19f63 100644 --- a/src/cards/chips-card/chips-card-chips-editor.ts +++ b/src/cards/chips-card/chips-card-chips-editor.ts @@ -70,27 +70,33 @@ export class ChipsCardEditorChips extends MushroomBaseElement {
${this._renderChipLabel(chipConf)} - ${this._renderChipSecondary(chipConf)} + + ${this._renderChipSecondary(chipConf)} +
`} + ${!chipConf.type.includes("spacer") + ? html` + + + + ` + : ""} - - - + ` diff --git a/src/cards/chips-card/chips/spacer-chip-editor.ts b/src/cards/chips-card/chips/spacer-chip-editor.ts deleted file mode 100644 index 14e76e7d4..000000000 --- a/src/cards/chips-card/chips/spacer-chip-editor.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property } from "lit/decorators.js"; -import { HomeAssistant } from "../../../ha"; -import setupCustomlocalize from "../../../localize"; -import { computeChipEditorComponentName } from "../../../utils/lovelace/chip/chip-element"; -import { LovelaceChipEditor } from "../../../utils/lovelace/types"; - -@customElement(computeChipEditorComponentName("spacer")) -export class SpacerChipEditor extends LitElement implements LovelaceChipEditor { - @property({ attribute: false }) public hass?: HomeAssistant; - - public setConfig(): void {} - - protected render(): TemplateResult { - if (!this.hass) { - return html``; - } - - const customLocalize = setupCustomlocalize(this.hass!); - - return html`
${customLocalize(`editor.chip.no_config`)}
`; - } - - static get styles(): CSSResultGroup { - return css` - div { - margin-top: 20px; - } - `; - } -} diff --git a/src/cards/chips-card/chips/spacer-chip.ts b/src/cards/chips-card/chips/spacer-chip.ts index a8e00787c..f7310bd61 100644 --- a/src/cards/chips-card/chips/spacer-chip.ts +++ b/src/cards/chips-card/chips/spacer-chip.ts @@ -1,31 +1,12 @@ -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { css, CSSResultGroup, LitElement } from "lit"; import { customElement } from "lit/decorators.js"; -import { - computeChipComponentName, - computeChipEditorComponentName, -} from "../../../utils/lovelace/chip/chip-element"; -import { SpacerChipConfig, LovelaceChip } from "../../../utils/lovelace/chip/types"; -import { LovelaceChipEditor } from "../../../utils/lovelace/types"; +import { LovelaceChip } from "../../../utils/lovelace/chip/types"; +import { computeChipComponentName } from "../../../utils/lovelace/chip/chip-element"; @customElement(computeChipComponentName("spacer")) export class SpacerChip extends LitElement implements LovelaceChip { - public static async getConfigElement(): Promise { - await import("./spacer-chip-editor"); - return document.createElement( - computeChipEditorComponentName("spacer") - ) as LovelaceChipEditor; - } - - public static async getStubConfig(): Promise { - return { type: `spacer` }; - } - public setConfig(): void {} - protected render(): TemplateResult { - return html`
`; - } - static get styles(): CSSResultGroup { return css` :host { diff --git a/src/translations/en.json b/src/translations/en.json index 1aeec9b67..648f6b3f8 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -171,8 +171,7 @@ "template": "Template", "weather": "Weather" } - }, - "no_config": "There are currently no config options for this chip." + } } } } From ab07c50e4eb6fe6fccebfd40249c4e8bbf236762 Mon Sep 17 00:00:00 2001 From: BizzySleepin Date: Fri, 7 Apr 2023 09:51:02 -0700 Subject: [PATCH 7/7] cleam code --- src/cards/chips-card/chips-card-chips-editor.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cards/chips-card/chips-card-chips-editor.ts b/src/cards/chips-card/chips-card-chips-editor.ts index ab6a19f63..107604675 100644 --- a/src/cards/chips-card/chips-card-chips-editor.ts +++ b/src/cards/chips-card/chips-card-chips-editor.ts @@ -76,8 +76,9 @@ export class ChipsCardEditorChips extends MushroomBaseElement { `} - ${!chipConf.type.includes("spacer") - ? html` + ${chipConf.type == "spacer" + ? "" + : html` - ` - : ""} + `}