Repository navigation
feat: add a colour palette generator and colour checks - #149
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users
Add the independent
@metronforge/concept-map/colorentry withpalette,checkColorsandColorError. Hosts can generate deterministic light and darkthemes, keep exact layer colours or accents, check an existing theme, and emit
CSS rules with
toCss.Each theme has neutral background, node, text and border roles, categorical
layer colours, and one accent reserved for the current step. Text needs WCAG
contrast of 4.5:1 and meaningful lines need 3:1. Layer pairs and layer–accent
pairs are checked in OKLab under normal vision and three Machado simulations.
Distances below 0.04 are hard defects; below 0.06 are advice. Ghost text and
lines keep floors of 2:1 and 1.3:1 and the ghost < normal ≤ current contrast
order. WCAG contrast is the only contrast measure. Strict checking throws on hard defects;
invalid hex colours name the affected path.
APCA code, its public metric and its tests were removed before publication
because its licence restrictions are incompatible with the MIT package.
The raw catalogue and research-only scripts were removed too. The full research
and its scripts remain on
archive/colour-catalogue-140at commit040827a.A findings summary retains the counts and default defect. Three scripts
reproduce that summary and the palette reports, using frozen book inputs
restored from the archive into an ignored cache. No script writes the raw
catalogue into the tracked evidence folder.
Why
Normal text contrast alone misses colours that become alike under a colour
vision deficiency. The frozen book inventory gives these findings:
These are repeated role-pair cases across maps, not independent colours or
readers. All ten examples and 18 of 23 book maps use at most four layers, so
four-layer separation matters most.
The generator scores all four vision models. The comparison enumerates every
subset of the book's nine existing layer ids for each count and selects the
subset with the greatest worst distance, keeping the book accent. Generated
palettes beat even this strongest reference at every count from two to six.
The fixed-accent variant keeps the book's exact accent on the generated bases.
Each number is the minimum across all layer pairs, layer–accent pairs and
all four vision models. All 20 generated comparison themes have no hard defects.
The reproducible report includes each model separately and the selected book
subset, rather than assuming that normal vision predicts the simulations.
The light search includes L=0.30 because the original grid missed its four-layer
target. Out-of-gamut generated accents reduce chroma; layer candidates outside
sRGB are rejected. No checker thresholds change. Default four-, six- and
eight-layer results exceed all six prototype targets.
Evidence
npm run verify: passes completely, including formatting, lint, types,dependency rules, build, schema, 172 test files / 1,478 tests, API reports,
contract guards, size limits, package checks and demo build. The previous
sandbox subprocess failures are absent; architecture tests pass unchanged.
npx vitest run --exclude test/unit/architecture.test.ts: 171 files and1,470 tests pass as an additional check. Source and API reports have no APCA.
node scripts/colour-findings.mjs --check: 60 finding counts, 24 layerdistribution rows and the known default defect reproduce. An independent
comparison matches every count against the archived reports. A stale-count
probe fails as expected, and check mode preserves all three evidence files.
node scripts/colour-palette.mjs --check: 28 theme/fixed-layer cases andtwo fixed-accent fallbacks pass without hard defects.
node scripts/colour-palette-comparison.mjs --check: 10 best book subsetsand 20 generated themes; all generated worst distances beat the reference.
All 30 table rows are unchanged by the catalogue removal.
npm run size -- --json: colour entry 3,416 B gzip, limit 3,518 B(102 B margin, below 3%). APCA removal saved 143 B. Catalogue removal changes
none of the 12 entry sizes. Element/player/server/root remain
32,976 / 16,959 / 4,385 / 16,915 B.
scripts from 13 to three. The 271-line findings script keeps its report
template and reproduction instructions beside the calculations.
The initial concurrent run passed 174/176; two module fetches failed while
verification replaced the demo output. Running after the build resolves both.
No browser tests or checks changed. Fresh logs:
/tmp/colour-140-iteration-1-verify.logand/tmp/colour-140-iteration-1-chromium-final.log.Not done
The raw catalogue is excluded from this branch and remains preserved on
archive/colour-catalogue-140at040827a; that branch was not touched.All local acceptance checks pass, including the full Chromium suite and the
unchanged architecture tests.
Lane labels still use the current drawing. Moving them to neutral text with a
layer swatch is a separate visible change: generated layer colours promise
line contrast, not lane-label text contrast. The current fallback/accent pair's
hard tritanopia defect (0.036455690) remains recorded and pinned by a test;
replacing defaults is separate. One-layer generation with an exact accent
already supplies candidates for that work.
Fixed host colours are preserved, so arbitrary supplied colours can still
fail checks. Combined painted states and route-dependent token contrast remain
outside the completed catalogue scope. The colour entry checks supplied roles;
it does not inspect the CSS cascade or SVG. Firefox and WebKit were not run
locally because no browser-specific behaviour changes; CI remains the check
across all three browsers before merge.
Changelog
BEGIN_COMMIT_OVERRIDE
feat: add a colour palette generator and colour checks
END_COMMIT_OVERRIDE