${this.checked
? this.pathOn
@@ -91,8 +92,9 @@ export class HaBarSwitch extends LitElement {
return css`
:host {
display: block;
- --switch-bar-color-on: var(--rgb-primary-color);
- --switch-bar-color-off: var(--rgb-disabled-color);
+ --switch-bar-on-color: rgb(var(--rgb-primary-color));
+ --switch-bar-off-color: rgb(var(--rgb-disabled-color));
+ --switch-bar-background-opacity: 0.2;
--switch-bar-thickness: 40px;
--switch-bar-border-radius: 12px;
--switch-bar-padding: 4px;
@@ -109,11 +111,20 @@ export class HaBarSwitch extends LitElement {
height: 100%;
width: 100%;
border-radius: var(--switch-bar-border-radius);
- background-color: rgba(var(--switch-bar-color-off), 0.3);
+ overflow: hidden;
padding: var(--switch-bar-padding);
- transition: background-color 180ms ease-in-out;
display: flex;
}
+ .switch .background {
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ width: 100%;
+ background-color: var(--switch-bar-off-color);
+ transition: background-color 180ms ease-in-out;
+ opacity: var(--switch-bar-background-opacity);
+ }
.switch .button {
width: 50%;
height: 100%;
@@ -123,18 +134,18 @@ export class HaBarSwitch extends LitElement {
);
transition: transform 180ms ease-in-out,
background-color 180ms ease-in-out;
- background-color: rgb(var(--switch-bar-color-off));
+ background-color: var(--switch-bar-off-color);
color: white;
display: flex;
align-items: center;
justify-content: center;
}
- :host([checked]) .switch {
- background-color: rgba(var(--switch-bar-color-on), 0.3);
+ :host([checked]) .switch .background {
+ background-color: var(--switch-bar-on-color);
}
:host([checked]) .switch .button {
transform: translateX(100%);
- background-color: rgb(var(--switch-bar-color-on));
+ background-color: var(--switch-bar-on-color);
}
:host([reversed]) .switch {
flex-direction: row-reverse;
diff --git a/src/components/tile/ha-tile-button.ts b/src/components/tile/ha-tile-button.ts
index d1adc849bf..c6555b3e11 100644
--- a/src/components/tile/ha-tile-button.ts
+++ b/src/components/tile/ha-tile-button.ts
@@ -41,7 +41,9 @@ export class HaTileButton extends LitElement {
@touchcancel=${this.handleRippleDeactivate}
>
- ${this._shouldRenderRipple ? html`
` : ""}
+ ${this._shouldRenderRipple && !this.disabled
+ ? html`
`
+ : ""}
`;
}
@@ -79,9 +81,10 @@ export class HaTileButton extends LitElement {
static get styles(): CSSResultGroup {
return css`
:host {
- --icon-color: rgb(var(--color, var(--rgb-primary-text-color)));
- --bg-color: rgba(var(--color, var(--rgb-disabled-color)), 0.2);
- --mdc-ripple-color: rgba(var(--color, var(--rgb-disabled-color)));
+ --tile-button-icon-color: var(--primary-text-color);
+ --tile-button-background-color: rgb(var(--rgb-disabled-color));
+ --tile-button-background-opacity: 0.2;
+ --mdc-ripple-color: var(--tile-button-background-color);
width: 40px;
height: 40px;
-webkit-tap-highlight-color: transparent;
@@ -97,25 +100,37 @@ export class HaTileButton extends LitElement {
height: 100%;
border-radius: 10px;
border: none;
- background-color: var(--bg-color);
- transition: background-color 280ms ease-in-out, transform 180ms ease-out;
margin: 0;
padding: 0;
box-sizing: border-box;
line-height: 0;
outline: none;
+ overflow: hidden;
+ background: none;
+ }
+ .button::before {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ width: 100%;
+ background-color: var(--tile-button-background-color);
+ transition: background-color 180ms ease-in-out,
+ opacity 180ms ease-in-out;
+ opacity: var(--tile-button-background-opacity);
}
.button ::slotted(*) {
--mdc-icon-size: 20px;
- color: var(--icon-color);
+ transition: color 180ms ease-in-out;
+ color: var(--tile-button-icon-color);
pointer-events: none;
}
.button:disabled {
cursor: not-allowed;
- background-color: rgba(var(--rgb-disabled-color), 0.2);
- }
- .button:disabled ::slotted(*) {
- color: rgb(var(--rgb-disabled-color));
+ --tile-button-background-color: rgb(var(--rgb-disabled-color));
+ --tile-button-icon-color: var(--disabled-text-color);
+ --tile-button-background-opacity: 0.2;
}
`;
}
diff --git a/src/components/tile/ha-tile-icon.ts b/src/components/tile/ha-tile-icon.ts
index e730035e93..a03643b10d 100644
--- a/src/components/tile/ha-tile-icon.ts
+++ b/src/components/tile/ha-tile-icon.ts
@@ -22,10 +22,20 @@ export class HaTileIcon extends LitElement {
static get styles(): CSSResultGroup {
return css`
:host {
- --icon-color: rgb(var(--color));
- --shape-color: rgba(var(--color), 0.2);
+ --tile-icon-color: rgb(var(--rgb-disabled-color));
--mdc-icon-size: 24px;
}
+ .shape::before {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ width: 100%;
+ background-color: var(--tile-icon-color);
+ transition: background-color 180ms ease-in-out;
+ opacity: 0.2;
+ }
.shape {
position: relative;
width: 40px;
@@ -34,13 +44,13 @@ export class HaTileIcon extends LitElement {
display: flex;
align-items: center;
justify-content: center;
- background-color: var(--shape-color);
- transition: background-color 180ms ease-in-out, color 180ms ease-in-out;
+ transition: color 180ms ease-in-out;
+ overflow: hidden;
}
.shape ha-icon,
.shape ha-svg-icon {
display: flex;
- color: var(--icon-color);
+ color: var(--tile-icon-color);
transition: color 180ms ease-in-out;
}
`;
diff --git a/src/components/tile/ha-tile-slider.ts b/src/components/tile/ha-tile-slider.ts
index f59e1d7c45..60f45378b5 100644
--- a/src/components/tile/ha-tile-slider.ts
+++ b/src/components/tile/ha-tile-slider.ts
@@ -48,12 +48,16 @@ export class HaTileSlider extends LitElement {
return css`
ha-bar-slider {
--slider-bar-color: var(
- --tile-slider-bar-color,
+ --tile-slider-color,
rgb(var(--rgb-primary-color))
);
--slider-bar-background: var(
- --tile-slider-bar-background,
- rgba(var(--rgb-disabled-color), 0.2)
+ --tile-slider-background,
+ rgb(var(--rgb-disabled-color))
+ );
+ --slider-bar-background-opacity: var(
+ --tile-slider-background-opacity,
+ 0.2
);
--slider-bar-thickness: 40px;
--slider-bar-border-radius: 10px;
diff --git a/src/panels/lovelace/cards/hui-tile-card.ts b/src/panels/lovelace/cards/hui-tile-card.ts
index 9d74391b99..ae5c588a5a 100644
--- a/src/panels/lovelace/cards/hui-tile-card.ts
+++ b/src/panels/lovelace/cards/hui-tile-card.ts
@@ -4,7 +4,7 @@ import { HassEntity } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { styleMap } from "lit/directives/style-map";
-import { computeRgbColor } from "../../../common/color/compute-color";
+import { computeCssColor } from "../../../common/color/compute-color";
import { hsv2rgb, rgb2hsv } from "../../../common/color/convert-color";
import { DOMAINS_TOGGLE } from "../../../common/const";
import { computeDomain } from "../../../common/entity/compute_domain";
@@ -131,7 +131,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
private _computeStateColor = memoize((entity: HassEntity, color?: string) => {
// Use custom color if active
if (color) {
- return stateActive(entity) ? computeRgbColor(color) : undefined;
+ return stateActive(entity) ? computeCssColor(color) : undefined;
}
// Use default color for person/device_tracker because color is on the badge
@@ -139,7 +139,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
computeDomain(entity.entity_id) === "person" ||
computeDomain(entity.entity_id) === "device_tracker"
) {
- return "var(--rgb-state-default-color)";
+ return "rgb(var(--rgb-state-default-color))";
}
// Use light color if the light support rgb
@@ -158,11 +158,13 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
hsvColor[1] = 0.4;
}
}
- return hsv2rgb(hsvColor).join(",");
+ return `rgb(${hsv2rgb(hsvColor).join(",")})`;
}
// Fallback to state color
- return stateColorCss(entity) ?? "var(--rgb-state-default-color)";
+ const stateColor =
+ stateColorCss(entity) ?? "var(--rgb-state-default-color)";
+ return `rgb(${stateColor})`;
});
private _computeStateDisplay(stateObj: HassEntity): TemplateResult | string {
@@ -226,11 +228,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
if (!stateObj) {
return html`
-
+
@@ -243,6 +241,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
>
@@ -311,6 +310,7 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
: null}
`;
@@ -86,7 +86,7 @@ export class HuiColorPicker extends LitElement {
return css`
.circle-color {
display: block;
- background-color: rgb(var(--circle-color));
+ background-color: var(--circle-color);
border-radius: 10px;
width: 20px;
height: 20px;
diff --git a/src/panels/lovelace/tile-features/hui-light-brightness-tile-feature.ts b/src/panels/lovelace/tile-features/hui-light-brightness-tile-feature.ts
index e096044724..6848604e21 100644
--- a/src/panels/lovelace/tile-features/hui-light-brightness-tile-feature.ts
+++ b/src/panels/lovelace/tile-features/hui-light-brightness-tile-feature.ts
@@ -73,8 +73,9 @@ class HuiLightBrightnessTileFeature
static get styles() {
return css`
ha-tile-slider {
- --tile-slider-bar-color: rgb(var(--tile-color));
- --tile-slider-bar-background: rgba(var(--tile-color), 0.2);
+ --tile-slider-color: var(--tile-color);
+ --tile-slider-background: var(--tile-color);
+ --tile-slider-background-opacity: 0.2;
}
.container {
padding: 0 12px 12px 12px;