@josueavalosjim/taste-check 0.5.1 → 0.5.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/README.md +9 -0
- package/package.json +1 -1
- package/src/runtime.mjs +16 -1
package/README.md
CHANGED
|
@@ -227,6 +227,15 @@ page's own scripts, which is where a theme belongs because the page reads it at
|
|
|
227
227
|
boot. `after` runs once there is a document, for opening a panel or focusing a
|
|
228
228
|
field. Each state's setup is removed before the next one, so they cannot leak.
|
|
229
229
|
|
|
230
|
+
**A foreground composites over its own background. An edge measures against
|
|
231
|
+
what is outside it.** Those are different questions. Text sits on the thing
|
|
232
|
+
behind it, so its own background belongs in the stack. A border is a boundary,
|
|
233
|
+
and 1.4.11 asks whether that boundary can be told apart from what is adjacent
|
|
234
|
+
to it, which is the page rather than the control's own fill. A solid button
|
|
235
|
+
that sets its border to its own background colour measures 1.00:1 the first
|
|
236
|
+
way and 14.68:1 the second, and only one of those is the edge anybody sees.
|
|
237
|
+
Border properties are handled this way for you.
|
|
238
|
+
|
|
230
239
|
Use `againstParent` when the thing being measured is a fill rather than a
|
|
231
240
|
foreground. A selected row with its own background measured against itself
|
|
232
241
|
scores 1.00, which is a pass that means nothing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josueavalosjim/taste-check",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Design review in CI with a line down the middle: measured checks that gate the build (WCAG contrast from your tokens or from a real rendered page, one-off values in your markup) and a fresh-eyes model judge whose verdicts stay advisory. Zero dependencies. Ships no design rules of its own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
package/src/runtime.mjs
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
* 2. It can measure a state, because it can put the page into one first.
|
|
18
18
|
* A theme, an opened panel, a focused input.
|
|
19
19
|
*
|
|
20
|
+
* A foreground composites over its own background. An edge measures against
|
|
21
|
+
* what is outside it. Those are different questions and getting them the same
|
|
22
|
+
* way round produces confident nonsense in both directions.
|
|
23
|
+
*
|
|
20
24
|
* A selector that matches nothing is a failure, not a skipped target. So is a
|
|
21
25
|
* border with no width: you asked for the contrast of an edge that is not
|
|
22
26
|
* being drawn, and the honest answer is that the question is wrong.
|
|
@@ -42,7 +46,18 @@ const MEASURE = `(targets) => targets.map(({ selector, prop, againstParent }) =>
|
|
|
42
46
|
if (!width) return { error: 'has a ' + prop + ' but no width, so no edge is drawn' };
|
|
43
47
|
}
|
|
44
48
|
const layers = [];
|
|
45
|
-
|
|
49
|
+
// Two reasons to start one level up.
|
|
50
|
+
//
|
|
51
|
+
// A fill measured against itself scores 1.00, so againstParent hands us the
|
|
52
|
+
// parent instead.
|
|
53
|
+
//
|
|
54
|
+
// A border is the same, for a different reason. 1.4.11 asks whether the
|
|
55
|
+
// boundary of a control can be told apart from what is adjacent to it, and
|
|
56
|
+
// what is adjacent is the page, not the control's own fill. A solid button
|
|
57
|
+
// that sets its border to its own background colour measures 1.00:1 against
|
|
58
|
+
// that background: true, and an answer to a question nobody asked.
|
|
59
|
+
const outside = againstParent || prop.indexOf('border') === 0;
|
|
60
|
+
let node = outside ? el.parentElement : el;
|
|
46
61
|
if (!node) return { error: 'has no parent to measure against' };
|
|
47
62
|
while (node) {
|
|
48
63
|
const bg = getComputedStyle(node).backgroundColor;
|