Make sure idle and random color dont collide (#9808)

This commit is contained in:
Bram Kragten 2021-08-16 05:45:07 +02:00 committed by GitHub
parent 7a35f46370
commit e0d23ee6cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 69 deletions

View File

@ -1,5 +1,5 @@
export const COLORS = [
"#377eb8",
"#44739e",
"#984ea3",
"#00d2d5",
"#ff7f00",

View File

@ -157,66 +157,3 @@ export const UNIT_F = "°F";
/** Entity ID of the default view. */
export const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
/** HA Color Pallete. */
export const HA_COLOR_PALETTE = [
"ff0029",
"66a61e",
"377eb8",
"984ea3",
"00d2d5",
"ff7f00",
"af8d00",
"7f80cd",
"b3e900",
"c42e60",
"a65628",
"f781bf",
"8dd3c7",
"bebada",
"fb8072",
"80b1d3",
"fdb462",
"fccde5",
"bc80bd",
"ffed6f",
"c4eaff",
"cf8c00",
"1b9e77",
"d95f02",
"e7298a",
"e6ab02",
"a6761d",
"0097ff",
"00d067",
"f43600",
"4ba93b",
"5779bb",
"927acc",
"97ee3f",
"bf3947",
"9f5b00",
"f48758",
"8caed6",
"f2b94f",
"eff26e",
"e43872",
"d9b100",
"9d7a00",
"698cff",
"d9d9d9",
"00d27e",
"d06800",
"009f82",
"c49200",
"cbe8ff",
"fecddf",
"c27eb6",
"8cd2ce",
"c4b8d9",
"f883b0",
"a49100",
"f48800",
"27d0df",
"a04a9b",
];

View File

@ -1,4 +1,4 @@
import { HA_COLOR_PALETTE } from "../common/const";
import { getColorByIndex } from "../common/color/colors";
import { computeDomain } from "../common/entity/compute_domain";
import { computeStateName } from "../common/entity/compute_state_name";
import type { CalendarEvent, HomeAssistant } from "../types";
@ -81,5 +81,5 @@ export const getCalendars = (hass: HomeAssistant): Calendar[] =>
.map((eid, idx) => ({
entity_id: eid,
name: computeStateName(hass.states[eid]),
backgroundColor: `#${HA_COLOR_PALETTE[idx % HA_COLOR_PALETTE.length]}`,
backgroundColor: getColorByIndex(idx),
}));

View File

@ -7,7 +7,7 @@ import {
TemplateResult,
} from "lit";
import { customElement, property, state, query } from "lit/decorators";
import { HA_COLOR_PALETTE } from "../../../common/const";
import { getColorByIndex } from "../../../common/color/colors";
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
import { HASSDomEvent } from "../../../common/dom/fire_event";
import { debounce } from "../../../common/util/debounce";
@ -86,7 +86,7 @@ export class HuiCalendarCard extends LitElement implements LovelaceCard {
this._calendars = config!.entities.map((entity, idx) => ({
entity_id: entity,
backgroundColor: `#${HA_COLOR_PALETTE[idx % HA_COLOR_PALETTE.length]}`,
backgroundColor: getColorByIndex(idx),
}));
if (this._config?.entities !== config.entities) {

View File

@ -70,7 +70,7 @@ documentContainer.innerHTML = `<custom-style>
--state-not_home-color: #ff0029;
/* --state-unavailable-color: #a0a0a0; derived from disabled-text-color */
--state-unknown-color: #606060;
--state-idle-color: #377eb8;
--state-idle-color: #7990a3;
/* climate state colors */
--state-climate-auto-color: #008000;