From d3f6ebd1d07940cc19d2e5ff4616786ff81dd790 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Fri, 10 Nov 2023 14:22:10 +0100 Subject: [PATCH] Add unit to temperature tile number button group (#17841) * Add unit to temperature tile number button group * Update gallery * Use blank before unit * Hide unit if no space * Fix build --------- Co-authored-by: Paul Bottein --- .../components/ha-control-number-buttons.ts | 7 ++++ package.json | 1 + .../entity/compute_attribute_display.ts | 15 +++------ src/common/entity/compute_state_display.ts | 24 ++++++++------ src/components/ha-control-number-buttons.ts | 32 ++++++++++++++++--- .../hui-target-temperature-tile-feature.ts | 8 +++++ yarn.lock | 11 +------ 7 files changed, 62 insertions(+), 36 deletions(-) diff --git a/gallery/src/pages/components/ha-control-number-buttons.ts b/gallery/src/pages/components/ha-control-number-buttons.ts index 8afa9ee487..d8770dd4a1 100644 --- a/gallery/src/pages/components/ha-control-number-buttons.ts +++ b/gallery/src/pages/components/ha-control-number-buttons.ts @@ -11,6 +11,7 @@ const buttons: { min?: number; max?: number; step?: number; + unit?: string; class?: string; }[] = [ { @@ -29,6 +30,11 @@ const buttons: { label: "Custom", class: "custom", }, + { + id: "unit", + label: "With unit", + unit: "m", + }, ]; @customElement("demo-components-ha-control-number-buttons") @@ -50,6 +56,7 @@ export class DemoHarControlNumberButtons extends LitElement {
Config: ${JSON.stringify(config)}
- ${displayedValue} + ${value} ${unit ? html`${unit}` : nothing}