Files
app/frontend/src/components/Dashboard/palette.check.ts
T
stroblmeandClaude Opus 5.5 4f4de1fd9d Draw charts from one categorical palette, --chart-1…8
The one-hue ramp told lines apart by lightness alone. --chart-1 is now
--primary and slots 2-8 are distinct hues (orange, violet, green, orchid,
ochre, teal, magenta) that clear 3:1 on --card and stay apart under
protanopia and deuteranopia; red and sage are left out as the status
colours. A chart takes the slots in order instead of spreading a ramp,
and a dashboard's own palette continues after its primary and listed
colours with slots 2-8 rather than tints of its scheme. Line charts stay
at five series. Tokens mirror index's, as design-check requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
2026-10-06 07:05:09 +02:00

61 lines
2.0 KiB
TypeScript

/**
* The dashboard palette, checked.
*
* ponytail: a script rather than a suite, like `color.check.ts` beside it —
* the frontend's only runner is Playwright and picking a palette slot does not
* need a browser:
*
* cd frontend && bun run src/components/Dashboard/palette.check.ts
*
* Two properties, and it is worth being clear which is which.
*
* The one that must never move is **inertness**: a palette a dashboard wrote
* down is drawn exactly as written, so shipping this mechanism could not
* change the meaning of a single stored document. That is what made the
* default safe to move afterwards.
*
* The one that is free to move is the **default** itself — where a chart that
* named no palette lands. It started as a one-hue ramp in order, was spread
* across that ramp, and is now the categorical `--chart-1…8` in order. That is
* a design decision, pinned here so it changes on purpose rather than by
* accident.
*/
import assert from "node:assert/strict"
import {
CHART_SLOTS,
MAX_SERIES,
NO_PALETTE,
slotsFor,
} from "@/components/Common/UplotChart"
// --- the default: the shared palette, in order ----------------------------
assert.deepEqual(
CHART_SLOTS,
["1", "2", "3", "4", "5", "6", "7", "8"],
"eight slots, named as --chart-1…8 is",
)
for (const stored of [undefined, NO_PALETTE]) {
assert.deepEqual(
slotsFor(stored),
CHART_SLOTS,
"naming no palette, however it is stored, takes the slots in order",
)
}
assert.ok(
MAX_SERIES <= CHART_SLOTS.length,
"a full chart never repeats a colour",
)
// --- inertness: a named palette is drawn as written -----------------------
// A dashboard names colours now (`ui/core/theme.ts`), and a chart draws them
// as they were written: not re-spread, not widened, not reordered. A chart
// with more lines than it names cycles through them.
const NAMED = ["#2a9d8f", "#e9c46a"]
assert.deepEqual(slotsFor(NAMED), NAMED, "a named palette is drawn as written")
console.log("palette: ok")