mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
convert-color: color names should be case insensitive (#25140)
convert-color: colornames should be case insensitive
This commit is contained in:
parent
48c90267df
commit
4c6a5ed2e3
@ -144,7 +144,7 @@ export function theme2hex(themeColor: string): string {
|
||||
return themeColor;
|
||||
}
|
||||
|
||||
const rgbFromColorName = colors[themeColor];
|
||||
const rgbFromColorName = colors[themeColor.toLowerCase()];
|
||||
if (rgbFromColorName) {
|
||||
return rgb2hex(rgbFromColorName);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ describe("Color Conversion Tests", () => {
|
||||
|
||||
it("should convert theme color to hex (ignoring alpha)", () => {
|
||||
expect(theme2hex("red")).toBe("#ff0000");
|
||||
expect(theme2hex("ReD")).toBe("#ff0000");
|
||||
expect(theme2hex("#ff0000")).toBe("#ff0000");
|
||||
expect(theme2hex("unicorn")).toBe("unicorn");
|
||||
expect(theme2hex("#abc")).toBe("#aabbcc");
|
||||
|
Loading…
x
Reference in New Issue
Block a user