@designesy/score 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +27 -7
- package/package.json +1 -1
package/dist/engine.d.ts
CHANGED
|
@@ -159,7 +159,7 @@ export declare function scoreFromParts(input: ScorePartsInput): Promise<ScoreRes
|
|
|
159
159
|
* the site served v0.4.3; test/engine-1-2-0.test.mjs now reads the site's
|
|
160
160
|
* contract source and fails when the two differ.
|
|
161
161
|
*/
|
|
162
|
-
export declare const CONTRACT_VERSION = "v0.4.
|
|
162
|
+
export declare const CONTRACT_VERSION = "v0.4.4";
|
|
163
163
|
/**
|
|
164
164
|
* The one verdict rule, shared by every emission format.
|
|
165
165
|
*
|
package/dist/engine.js
CHANGED
|
@@ -500,12 +500,32 @@ function checkPaperToken(tokens) {
|
|
|
500
500
|
return { id: 'v01', item: 'Token values match live site :root foundation', category: 'tokens', status: 'FAIL', detail: '--paper background token not declared in :root' };
|
|
501
501
|
}
|
|
502
502
|
function checkContrastSignal(tokens) {
|
|
503
|
-
// v22 — REAL WCAG 2.1 contrast between
|
|
504
|
-
//
|
|
505
|
-
//
|
|
506
|
-
// (
|
|
507
|
-
//
|
|
508
|
-
//
|
|
503
|
+
// v22 — REAL WCAG 2.1 contrast between the primary button's fill and its
|
|
504
|
+
// label. AA threshold: 4.5:1 for body text, 3:1 for large/UI — buttons are
|
|
505
|
+
// large text, but we hold the 4.5:1 bar because button labels are often
|
|
506
|
+
// small (12-14px).
|
|
507
|
+
//
|
|
508
|
+
// A contract that names its primary action pair (--action, the fill, and
|
|
509
|
+
// --on-action, the label) is measured on exactly that pair: it is what the
|
|
510
|
+
// button paints, so a better-contrast token elsewhere cannot stand in for a
|
|
511
|
+
// label that fails. Without both tokens the check reads the convention most
|
|
512
|
+
// contracts use: --paper or --ink text on --signal, the better ratio winning
|
|
513
|
+
// (designers choose the higher-contrast pairing).
|
|
514
|
+
const actionVal = tokens['--action'];
|
|
515
|
+
const onActionVal = tokens['--on-action'];
|
|
516
|
+
if (actionVal && onActionVal) {
|
|
517
|
+
const fillRgb = resolveColor(actionVal, tokens);
|
|
518
|
+
const labelRgb = resolveColor(onActionVal, tokens);
|
|
519
|
+
if (!fillRgb || !labelRgb)
|
|
520
|
+
return { id: 'v22', item: 'Primary button text passes WCAG AA contrast against --signal fill', category: 'accessibility', status: 'SKIP', detail: `--action ${actionVal} or --on-action ${onActionVal} unresolvable to RGB` };
|
|
521
|
+
const pairRatio = contrastRatio(labelRgb, fillRgb);
|
|
522
|
+
const pairStr = `${pairRatio.toFixed(2)}:1`;
|
|
523
|
+
if (pairRatio >= 4.5)
|
|
524
|
+
return { id: 'v22', item: 'Primary button text passes WCAG AA contrast against --signal fill', category: 'accessibility', status: 'PASS', detail: `--on-action on --action = ${pairStr} (≥ 4.5:1 AA)` };
|
|
525
|
+
if (pairRatio >= 3)
|
|
526
|
+
return { id: 'v22', item: 'Primary button text passes WCAG AA contrast against --signal fill', category: 'accessibility', status: 'WARN', detail: `--on-action on --action = ${pairStr} (passes 3:1 large-text, fails 4.5:1 body)` };
|
|
527
|
+
return { id: 'v22', item: 'Primary button text passes WCAG AA contrast against --signal fill', category: 'accessibility', status: 'FAIL', detail: `--on-action on --action = ${pairStr} (below 3:1, illegible)` };
|
|
528
|
+
}
|
|
509
529
|
const signalVal = tokens['--signal'];
|
|
510
530
|
if (!signalVal)
|
|
511
531
|
return { id: 'v22', item: 'Primary button text passes WCAG AA contrast against --signal fill', category: 'accessibility', status: 'WARN', detail: '--signal accent token not declared' };
|
|
@@ -4586,7 +4606,7 @@ export async function scoreFromParts(input) {
|
|
|
4586
4606
|
* the site served v0.4.3; test/engine-1-2-0.test.mjs now reads the site's
|
|
4587
4607
|
* contract source and fails when the two differ.
|
|
4588
4608
|
*/
|
|
4589
|
-
export const CONTRACT_VERSION = 'v0.4.
|
|
4609
|
+
export const CONTRACT_VERSION = 'v0.4.4';
|
|
4590
4610
|
/**
|
|
4591
4611
|
* The one verdict rule, shared by every emission format.
|
|
4592
4612
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designesy/score",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Standalone 44-check design-contract scoring engine: fetches a URL, extracts CSS + tokens, and runs all checks locally. No required dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Designesy <hello@designesy.org>",
|