diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-16 06:11:15 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-16 06:11:15 -0500 |
| commit | 9e99749de911ffc5b375bc79ee664d498e4d76d6 (patch) | |
| tree | f76652c5d684536598f8d510baf52f304c70d818 /scripts/theme-studio/test-app-util.mjs | |
| parent | cf882dfe168463471598d01205256131bc4e7f1b (diff) | |
| download | dotemacs-9e99749de911ffc5b375bc79ee664d498e4d76d6.tar.gz dotemacs-9e99749de911ffc5b375bc79ee664d498e4d76d6.zip | |
feat(theme-studio): move the contrast verdict into a hover
The contrast column showed "5.4 PASS". The number's color already encodes the tier (green AAA, grey AA, red fail), so the PASS/FAIL word was redundant. I dropped it and put the WCAG meaning in the cell's hover via a pure contrastTitle helper. crHtml now renders just the colored number. verdictFor stays for the covered-overlay worst-case readout, which is unchanged.
Diffstat (limited to 'scripts/theme-studio/test-app-util.mjs')
| -rw-r--r-- | scripts/theme-studio/test-app-util.mjs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/theme-studio/test-app-util.mjs b/scripts/theme-studio/test-app-util.mjs index 2cb08e0e6..37cf0889b 100644 --- a/scripts/theme-studio/test-app-util.mjs +++ b/scripts/theme-studio/test-app-util.mjs @@ -5,10 +5,35 @@ import { test } from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; -import { normHex, ratingColor, textOn } from './app-util.js'; +import { normHex, ratingColor, textOn, contrastTitle } from './app-util.js'; const here = fileURLToPath(new URL('.', import.meta.url)); +// contrastTitle: the hover text for a contrast number, naming the color tier +// (green AAA / grey AA / red fail) so the verdict word can be dropped from the cell. +test('contrastTitle: green tier (>=7) names AAA', () => { + const t = contrastTitle(8.2); + assert.match(t, /green/i); + assert.match(t, /AAA/); + assert.match(t, /^8\.2:1/); +}); +test('contrastTitle: grey tier (4.5..7) passes AA, not AAA', () => { + const t = contrastTitle(5.4); + assert.match(t, /grey|gray/i); + assert.match(t, /AA/); + assert.match(t, /not AAA|below AAA/i); +}); +test('contrastTitle: red tier (<4.5) fails AA', () => { + const t = contrastTitle(3.1); + assert.match(t, /red/i); + assert.match(t, /fail/i); +}); +test('contrastTitle: boundaries — 7 is green, 4.5 is grey, just under is red', () => { + assert.match(contrastTitle(7), /green/i); + assert.match(contrastTitle(4.5), /grey|gray/i); + assert.match(contrastTitle(4.49), /red/i); +}); + test('normHex: Normal — adds the #, lowercases, accepts an existing #', () => { assert.equal(normHex('67809C'), '#67809c'); assert.equal(normHex('#E8BD30'), '#e8bd30'); |
