mirror of
https://github.com/lukaszraczylo/beat-delivery-methodology.git
synced 2026-11-26 11:08:13 +00:00
feat(scripts): add theme contrast measurement harness and measured table
Add scripts/check-contrast.mjs, a plain Node script with no runtime
dependency and no test framework, that measures the WCAG 2.2 contrast
ratio of every theme token pair in the light and the dark theme.
- Read the light values from the :root block and the dark values from
the .dark block of public/src/main.css, the only stylesheet in the
build that declares the token values.
- Read the measured pairs from scripts/contrast-pairs.json, so the list
is reviewable next to the script. Every pair states its own threshold
and the harness rejects a threshold that disagrees with its category.
- Apply 4.5:1 for body text, 3:1 for large text and 3:1 for UI
component boundaries, and exit non-zero naming every pair below its
threshold with its token names, values, measured ratio and threshold.
- Report a token that is missing from a theme as a failure, not a skip.
Commit the measured table to docs/theme-contrast.md: 16 pairs, 32
measurements, 32 pass, 0 fail at commit 552d847.
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
{
|
||||
"comment": [
|
||||
"The foreground/background pairs of the theme token contract that the",
|
||||
"contrast harness measures. Every pair names the CSS custom properties",
|
||||
"it reads, so a reviewer can check the list against the token file",
|
||||
"without running anything.",
|
||||
"",
|
||||
"The category fixes the WCAG 2.2 threshold the harness applies:",
|
||||
" body-text 4.5:1 (WCAG 1.4.3, normal-size text)",
|
||||
" large-text 3:1 (WCAG 1.4.3, large-scale text)",
|
||||
" ui-component 3:1 (WCAG 1.4.11, component boundaries)",
|
||||
"",
|
||||
"Every pair also states its own threshold, so the list carries the",
|
||||
"requirement in full and can be reviewed without the harness. The",
|
||||
"harness rejects a pair whose threshold disagrees with its category.",
|
||||
"",
|
||||
"A pair is checked in both themes: the light values come from the :root",
|
||||
"block and the dark values from the .dark block of the token file."
|
||||
],
|
||||
"pairs": [
|
||||
{
|
||||
"id": "body-text-on-background",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-text-body",
|
||||
"background": "--color-background",
|
||||
"surface": "Body copy on the page background"
|
||||
},
|
||||
{
|
||||
"id": "body-text-on-muted",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-text-body",
|
||||
"background": "--color-muted",
|
||||
"surface": "Body copy on a muted surface (card, code block, inset panel)"
|
||||
},
|
||||
{
|
||||
"id": "foreground-on-background",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-foreground",
|
||||
"background": "--color-background",
|
||||
"surface": "Primary text and headings on the page background"
|
||||
},
|
||||
{
|
||||
"id": "foreground-on-muted",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-foreground",
|
||||
"background": "--color-muted",
|
||||
"surface": "Primary text and headings on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "muted-foreground-on-background",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-muted-foreground",
|
||||
"background": "--color-background",
|
||||
"surface": "Secondary text (captions, metadata, helper text) on the page background"
|
||||
},
|
||||
{
|
||||
"id": "muted-foreground-on-muted",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-muted-foreground",
|
||||
"background": "--color-muted",
|
||||
"surface": "Secondary text on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "accent-text-on-background",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-accent",
|
||||
"background": "--color-background",
|
||||
"surface": "Link and emphasis text on the page background"
|
||||
},
|
||||
{
|
||||
"id": "accent-text-on-muted",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-accent",
|
||||
"background": "--color-muted",
|
||||
"surface": "Link and emphasis text on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "accent-foreground-on-accent",
|
||||
"category": "body-text",
|
||||
"threshold": 4.5,
|
||||
"foreground": "--color-accent-foreground",
|
||||
"background": "--color-accent",
|
||||
"surface": "Label text on an accent-filled button or badge"
|
||||
},
|
||||
{
|
||||
"id": "large-text-on-background",
|
||||
"category": "large-text",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-text-large",
|
||||
"background": "--color-background",
|
||||
"surface": "Large headings on the page background"
|
||||
},
|
||||
{
|
||||
"id": "large-text-on-muted",
|
||||
"category": "large-text",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-text-large",
|
||||
"background": "--color-muted",
|
||||
"surface": "Large headings on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "border-on-background",
|
||||
"category": "ui-component",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-border",
|
||||
"background": "--color-background",
|
||||
"surface": "Control and card boundary on the page background"
|
||||
},
|
||||
{
|
||||
"id": "border-on-muted",
|
||||
"category": "ui-component",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-border",
|
||||
"background": "--color-muted",
|
||||
"surface": "Control and card boundary on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "accent-boundary-on-background",
|
||||
"category": "ui-component",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-accent",
|
||||
"background": "--color-background",
|
||||
"surface": "Accent control edge and focus indicator on the page background"
|
||||
},
|
||||
{
|
||||
"id": "accent-boundary-on-muted",
|
||||
"category": "ui-component",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-accent",
|
||||
"background": "--color-muted",
|
||||
"surface": "Accent control edge on a muted surface"
|
||||
},
|
||||
{
|
||||
"id": "foreground-boundary-on-background",
|
||||
"category": "ui-component",
|
||||
"threshold": 3,
|
||||
"foreground": "--color-foreground",
|
||||
"background": "--color-background",
|
||||
"surface": "Strong control edge (input outline, toggle track) on the page background"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user