diff --git a/gallery/src/pages/components/ha-bar-slider.ts b/gallery/src/pages/components/ha-bar-slider.ts index ece20c2a7f..261169d6dc 100644 --- a/gallery/src/pages/components/ha-bar-slider.ts +++ b/gallery/src/pages/components/ha-bar-slider.ts @@ -142,7 +142,8 @@ export class DemoHaBarSlider extends LitElement { } .custom { --slider-bar-color: #ffcf4c; - --slider-bar-background: #ffcf4c64; + --slider-bar-background: #ffcf4c; + --slider-bar-background-opacity: 0.2; --slider-bar-thickness: 100px; --slider-bar-border-radius: 24px; } diff --git a/gallery/src/pages/components/ha-bar-switch.ts b/gallery/src/pages/components/ha-bar-switch.ts index a9de6f0905..aeca191bff 100644 --- a/gallery/src/pages/components/ha-bar-switch.ts +++ b/gallery/src/pages/components/ha-bar-switch.ts @@ -115,8 +115,8 @@ export class DemoHaBarSwitch extends LitElement { font-weight: 600; } .custom { - --switch-bar-color-on: var(--rgb-green-color); - --switch-bar-color-off: var(--rgb-red-color); + --switch-bar-on-color: rgb(var(--rgb-green-color)); + --switch-bar-off-color: rgb(var(--rgb-red-color)); --switch-bar-thickness: 100px; --switch-bar-border-radius: 24px; --switch-bar-padding: 6px; diff --git a/src/common/color/compute-color.ts b/src/common/color/compute-color.ts index e7e3409a9d..9408b1e7ac 100644 --- a/src/common/color/compute-color.ts +++ b/src/common/color/compute-color.ts @@ -1,5 +1,3 @@ -import { hex2rgb } from "./convert-color"; - export const THEME_COLORS = new Set([ "primary", "accent", @@ -27,16 +25,9 @@ export const THEME_COLORS = new Set([ "white", ]); -export function computeRgbColor(color: string): string { +export function computeCssColor(color: string): string { if (THEME_COLORS.has(color)) { - return `var(--rgb-${color}-color)`; - } - if (color.startsWith("#")) { - try { - return hex2rgb(color).join(", "); - } catch (err) { - return ""; - } + return `rgb(var(--rgb-${color}-color))`; } return color; } diff --git a/src/components/ha-bar-slider.ts b/src/components/ha-bar-slider.ts index a50fd154ad..11b8558cda 100644 --- a/src/components/ha-bar-slider.ts +++ b/src/components/ha-bar-slider.ts @@ -272,7 +272,8 @@ export class HaBarSlider extends LitElement { :host { display: block; --slider-bar-color: rgb(var(--rgb-primary-color)); - --slider-bar-background: rgba(var(--rgb-disabled-color), 0.2); + --slider-bar-background: rgb(var(--rgb-disabled-color)); + --slider-bar-background-opacity: 0.2; --slider-bar-thickness: 40px; --slider-bar-border-radius: 10px; height: var(--slider-bar-thickness); @@ -301,6 +302,7 @@ export class HaBarSlider extends LitElement { height: 100%; width: 100%; background: var(--slider-bar-background); + opacity: var(--slider-bar-background-opacity); } .slider .slider-track-bar { --border-radius: var(--slider-bar-border-radius); diff --git a/src/components/ha-bar-switch.ts b/src/components/ha-bar-switch.ts index 13b22a286b..7c0f687e59 100644 --- a/src/components/ha-bar-switch.ts +++ b/src/components/ha-bar-switch.ts @@ -74,6 +74,7 @@ export class HaBarSwitch extends LitElement { protected render(): TemplateResult { return html`
+