From a9f1c4a19843fd24aacd72c1b87cb6fbb92d08e5 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 31 May 2023 11:48:22 +0200 Subject: [PATCH] Add button bar for light modes (#16683) * Add button bar for light modes * Add disabled style * Fix favorite colors display condition * Fix color temp button --- .../ha-more-info-light-favorite-colors.ts | 2 +- .../more-info/controls/more-info-light.ts | 193 ++++++++++-------- src/translations/en.json | 1 + 3 files changed, 105 insertions(+), 91 deletions(-) diff --git a/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts b/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts index 5828777f1c..390588bf99 100644 --- a/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts +++ b/src/dialogs/more-info/components/lights/ha-more-info-light-favorite-colors.ts @@ -294,7 +294,7 @@ export class HaMoreInfoLightFavoriteColors extends LitElement { display: flex; align-items: center; justify-content: center; - margin-bottom: 12px; + margin: -8px; flex-wrap: wrap; max-width: 250px; user-select: none; diff --git a/src/dialogs/more-info/controls/more-info-light.ts b/src/dialogs/more-info/controls/more-info-light.ts index db541897a9..1614eaeb3b 100644 --- a/src/dialogs/more-info/controls/more-info-light.ts +++ b/src/dialogs/more-info/controls/more-info-light.ts @@ -100,6 +100,11 @@ class MoreInfoLight extends LitElement { LightEntityFeature.EFFECT ); + const hasFavoriteColors = + this.entry && + (this.entry.options?.light?.favorite_colors == null || + this.entry.options.light.favorite_colors.length > 0); + const stateOverride = this._selectedBrightness ? `${Math.round(this._selectedBrightness)}${blankBeforePercent( this.hass!.locale @@ -132,88 +137,86 @@ class MoreInfoLight extends LitElement { `} ${supportsColorTemp || supportsColor || supportsBrightness ? html` -
-
- ${supportsBrightness - ? html` - - - - ` - : nothing} - ${supportsColor - ? html` - - - ` - : nothing} - ${supportsColorTemp - ? html` - - - ` - : nothing} - ${supportsWhite - ? html` - - - - ` - : nothing} -
- ${this.editMode || - (this.entry?.options?.light?.favorite_colors?.length ?? 0) > 0 +
+ ${supportsBrightness ? html` - - + + + ` + : nothing} + ${supportsColor + ? html` + + + + ` + : nothing} + ${supportsColorTemp + ? html` + + + + ` + : nothing} + ${supportsWhite + ? html` + + + ` : nothing}
+ ${this.entry && (this.editMode || hasFavoriteColors) + ? html` + + + ` + : nothing} ` : nothing} ${supportsEffects && this.stateObj.attributes.effect_list @@ -291,7 +294,7 @@ class MoreInfoLight extends LitElement { ), { entityId: this.stateObj!.entity_id, - defaultMode: ev.target.mode, + defaultMode: ev.currentTarget.mode, } ); }; @@ -323,20 +326,30 @@ class MoreInfoLight extends LitElement { return [ moreInfoControlStyle, css` - .buttons { - flex-wrap: wrap; - max-width: 250px; + .button-bar { + display: flex; + flex-direction: row; + align-items: center; + height: 48px; + border-radius: 24px; + background-color: rgba(139, 145, 151, 0.1); + box-sizing: border-box; + width: auto; } - .color-mode, - .color-temp-mode { - border-radius: 9999px; - --md-sys-color-outline: var(--divider-color); + .wheel { + width: 30px; + height: 30px; + flex: none; + border-radius: 15px; } - .color-mode { + ha-icon-button[disabled] .wheel { + filter: grayscale(1) opacity(0.5); + } + .wheel.color { background-image: url("/static/images/color_wheel.png"); background-size: cover; } - .color-temp-mode { + .wheel.color-temp { background: linear-gradient( 0, rgb(166, 209, 255) 0%, @@ -344,9 +357,9 @@ class MoreInfoLight extends LitElement { rgb(255, 160, 0) 100% ); } - .color-rgb-mode[disabled], - .color-temp-mode[disabled] { - filter: grayscale(1) opacity(0.5); + .buttons { + flex-wrap: wrap; + max-width: 250px; } `, ]; diff --git a/src/translations/en.json b/src/translations/en.json index b07a7addb0..a39cecf4cc 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -930,6 +930,7 @@ "edit_mode": "Edit favorite colors", "toggle": "Toggle", "change_color": "Change color", + "change_color_temp": "Change color temperature", "set_white": "Set white", "select_effect": "Select effect", "brightness": "Brightness",