mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Use supported_color_modes to determine what UI elements to show (#8961)
This commit is contained in:
@@ -15,6 +15,7 @@ import { computeActiveState } from "../../common/entity/compute_active_state";
|
||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||
import { stateIcon } from "../../common/entity/state_icon";
|
||||
import { iconColorCSS } from "../../common/style/icon_color_css";
|
||||
import { getLightRgbColor, LightEntity } from "../../data/light";
|
||||
import type { HomeAssistant } from "../../types";
|
||||
import "../ha-icon";
|
||||
|
||||
@@ -99,11 +100,13 @@ export class StateBadge extends LitElement {
|
||||
hostStyle.backgroundImage = `url(${imageUrl})`;
|
||||
this._showIcon = false;
|
||||
} else if (stateObj.state === "on") {
|
||||
if (stateObj.attributes.hs_color && this.stateColor !== false) {
|
||||
const hue = stateObj.attributes.hs_color[0];
|
||||
const sat = stateObj.attributes.hs_color[1];
|
||||
if (sat > 10) {
|
||||
iconStyle.color = `hsl(${hue}, 100%, ${100 - sat / 2}%)`;
|
||||
if (
|
||||
computeStateDomain(stateObj) === "light" &&
|
||||
this.stateColor !== false
|
||||
) {
|
||||
const rgb = getLightRgbColor(stateObj as LightEntity);
|
||||
if (rgb) {
|
||||
iconStyle.color = `rgb(${rgb.slice(0, 3).join(",")})`;
|
||||
}
|
||||
}
|
||||
if (stateObj.attributes.brightness && this.stateColor !== false) {
|
||||
|
||||
Reference in New Issue
Block a user