Chart: sorted color picker (#30073)
Some checks failed
Some checks failed
This commit is contained in:
parent
eb5fd6d50c
commit
c37ecd66ac
3 changed files with 44 additions and 32 deletions
|
|
@ -38,25 +38,27 @@ const colors: {
|
||||||
light: null,
|
light: null,
|
||||||
selfPalette: ["#0FDE41", "#FFBD2F", "#FD6158", "#03C1EF", "#0F662D", "#FF922E"],
|
selfPalette: ["#0FDE41", "#FFBD2F", "#FD6158", "#03C1EF", "#0F662D", "#FF922E"],
|
||||||
palette: [
|
palette: [
|
||||||
// Dynamic palette (vehicles, loadpoints, …): optimized for neighbor contrast, avoids overlap with system colors (solar, battery, grid, …).
|
// light
|
||||||
"#0EA5E9", // Sky
|
"#60A5FA", // blue
|
||||||
"#EC4899", // Pink
|
"#FBBF24", // amber
|
||||||
"#34D399", // Mint
|
"#22D3EE", // cyan
|
||||||
"#F97316", // Orange
|
"#F472B6", // pink
|
||||||
"#7C3AED", // Violet
|
"#34D399", // green
|
||||||
"#84CC16", // Lime
|
"#A78BFA", // violet
|
||||||
"#F43F5E", // Rose
|
// mid
|
||||||
"#2563EB", // Blue
|
"#2563EB", // blue
|
||||||
"#FACC15", // Yellow
|
"#F59E0B", // amber
|
||||||
"#D946EF", // Magenta
|
"#06B6D4", // cyan
|
||||||
"#10B981", // Emerald
|
"#EC4899", // pink
|
||||||
"#1E40AF", // Royal
|
"#10B981", // green
|
||||||
"#BE185D", // Crimson
|
"#8B5CF6", // violet
|
||||||
"#F59E0B", // Marigold
|
// dark
|
||||||
"#6366F1", // Indigo
|
"#1E40AF", // blue
|
||||||
"#14B8A6", // Teal
|
"#B45309", // amber
|
||||||
"#A855F7", // Lavender
|
"#0E7490", // cyan
|
||||||
"#DC2626", // Red
|
"#BE185D", // pink
|
||||||
|
"#047857", // green
|
||||||
|
"#6D28D9", // violet
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,13 +99,23 @@ export default defineComponent({
|
||||||
emits: ["update:modelValue", "update:color"],
|
emits: ["update:modelValue", "update:color"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
palette: colors.palette,
|
|
||||||
popper: null as PopperInstance | null,
|
popper: null as PopperInstance | null,
|
||||||
hexInputValue: "",
|
hexInputValue: "",
|
||||||
hexFocused: false,
|
hexFocused: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
palette(): string[] {
|
||||||
|
// de-interleave warm/cool palette into 3×6 grid (rows: light/mid/dark, cols: hue)
|
||||||
|
const grid: string[][] = Array.from({ length: 3 }, () => Array(6).fill(""));
|
||||||
|
colors.palette.forEach((hex, i) => {
|
||||||
|
const row = Math.floor(i / 6);
|
||||||
|
const step = i % 6;
|
||||||
|
const col = Math.floor(step / 2) + (step % 2) * 3;
|
||||||
|
grid[row][col] = hex;
|
||||||
|
});
|
||||||
|
return grid.flat();
|
||||||
|
},
|
||||||
customHex(): string {
|
customHex(): string {
|
||||||
return normalizeHex(this.color);
|
return normalizeHex(this.color);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import { start, stop, baseUrl } from "./evcc";
|
||||||
test.use({ baseURL: baseUrl() });
|
test.use({ baseURL: baseUrl() });
|
||||||
|
|
||||||
// from assets/js/colors.ts palette
|
// from assets/js/colors.ts palette
|
||||||
const SKY = "rgb(14, 165, 233)"; // #0EA5E9 — palette[0]
|
const BLUE = "rgb(96, 165, 250)"; // #60A5FA — palette[0]
|
||||||
const PINK = "rgb(236, 72, 153)"; // #EC4899 — palette[1]
|
const AMBER = "rgb(251, 191, 36)"; // #FBBF24 — palette[1]
|
||||||
const CUSTOM_HEX = "FF0080";
|
const CUSTOM_HEX = "FF0080";
|
||||||
const CUSTOM_RGB = "rgb(255, 0, 128)";
|
const CUSTOM_RGB = "rgb(255, 0, 128)";
|
||||||
|
|
||||||
|
|
@ -31,25 +31,25 @@ test("device colors: autoassign, override, persistence", async ({ page }) => {
|
||||||
await page.goto("/#/sessions?year=2026&month=5");
|
await page.goto("/#/sessions?year=2026&month=5");
|
||||||
await expect(page.getByRole("heading", { name: "Charging Sessions" })).toBeVisible();
|
await expect(page.getByRole("heading", { name: "Charging Sessions" })).toBeVisible();
|
||||||
await page.getByRole("button", { name: "Vehicle", exact: true }).click();
|
await page.getByRole("button", { name: "Vehicle", exact: true }).click();
|
||||||
await expectLegendColor(page, "Honda", SKY);
|
await expectLegendColor(page, "Honda", BLUE);
|
||||||
|
|
||||||
// ---------- Step 2 — Sessions, by-loadpoint + override ----------
|
// ---------- Step 2 — Sessions, by-loadpoint + override ----------
|
||||||
await page.getByRole("button", { name: "Charging point", exact: true }).click();
|
await page.getByRole("button", { name: "Charging point", exact: true }).click();
|
||||||
// initial autoassign — Garage (more energy) → palette[0], Carport → palette[1]
|
// initial autoassign — Garage (more energy) → palette[0], Carport → palette[1]
|
||||||
await expectLegendColor(page, "Garage", SKY);
|
await expectLegendColor(page, "Garage", BLUE);
|
||||||
await expectLegendColor(page, "Carport", PINK);
|
await expectLegendColor(page, "Carport", AMBER);
|
||||||
|
|
||||||
// open picker on Garage badge; second palette swatch = PINK
|
// open picker on Garage badge; second palette swatch = AMBER
|
||||||
await legendBadge(page, "Garage").click();
|
await legendBadge(page, "Garage").click();
|
||||||
const popover = page.getByRole("dialog");
|
const popover = page.getByRole("dialog");
|
||||||
await expect(popover).toBeVisible();
|
await expect(popover).toBeVisible();
|
||||||
// palette swatches have title=hex
|
// palette swatches have title=hex
|
||||||
await popover.getByTitle("#EC4899").click();
|
await popover.getByTitle("#FBBF24").click();
|
||||||
await page.keyboard.press("Escape");
|
await page.keyboard.press("Escape");
|
||||||
|
|
||||||
await expectLegendColor(page, "Garage", PINK);
|
await expectLegendColor(page, "Garage", AMBER);
|
||||||
// non-collision: Carport must shift off PINK to the first free entry (SKY)
|
// non-collision: Carport must shift off AMBER to the first free entry (BLUE)
|
||||||
await expectLegendColor(page, "Carport", SKY);
|
await expectLegendColor(page, "Carport", BLUE);
|
||||||
|
|
||||||
// ---------- Step 3 — History view, same colors ----------
|
// ---------- Step 3 — History view, same colors ----------
|
||||||
await page.goto("/#/history?period=day&year=2026&month=5&day=15");
|
await page.goto("/#/history?period=day&year=2026&month=5&day=15");
|
||||||
|
|
@ -57,8 +57,8 @@ test("device colors: autoassign, override, persistence", async ({ page }) => {
|
||||||
.locator("section")
|
.locator("section")
|
||||||
.filter({ has: page.getByRole("heading", { name: "Charging & Heating" }) });
|
.filter({ has: page.getByRole("heading", { name: "Charging & Heating" }) });
|
||||||
await expect(lpSection).toBeVisible({ timeout: 10000 });
|
await expect(lpSection).toBeVisible({ timeout: 10000 });
|
||||||
await expectLegendColor(lpSection, "Garage", PINK);
|
await expectLegendColor(lpSection, "Garage", AMBER);
|
||||||
await expectLegendColor(lpSection, "Carport", SKY);
|
await expectLegendColor(lpSection, "Carport", BLUE);
|
||||||
|
|
||||||
// ---------- Step 4 — Custom hex on ext meter, reload ----------
|
// ---------- Step 4 — Custom hex on ext meter, reload ----------
|
||||||
const meterSection = page
|
const meterSection = page
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue