@reqvire-org/ads 0.3.48 → 0.3.50

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.
Files changed (94) hide show
  1. package/README.md +36 -6
  2. package/dist/active-clock.mjs +34 -0
  3. package/dist/assets.mjs +20 -2
  4. package/dist/boundaries.mjs +2 -0
  5. package/dist/browser-audit/layout-overflow.mjs +57 -0
  6. package/dist/browser-audit/layout-shift.mjs +32 -0
  7. package/dist/browser-audit/non-text-contrast.mjs +87 -0
  8. package/dist/browser-audit/worker.mjs +36 -7
  9. package/dist/browser-audit.mjs +198 -22
  10. package/dist/check.mjs +14 -1
  11. package/dist/cli.mjs +7 -4
  12. package/dist/component-contrast.mjs +138 -0
  13. package/dist/config.mjs +12 -6
  14. package/dist/finding-rules.mjs +13 -1
  15. package/dist/fonts-generated.mjs +85 -0
  16. package/dist/image-attributes.mjs +110 -0
  17. package/dist/init.mjs +2 -0
  18. package/dist/layout-widths.mjs +184 -0
  19. package/dist/mcp/context.mjs +1 -1
  20. package/dist/mcp/mutations.mjs +7 -5
  21. package/dist/mcp/preview-watch.mjs +9 -8
  22. package/dist/mcp/server.mjs +6 -4
  23. package/dist/palette-generated.mjs +6 -3
  24. package/dist/preview-files.mjs +3 -0
  25. package/dist/project-boundary.mjs +23 -0
  26. package/dist/project-documents.mjs +2 -1
  27. package/dist/scenarios-compiler.mjs +23 -3
  28. package/dist/showcase/client.bundle.js +11 -11
  29. package/dist/showcase/icons.js +5 -5
  30. package/dist/showcase/style.css +1 -1
  31. package/dist/skills/ads-break-ui/SKILL.md +8 -0
  32. package/dist/skills/ads-break-ui/references/atomic-styles.md +2 -0
  33. package/dist/skills/ads-break-ui/references/design-data.md +47 -1
  34. package/dist/skills/ads-break-ui/references/drafts.md +1 -1
  35. package/dist/skills/ads-break-ui/references/guarded-editing.md +1 -1
  36. package/dist/skills/ads-break-ui/references/validation.md +9 -5
  37. package/dist/skills/ads-designer/SKILL.md +24 -4
  38. package/dist/skills/ads-designer/references/accessibility.md +31 -14
  39. package/dist/skills/ads-designer/references/atomic-styles.md +2 -0
  40. package/dist/skills/ads-designer/references/branding.md +10 -5
  41. package/dist/skills/ads-designer/references/cli.md +2 -1
  42. package/dist/skills/ads-designer/references/design-data.md +47 -1
  43. package/dist/skills/ads-designer/references/drafts.md +1 -1
  44. package/dist/skills/ads-designer/references/guarded-editing.md +1 -1
  45. package/dist/skills/ads-designer/references/mobile.md +3 -0
  46. package/dist/skills/ads-designer/references/performance.md +89 -0
  47. package/dist/skills/ads-designer/references/validation.md +9 -5
  48. package/dist/skills/ads-import/references/atomic-styles.md +2 -0
  49. package/dist/skills/ads-import/references/cli.md +2 -1
  50. package/dist/skills/ads-import/references/design-data.md +47 -1
  51. package/dist/skills/ads-import/references/drafts.md +1 -1
  52. package/dist/skills/ads-import/references/guarded-editing.md +1 -1
  53. package/dist/skills/ads-import/references/validation.md +9 -5
  54. package/dist/skills/ads-motion/references/atomic-styles.md +2 -0
  55. package/dist/skills/ads-motion/references/design-data.md +47 -1
  56. package/dist/skills/ads-motion/references/drafts.md +1 -1
  57. package/dist/skills/ads-motion/references/guarded-editing.md +1 -1
  58. package/dist/skills/ads-motion/references/validation.md +9 -5
  59. package/dist/skills/ads-port/references/atomic-styles.md +2 -0
  60. package/dist/skills/ads-port/references/cli.md +2 -1
  61. package/dist/skills/ads-port/references/design-data.md +47 -1
  62. package/dist/skills/ads-port/references/drafts.md +1 -1
  63. package/dist/skills/ads-port/references/guarded-editing.md +1 -1
  64. package/dist/skills/ads-port/references/validation.md +9 -5
  65. package/dist/starters/preact/ds.config.json +1 -0
  66. package/dist/starters/preact/package.json +1 -0
  67. package/dist/starters/react/ADS.md +1 -1
  68. package/dist/starters/react/README.md +14 -2
  69. package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +1 -1
  70. package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +2 -0
  71. package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +13 -0
  72. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +48 -0
  73. package/dist/starters/react/design-system/components/Content/Image/README.md +20 -0
  74. package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
  75. package/dist/starters/react/design-system/index.ts +1 -0
  76. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +16 -0
  77. package/dist/starters/react/design-system/tokens/spacing.css +18 -0
  78. package/dist/starters/react/ds.config.json +1 -0
  79. package/dist/starters/react/package-lock.json +47 -0
  80. package/dist/starters/react/package.json +2 -1
  81. package/dist/test-boundaries.mjs +30 -1
  82. package/dist/themes-generated.mjs +15 -4
  83. package/dist/token-quality.mjs +61 -24
  84. package/dist/units.mjs +2 -1
  85. package/dist/validation-checks.mjs +5 -4
  86. package/dist/validation.mjs +1 -1
  87. package/dist/verification/browser.mjs +28 -2
  88. package/dist/verification.mjs +5 -4
  89. package/docs/ADS.md +4 -1
  90. package/docs/ARCHITECTURE.md +13 -3
  91. package/docs/CHANGELOG.md +111 -12
  92. package/docs/GUIDE.md +208 -14
  93. package/docs/MCP.md +14 -10
  94. package/package.json +1 -1
@@ -86,10 +86,10 @@ function logo(file) {
86
86
  const figure = element("figure", { className: "icons-logo" });
87
87
  figure.dataset.logo = file.name;
88
88
  if (file.tooLarge) { figure.append(element("figcaption", { textContent: `${file.name} (over 1 MB; not shown)` })); return figure; }
89
- const muted = element("span", { className: "icons-logo-muted", title: `${file.name}, muted` });
90
- muted.setAttribute("aria-hidden", "true");
91
- muted.style.maskImage = muted.style.webkitMaskImage = `url("${file.src}")`;
92
- figure.append(element("img", { src: file.src, alt: file.name, title: file.file }), muted, element("figcaption", { textContent: file.name }));
89
+ // The file exactly as it is, on a white and a black tile, so black and white artwork both show.
90
+ figure.append(element("span", { className: "icons-logo-tile" }, element("img", { src: file.src, alt: file.name, title: file.file })),
91
+ element("span", { className: "icons-logo-tile icons-logo-tile-black" }, element("img", { src: file.src, alt: "" })),
92
+ element("figcaption", { textContent: file.name }));
93
93
  return figure;
94
94
  }
95
95
 
@@ -128,7 +128,7 @@ export function renderIcons(slot, data) {
128
128
  cards.append(card(item, data.sizes));
129
129
  }
130
130
  if (data.logos) {
131
- view.append(element("h2", {}, "Other products' logos ", element("small", { textContent: `${data.logos.source} · in color and muted` })),
131
+ view.append(element("h2", {}, "Other products' logos ", element("small", { textContent: data.logos.source })),
132
132
  data.logos.files.length ? element("div", { className: "icons-logos" }, ...data.logos.files.map(logo)) : element("p", { className: "icons-summary", textContent: "No images yet." }));
133
133
  }
134
134
  const filter = () => {
@@ -44,4 +44,4 @@ body[data-active-section="icons"] #sidebar{display:none}
44
44
  .icons-grid line{stroke:var(--icons-grid);stroke-width:.5px;vector-effect:non-scaling-stroke}.icons-grid line.mid{stroke:var(--icons-grid-mid);stroke-width:1px}
45
45
  .icons-sizes{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-end;justify-content:center}.icons-size{display:flex;flex-direction:column;align-items:center;gap:2px}.icons-size small{font-size:10px;color:var(--icons-muted)}
46
46
  .icons-finding{margin:10px 0 0;font-size:12px;color:var(--icons-error);background:var(--icons-error-bg);border-radius:6px;padding:5px 8px;overflow-wrap:anywhere}.icons-empty{color:var(--icons-muted)}
47
- .icons-logos{display:flex;flex-wrap:wrap;gap:12px}.icons-logo{display:flex;align-items:center;gap:10px;margin:0;background:var(--icons-surface);border:1px solid var(--frame-line);border-radius:10px;padding:8px 12px}.icons-logo img,.icons-logo-muted{width:24px;height:24px;object-fit:contain}.icons-logo-muted{display:inline-block;background:var(--icons-muted);-webkit-mask:center/contain no-repeat;mask:center/contain no-repeat}.icons-logo figcaption{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}
47
+ .icons-logos{display:flex;flex-wrap:wrap;gap:12px}.icons-logo{display:flex;align-items:center;gap:10px;margin:0;background:var(--icons-surface);border:1px solid var(--frame-line);border-radius:10px;padding:8px 12px}.icons-logo-tile{display:inline-flex;background:#fff;border-radius:6px;padding:6px}.icons-logo-tile-black{background:#000}.icons-logo img{display:block;width:24px;height:24px;object-fit:contain}.icons-logo figcaption{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}
@@ -37,6 +37,14 @@ Exercise the real component through its public API. Accept an item name, screen,
37
37
  file, or local project path; discover the relevant exports and usage when the
38
38
  request already identifies the target.
39
39
 
40
+ ## Check overflow
41
+
42
+ Run `ads audit` on the stressed scenario. `layout-overflow` fails it when the page overflows
43
+ horizontally, an element reaches past the viewport or content is clipped at 390, 768 or 1280
44
+ px. `overflow-x: auto` scrollers and `text-overflow: ellipsis` are exempt. Fix a failure with
45
+ fluid widths (`%`, `fr`, a `--grid-span-N` token in a container query), `min-width: 0` on flex
46
+ and grid children, and wrapping, not with `overflow: hidden`.
47
+
40
48
  ## Discover the target
41
49
 
42
50
  When ADS MCP is connected, `ads_status`/`ads_catalog` identify public UI, guides and
@@ -30,6 +30,8 @@ horizontal writing mode. In the inspected Linaria implementation, `padding` and
30
30
  it can override the intended size. Shared atom reuse and CSS splitting can make
31
31
  this visible in a larger build even when an isolated view appears correct.
32
32
  The order of class names in HTML does not decide equal-specificity rule order.
33
+ Queries on one property therefore use exclusive ranges, such as
34
+ `(min-width: 768px) and (max-width: 1023.98px)` beside `(min-width: 1024px)`.
33
35
  Valid tokens, successful extraction and a passing source check do not establish
34
36
  the intended computed value.
35
37
 
@@ -92,7 +92,7 @@ keeps independent component token definitions valid.
92
92
 
93
93
  ## Accessibility and rhythm checks
94
94
 
95
- `ads check` checks token values in every theme and brand. Each finding below is an error:
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error unless marked info:
96
96
 
97
97
  - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
98
  `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
@@ -100,6 +100,13 @@ keeps independent component token definitions valid.
100
100
  status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
101
  `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
102
  step for the role, in the theme the message names, never with a one-off color.
103
+ Any CSS color is evaluated (hex, named, `rgb()`, `hsl()`, `hwb()`, `lab()`, `lch()`,
104
+ `oklab()`, `oklch()`, `color()`, `color-mix()`, `light-dark()`), through halves and
105
+ aliases. A translucent background counts as composited over `--bg-canvas`, a translucent
106
+ foreground as composited over its background.
107
+ - `token-contrast-unresolved` (info): a pair color ADS cannot resolve statically
108
+ (`currentColor`, relative color syntax, a system color), so that pair is not checked. Give
109
+ the role a color or a ramp step, or check the pages that use it with `ads audit`.
103
110
  - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
111
  - `control-padding`: pad a control with the token for its size. A block sized with
105
112
  `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
@@ -127,6 +134,45 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
127
134
  breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
128
135
  widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
129
136
 
137
+ ### Widths are fluid on the grid; never a fixed cap
138
+
139
+ `--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
140
+ Set one inside a container query, under a `Grid` or another `container-type: inline-size`
141
+ ancestor, and leave narrow containers at full width:
142
+
143
+ ```css
144
+ inline-size: 100%;
145
+ @container (min-width: 1024px) { max-inline-size: var(--grid-span-10); }
146
+ ```
147
+
148
+ Atomic CSS does not keep rule order, so two queries on one property need exclusive ranges:
149
+
150
+ ```css
151
+ @container (min-width: 768px) and (max-width: 1023.98px) { max-inline-size: var(--grid-span-12); }
152
+ @container (min-width: 1024px) { max-inline-size: var(--grid-span-10); }
153
+ ```
154
+
155
+ Use `%` or `fr` for a share of the parent and a `ch` measure for running text
156
+ (`max-inline-size: 65ch`).
157
+
158
+ `layout-fixed-width` is an error for `width`, `min-width`, `max-width`, the logical inline
159
+ sizes, `flex-basis`, `flex`'s basis and `grid-template-columns` tracks with a fixed length
160
+ above 48 px, the top of the control and icon range: `var(--space-32)`,
161
+ `calc(var(--space-32) * 10)`.
162
+
163
+ These pass: `flex: 1 1 <basis>`; `min()`, `max()`, `clamp()` and `calc()` with a fluid part; `minmax()` with a fluid
164
+ maximum; the part sizes `--icon-*`, `--control-*`, `--avatar-*`, `--border-*`, `--focus-*`,
165
+ `--ring-*`, `--radius-*`, `--side-pane-*`, `--toast-*`, `--navigation-rail-width`,
166
+ `--app-header-height`, `--row-height-compact`, `--compact-column-min`; and tokens named by
167
+ `layout.widthTokens` in `ds.config.json`, which must be defined with `%` or container units.
168
+ A fixed `--container-*` or `--content-max` token named there is a cap, valid only as a maximum.
169
+ `layout.fixedWidthUnits` lists owners that may use fixed widths, by unit id or file glob: list
170
+ overlays (dialogs, menus, popovers, tooltips) there. There is no per-declaration exception.
171
+
172
+ `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
173
+ horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
174
+ scrollers and `text-overflow: ellipsis` are exempt.
175
+
130
176
  ## Color roles and states
131
177
 
132
178
  Name roles by element and purpose, the same in every theme; only their values change. Point roles at ramp steps rather than raw colors, so a theme is a ramp swap:
@@ -152,7 +152,7 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
155
+ their normal paths. Unless `acceptance.browserAudit` is false it also runs the axe-core
156
156
  audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
157
  Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
158
158
  application. Successful acceptance removes the proposal and records an event.
@@ -23,7 +23,7 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
26
+ at acceptance. Unless `acceptance.browserAudit` is false, axe-core also audits the candidate's
27
27
  affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
28
  Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
29
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
@@ -41,12 +41,16 @@ implicitly requiring them at acceptance.
41
41
  all registered behavior checks. Use before a release, after ownership/test/config
42
42
  migrations and for an explicit complete audit. Changed scope narrows registered
43
43
  owners while project scripts and core gates retain full scope.
44
- - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
- UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy. With `acceptance.browserAudit`, draft
44
+ - Both policies run the axe-core audit of every rendered UI scenario in every brand
45
+ and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
46
+ that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
47
+ that cannot run (no project Playwright or browser) fails it with a `browser-audit`
48
+ error naming what to install. Under the acceptance policy, draft
47
49
  acceptance and guarded patches/transactions audit the candidate's affected UI
48
50
  scenarios (all after configuration, foundation, token or asset changes) and reject
49
- the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
51
+ the change on any of those errors or a `browser-audit` failure. A render that fails is
52
+ retried on its own, up to 3 attempts; retried passes are listed under `retries`, and a scenario
53
+ that still fails is a `browser-audit` error naming it and the last cause. Declare
50
54
  `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
55
  component change audits only the scenarios that import it. See
52
56
  ads://guides/accessibility.
@@ -58,7 +62,7 @@ implicitly requiring them at acceptance.
58
62
  disable tests or weaken configuration to make a failing change pass.
59
63
 
60
64
  Defaults: both script lists are empty, acceptance `behaviorChecks:false`,
61
- validation `behaviorChecks:true`, both `browserAudit:false`. No lint/test/build script names are inferred.
65
+ validation `behaviorChecks:true`, both `browserAudit:true`. No lint/test/build script names are inferred.
62
66
  Every listed script must exist; commands are trusted project configuration, not
63
67
  MCP arguments. `mcp.mutationChecks` is a configuration error: list those scripts in
64
68
  `acceptance.checks` and set `acceptance.behaviorChecks`. `mcp.mutationCheckTimeoutMs`
@@ -216,7 +216,7 @@ TypeScript/Linaria configuration, general lint, a public barrel, project-owned
216
216
  review renderers (token tiles, brand preview, demo and screen frames), placeholder
217
217
  brand artwork with an app icon, a `Grid` (`GridItem`) on the grid tokens, an icon set with
218
218
  `Icon` and `IconButton`, and one example of each layer: `Button`, `IconButton`, `Icon`,
219
- `Logo`, `TextField` and `Grid` in four component groups, the `SearchBar` pattern and the
219
+ `Logo`, `Image`, `TextField` and `Grid` in four component groups, the `SearchBar` pattern and the
220
220
  `SearchPage` composition. Treat them as the project's own: adapt or replace them
221
221
  for the requested product. The browser shell is supplied by ADS tooling.
222
222
 
@@ -320,17 +320,37 @@ section (`brand/<Group>/<Name>` scenarios). Finished PNG/JPEG/WebP images and
320
320
  delivered `.ico`/`.icns` files are artwork too; ADS never enlarges a finished
321
321
  image. Other products' logos are not brand artwork or glyphs: keep them, in their own
322
322
  colors and under their owners' trademark and usage terms, in `assets/logos/` and
323
- show them as images (a CSS mask over `currentColor` for a muted use); ADS generates
323
+ show them as images, never muted, tinted or recolored; ADS generates
324
324
  and checks nothing there.
325
325
  Read [branding.md](references/branding.md) (`ads://guides/branding`) before changing
326
326
  brand artwork, icon outputs or glyphs.
327
327
 
328
+ ## Layout widths
329
+
330
+ Widths are fluid on the grid; never a fixed cap. Span columns with a `--grid-span-N` token in
331
+ a container query, use `%` or `fr`, or cap text with a `ch` measure. `calc(var(--space-32) * 10)`
332
+ fails `ads check` (`layout-fixed-width`); list overlays in `layout.fixedWidthUnits`. Atomic CSS
333
+ does not keep rule order: give queries on one property exclusive ranges, such as
334
+ `(min-width: 768px) and (max-width: 1023.98px)`. `ads audit` fails horizontal overflow at 390,
335
+ 768 and 1280 px (`layout-overflow`). See the Grid section of
336
+ [design-data.md](references/design-data.md) (`ads://guides/tokens`).
337
+
338
+ ## Web performance
339
+
340
+ Use the project's image component; give `priority` to the view's main visible image only, since
341
+ lazy loading above the fold hurts. Call `preloadFonts()` from `tokens/fonts.preload.generated.ts`
342
+ in the app entry when it exists. `ads check` fails unsized or unchosen `<img>` (`img-attributes`)
343
+ and oversized assets (`asset-image-budget`); `ads audit` fails layout shift above 0.1
344
+ (`layout-shift`). ADS does not cover page metadata, `noindex`, sitemaps or hosting: run Lighthouse
345
+ on a production build with real URLs. Read [performance.md](references/performance.md)
346
+ (`ads://guides/performance`).
347
+
328
348
  ## Accessibility
329
349
 
330
350
  Target WCAG 2.2 AA. `ads check` fails on contrast in every theme and brand, target size,
331
351
  focus, text resize, reduced motion, text spacing, image alternatives and icon-only controls
332
- (`a11y-*` and `token-contrast`), and lists keyboard reach for review (`a11y-keyboard`);
333
- `ads audit` adds axe-core in the browser. Read [accessibility.md](references/accessibility.md)
352
+ (`a11y-*`, `token-contrast` and `component-contrast`), and lists keyboard reach for review
353
+ (`a11y-keyboard`); `ads audit` adds axe-core and non-text contrast in the browser. Read [accessibility.md](references/accessibility.md)
334
354
  (`ads://guides/accessibility`) for the rules and the practice no tool can check.
335
355
 
336
356
  ## Design craft and mobile behavior
@@ -10,7 +10,8 @@ Each message names its WCAG criterion.
10
10
 
11
11
  | Rule | What it reviews | WCAG |
12
12
  |---|---|---|
13
- | `token-contrast` | Text, link, accent and status text on their backgrounds (4.5:1); focus and control borders on canvas and surface (3:1); in every theme and brand | 1.4.3, 1.4.11 |
13
+ | `token-contrast` | Text, link, accent and status text on their backgrounds (4.5:1); focus and control borders on canvas and surface (3:1); in every theme and brand, for any CSS color syntax, with translucent colors composited over their background and the canvas. A pair color that cannot be resolved statically (`currentColor`, relative color syntax) is a `token-contrast-unresolved` info item | 1.4.3, 1.4.11 |
14
+ | `component-contrast` | A component or pattern style block (top level, a nested state such as `&:hover` or `&[aria-selected="true"]`, or an at-rule) that sets both `color: var(--a)` and `background`/`background-color: var(--b)` needs 4.5:1 in every theme and brand, resolved like `token-contrast`. Local custom properties in the block resolve one level, and an undeclared one reads its `var()` fallback. Disabled states are exempt; `currentColor`, `transparent`, transparent backgrounds, one token on both sides and native progress, meter and range parts are skipped; a side that names no color token, or text matching the canvas over a translucent background, is a `component-contrast-unresolved` info item | 1.4.3 |
14
15
  | `a11y-target-size` | `--control-height-*` of at least 24 px (44 px where touch is common) | 2.5.8 |
15
16
  | `a11y-focus` | `--focus-w` of at least 2 px, and a `:focus-visible` indicator in `base.css` | 2.4.7, 2.4.13 |
16
17
  | `a11y-text-resize` | Font-size tokens in `rem`, so text follows the reader's browser font size | 1.4.4 |
@@ -22,13 +23,15 @@ Each message names its WCAG criterion.
22
23
 
23
24
  Fix a finding in its owner: choose a different ramp step or size token, add the missing
24
25
  attribute, or move the interaction to a native control. Do not silence it with a one-off
25
- value.
26
+ value. Fix `component-contrast` with the role contract: `--x-text` on `--x-bg`, `--x-fg` on
27
+ `--x`; never a status color (`--success`) as text on its own tint (`--success-bg`).
26
28
 
27
- ## Browser audit (axe-core)
29
+ ## Browser audit (axe-core and non-text contrast)
28
30
 
29
31
  Run `ads audit` after changing a component, pattern or composition scenario. It renders
30
- each one in every declared brand and theme and runs axe-core's WCAG A/AA rules on the
31
- scenario content.
32
+ each one in every declared brand and theme, runs axe-core's WCAG A/AA rules on the
33
+ scenario content, and runs ADS's non-text contrast check (WCAG 1.4.11), which axe does not
34
+ cover.
32
35
 
33
36
  ```sh
34
37
  ads audit # every UI scenario, brand and theme
@@ -43,16 +46,30 @@ design-system/components/Broken.scenario.tsx:1:1 [error:a11y-axe] axe button-nam
43
46
  ```
44
47
 
45
48
  - Fix the finding in the component that renders the failing element, not in the scenario.
46
- - A `color-contrast` finding that `token-contrast` also reports is a token pair: change the
47
- ramp step. One only the audit reports comes from a component pairing tokens itself: use
48
- a role pair that `token-contrast` checks.
49
+ - A `color-contrast` finding that `token-contrast` or `component-contrast` also reports is a
50
+ token pair: change the ramp step or use the role pair. One only the audit reports comes
51
+ from inherited colors: set `color` beside the `background` it sits on, using a role pair.
52
+ - `a11y-non-text-contrast` errors cover enabled, visible buttons, inputs, selects,
53
+ textareas, links and `switch`/`checkbox`/`radio`/`slider`/`tab` roles. A control whose
54
+ background has less than 3:1 against its surroundings and that has a visible border needs
55
+ that border at 3:1 against the surrounding background: outline fields and controls with
56
+ `--border-strong`, keep `--border-default` for dividers. A button, link or tab with text or
57
+ an icon needs no boundary. An icon-only control needs its
58
+ icon's stroke or fill at 3:1 against the control's background: paint icons with a text
59
+ or `-fg` token. Disabled controls are exempt. Each finding names the elements, themes,
60
+ brands and lowest ratio.
61
+ - A failed render is retried on its own, up to 3 attempts. Read `retries` for retried passes; a
62
+ `browser-audit` error names a scenario that still failed and its last cause.
49
63
  - Token and brand scenarios are skipped; name one with `--scenario` to audit it.
50
- - To run the audit in `ads validate`/`ads_validate`, set `browserAudit: true` in that
51
- policy (`validation` or `acceptance`); its findings then fail that policy, as they fail
52
- `ads audit`. With `acceptance.browserAudit`, `ads_accept`, `ads_apply_patch` and
53
- `ads_apply_transaction` also audit the candidate's affected scenarios and reject the
54
- change on any `a11y-axe` error; read the findings with `ads_results` (`diagnostics`).
55
- - It needs the project's Playwright and browser, as captures do (`mcp.capture`).
64
+ - `ads validate`/`ads_validate` run the audit in both policies (`validation` and
65
+ `acceptance`); its findings fail the policy, as they fail `ads audit`. `ads_accept`,
66
+ `ads_apply_patch` and `ads_apply_transaction` audit the candidate's affected scenarios
67
+ and reject the change on any `a11y-axe` or `a11y-non-text-contrast` error; read the findings with `ads_results`
68
+ (`diagnostics`). `"browserAudit": false` in a policy turns its audit off.
69
+ - It needs the project's Playwright and browser, as captures do: `npm install -D
70
+ @playwright/test` and `npx playwright install chromium` (`ads create` and
71
+ `ads init` declare `@playwright/test`). `mcp.capture` selects the browser or an installed Chrome channel.
72
+ Without them the policy fails with a `browser-audit` error.
56
73
 
57
74
  A clean audit is not a pass: automated rules find only part of the WCAG failures. Keep the
58
75
  manual checks below.
@@ -30,6 +30,8 @@ horizontal writing mode. In the inspected Linaria implementation, `padding` and
30
30
  it can override the intended size. Shared atom reuse and CSS splitting can make
31
31
  this visible in a larger build even when an isolated view appears correct.
32
32
  The order of class names in HTML does not decide equal-specificity rule order.
33
+ Queries on one property therefore use exclusive ranges, such as
34
+ `(min-width: 768px) and (max-width: 1023.98px)` beside `(min-width: 1024px)`.
33
35
  Valid tokens, successful extraction and a passing source check do not establish
34
36
  the intended computed value.
35
37
 
@@ -142,15 +142,20 @@ fails on icon-only buttons and links without a name.
142
142
 
143
143
  Logos of other products (a chat service, a model provider, a sign-in provider) are
144
144
  not the project's brand and not UI icons. Keep them in `assets/logos/`, each in the
145
- colors its owner publishes, with a `README.md` that names each file, its source and
146
- the usage terms it is used under. Their owners' trademark and usage guidelines
145
+ colors its owner publishes, with a `README.md` that records each file's source and
146
+ the rule it is used under. Their owners' trademark and usage guidelines
147
147
  apply: use the official artwork, keep its colors and proportions, and do not change
148
148
  it to match the project's look.
149
149
 
150
150
  Show them as images: import the file with `?url` and render an `<img>` with an
151
- `alt` that names the product, or `alt=""` beside text that already names it. Where
152
- the logo must follow the text color (a muted or monochrome use), use the file as a
153
- CSS mask over `currentColor`, so its shape stays and the color follows the theme.
151
+ `alt` that names the product, or `alt=""` beside text that already names it.
152
+
153
+ Never mute, tint or recolor another product's logo. Use a one-color version only where
154
+ its owner's published rules allow it and in the colors they name; a CSS mask over a color
155
+ token then keeps the shape and follows the theme. A quieter version needs the owner's rule
156
+ or written permission.
157
+
158
+ The showcase's Icons tab shows each file as it is, on a white and a black tile.
154
159
 
155
160
  ADS generates nothing from `assets/logos/` and does not treat its files as brand
156
161
  artwork or glyphs: the brand checks (`brand-readme`, `brand-preview`,
@@ -103,7 +103,8 @@ generated `tokens/themes.generated.css` and `tokens/themes.generated.ts`. Run `a
103
103
  assets` after editing tokens or `ds.config.json` themes and brands without a running
104
104
  showcase or MCP server (`themes-generated` fails while they are stale). `ads audit`
105
105
  runs axe-core in every rendered UI scenario (`a11y-axe` errors; see
106
- ads://guides/accessibility). Set `assets.iconSource` to an SVG inside the ADS's
106
+ ads://guides/accessibility), the non-text contrast check (`a11y-non-text-contrast`) and the
107
+ overflow check at 390, 768 and 1280 px (`layout-overflow`; see ads://guides/tokens). Set `assets.iconSource` to an SVG inside the ADS's
107
108
  `assets/brand/`, relative to the ADS folder; no source means generation is a no-op.
108
109
  Integrate that directory through the app's existing asset mount. Fixed token
109
110
  names and prefixes are required; project values and artwork remain project-owned.
@@ -92,7 +92,7 @@ keeps independent component token definitions valid.
92
92
 
93
93
  ## Accessibility and rhythm checks
94
94
 
95
- `ads check` checks token values in every theme and brand. Each finding below is an error:
95
+ `ads check` checks token values in every theme and brand. Each finding below is an error unless marked info:
96
96
 
97
97
  - `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
98
98
  `--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
@@ -100,6 +100,13 @@ keeps independent component token definitions valid.
100
100
  status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
101
101
  `--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
102
102
  step for the role, in the theme the message names, never with a one-off color.
103
+ Any CSS color is evaluated (hex, named, `rgb()`, `hsl()`, `hwb()`, `lab()`, `lch()`,
104
+ `oklab()`, `oklch()`, `color()`, `color-mix()`, `light-dark()`), through halves and
105
+ aliases. A translucent background counts as composited over `--bg-canvas`, a translucent
106
+ foreground as composited over its background.
107
+ - `token-contrast-unresolved` (info): a pair color ADS cannot resolve statically
108
+ (`currentColor`, relative color syntax, a system color), so that pair is not checked. Give
109
+ the role a color or a ramp step, or check the pages that use it with `ads audit`.
103
110
  - `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
104
111
  - `control-padding`: pad a control with the token for its size. A block sized with
105
112
  `--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
@@ -127,6 +134,45 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
127
134
  breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
128
135
  widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
129
136
 
137
+ ### Widths are fluid on the grid; never a fixed cap
138
+
139
+ `--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
140
+ Set one inside a container query, under a `Grid` or another `container-type: inline-size`
141
+ ancestor, and leave narrow containers at full width:
142
+
143
+ ```css
144
+ inline-size: 100%;
145
+ @container (min-width: 1024px) { max-inline-size: var(--grid-span-10); }
146
+ ```
147
+
148
+ Atomic CSS does not keep rule order, so two queries on one property need exclusive ranges:
149
+
150
+ ```css
151
+ @container (min-width: 768px) and (max-width: 1023.98px) { max-inline-size: var(--grid-span-12); }
152
+ @container (min-width: 1024px) { max-inline-size: var(--grid-span-10); }
153
+ ```
154
+
155
+ Use `%` or `fr` for a share of the parent and a `ch` measure for running text
156
+ (`max-inline-size: 65ch`).
157
+
158
+ `layout-fixed-width` is an error for `width`, `min-width`, `max-width`, the logical inline
159
+ sizes, `flex-basis`, `flex`'s basis and `grid-template-columns` tracks with a fixed length
160
+ above 48 px, the top of the control and icon range: `var(--space-32)`,
161
+ `calc(var(--space-32) * 10)`.
162
+
163
+ These pass: `flex: 1 1 <basis>`; `min()`, `max()`, `clamp()` and `calc()` with a fluid part; `minmax()` with a fluid
164
+ maximum; the part sizes `--icon-*`, `--control-*`, `--avatar-*`, `--border-*`, `--focus-*`,
165
+ `--ring-*`, `--radius-*`, `--side-pane-*`, `--toast-*`, `--navigation-rail-width`,
166
+ `--app-header-height`, `--row-height-compact`, `--compact-column-min`; and tokens named by
167
+ `layout.widthTokens` in `ds.config.json`, which must be defined with `%` or container units.
168
+ A fixed `--container-*` or `--content-max` token named there is a cap, valid only as a maximum.
169
+ `layout.fixedWidthUnits` lists owners that may use fixed widths, by unit id or file glob: list
170
+ overlays (dialogs, menus, popovers, tooltips) there. There is no per-declaration exception.
171
+
172
+ `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
173
+ horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
174
+ scrollers and `text-overflow: ellipsis` are exempt.
175
+
130
176
  ## Color roles and states
131
177
 
132
178
  Name roles by element and purpose, the same in every theme; only their values change. Point roles at ramp steps rather than raw colors, so a theme is a ramp swap:
@@ -152,7 +152,7 @@ current rendered revision and complete acceptance before finishing the change.
152
152
  After rendered review, call `ads_accept({id,revision})` once. It checks that exact
153
153
  revision, runs mandatory ADS guards plus `acceptance.checks` and, when
154
154
  `acceptance.behaviorChecks` is enabled, affected registered behavior checks against an isolated candidate, and applies passing changes at
155
- their normal paths. When `acceptance.browserAudit` is enabled it also runs the axe-core
155
+ their normal paths. Unless `acceptance.browserAudit` is false it also runs the axe-core
156
156
  audit on the candidate's affected UI scenarios; an `a11y-axe` error rejects the draft.
157
157
  Fix it in the component and accept the new revision. Changes during checking or baseline conflicts prevent
158
158
  application. Successful acceptance removes the proposal and records an event.
@@ -23,7 +23,7 @@ ads_apply_patch({"unit":"components/Example","patchFile":"<returned patchFile>",
23
23
  The dry run validates the candidate in an isolated project copy using mandatory
24
24
  ADS guards, `acceptance.checks` and, when `acceptance.behaviorChecks` is enabled,
25
25
  affected registered behavior checks. Registration alone does not require a test
26
- at acceptance. With `acceptance.browserAudit`, axe-core also audits the candidate's
26
+ at acceptance. Unless `acceptance.browserAudit` is false, axe-core also audits the candidate's
27
27
  affected UI scenarios; `a11y-axe` errors reject the patch. See [validation policies](validation.md).
28
28
  Configured browser checks use that candidate's managed preview, not the live showcase. Read the summary, then page failing
29
29
  `outcomes`, `diagnostics` or pipeline `checks` through `ads_results` with its
@@ -24,6 +24,9 @@ Don't require hover for essential content or actions.
24
24
 
25
25
  ## Viewport and scrolling
26
26
 
27
+ `ads audit` fails a scenario that overflows horizontally at 390, 768 or 1280 px
28
+ (`layout-overflow`). Widths stay fluid on the grid; see `ads://guides/tokens`.
29
+
27
30
  The application owns viewport metadata, document/root scrolling, browser theme
28
31
  metadata, and installable-app settings. Reusable components/patterns own local
29
32
  layout and scroll behavior. Do not change application metadata as a side effect
@@ -0,0 +1,89 @@
1
+ # Web performance
2
+
3
+ What ADS checks, what to do when it fails, and what it leaves to you.
4
+
5
+ ## Images
6
+
7
+ | Use | Format | Size |
8
+ |---|---|---|
9
+ | Photos and screenshots | AVIF or WebP; JPEG as a fallback | Twice the displayed width at most |
10
+ | Flat art, icons, logos | SVG; PNG only when SVG cannot draw it | Optimized with SVGO or similar |
11
+
12
+ `asset-image-budget` (`ads check`) fails an image in `assets/` over its limit: SVG 100 KB, WebP
13
+ and AVIF 300 KB, JPEG 400 KB, PNG and GIF 500 KB. `assets.imageBudgetKb` in `ds.config.json`
14
+ replaces them with one limit for every format.
15
+
16
+ Use the starter's `Image`, or a project image component that does the same: it reserves the space
17
+ and loads lazily.
18
+
19
+ - `width` and `height` are the file's size. Use `aspectRatio` for a fluid image.
20
+ - Give `priority` to the view's main visible image, usually a hero. It loads eagerly with
21
+ `fetchpriority="high"`. Use it once per view.
22
+ - Never load an image lazily above the fold: it delays what the reader sees first.
23
+
24
+ `img-attributes` (`ads check`) fails a raw `<img>` in components, patterns and compositions without
25
+ a `loading` attribute, or without `width` and `height`, a visible `aspect-ratio`, a width and a
26
+ height in its style, or `position: absolute` or `fixed`. `loading="eager"` is a valid choice. A
27
+ spread or a class from another file is an `img-attributes-unresolved` info item: pass the
28
+ attributes explicitly.
29
+
30
+ `img-attributes` also fails a `srcset` with width descriptors and no `sizes`, on `<img>` and the
31
+ project's `Image`. Without `sizes` the browser assumes the full viewport width.
32
+
33
+ Suggestions for large content images:
34
+
35
+ - Generate the widths in the project's build tool or CDN; ADS generates no images. Use `srcset`
36
+ for large content images only, not icons or logos.
37
+ - Write `sizes` as the width the image displays at, per layout: `(min-width: 1024px) 50vw, 100vw`.
38
+ Add any margins the layout takes off.
39
+ - Verify at a phone width: load the page at 390 px wide and read `currentSrc` on the image, or the
40
+ network panel. The file should be the smallest candidate at least as wide as the image at that
41
+ device's pixel ratio.
42
+
43
+ Preloading the main image, as a suggestion:
44
+
45
+ - `priority` makes the browser fetch the image once it sees the `<img>`. In a client-rendered app
46
+ that tag does not exist until JavaScript runs, so a real head start needs
47
+ `<link rel="preload" as="image" imagesrcset="…" imagesizes="…" fetchpriority="high">` in the
48
+ page HTML.
49
+ - Only the project knows each page's hero, so ADS does not automate this. Pre-rendered or
50
+ server-rendered pages can generate the link from the same data as the `Image`; use a framework's
51
+ preload API where one exists.
52
+ - `imagesrcset` and `imagesizes` must match the `<img>` exactly, or the browser can download two
53
+ files. Verify by counting image requests.
54
+ - Preload one image per page at most. Do not preload anything below the fold.
55
+
56
+ ## Fonts
57
+
58
+ - Serve WOFF2 from `assets/fonts`, declared in `tokens/fonts.css`, with `font-display: swap`.
59
+ - When body or heading text uses a declared font, `ads assets` writes
60
+ `tokens/fonts.preload.generated.ts` naming only those files. `ads check` fails it when stale
61
+ (`themes-generated`). Without such a font it is not generated.
62
+ - Call `preloadFonts()` from it in the app entry, before the first render. It imports each file
63
+ through the bundler, so the preload and the stylesheet request one URL. A hand-written preload
64
+ URL that differs downloads the font twice.
65
+
66
+ ## CSS delivery
67
+
68
+ Do not inline the extracted stylesheet by default: repeat visits lose caching, large inlined CSS can
69
+ overflow the first round trip, and a strict CSP gets harder. Prefer hashed filenames, long-term
70
+ caching, Brotli, and Early Hints where the host supports them.
71
+
72
+ ## Layout shift
73
+
74
+ `layout-shift` (`ads audit`) fails a scenario whose Cumulative Layout Shift is above 0.1, in the
75
+ first render at 1280 px wide. Fix it by giving images and media dimensions, reserving space for
76
+ late content, and preloading first-text fonts. It runs where the browser reports layout shift
77
+ (Chromium). `worstLayoutShift` in the JSON result shows the highest score.
78
+
79
+ ## Measure first
80
+
81
+ Run Lighthouse on a production build and real URLs before tuning. Once Largest Contentful Paint is
82
+ under 2.5 s, preloads and delivery changes bring modest gains.
83
+
84
+ ## What ADS does not cover
85
+
86
+ - Page metadata, `noindex`, `robots.txt` and sitemaps belong to the application.
87
+ - Hosting: compression, cache headers, a CDN and HTTP versions.
88
+ - Image generation and image preloads.
89
+ - Real load times: scenario previews are not pages, and `ads audit` measures no load times.
@@ -41,12 +41,16 @@ implicitly requiring them at acceptance.
41
41
  all registered behavior checks. Use before a release, after ownership/test/config
42
42
  migrations and for an explicit complete audit. Changed scope narrows registered
43
43
  owners while project scripts and core gates retain full scope.
44
- - `browserAudit: true` in either policy adds the axe-core audit of every rendered
45
- UI scenario in every brand and theme (`browser-accessibility-audit`). Its `a11y-axe`
46
- findings are errors that fail the policy. With `acceptance.browserAudit`, draft
44
+ - Both policies run the axe-core audit of every rendered UI scenario in every brand
45
+ and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
46
+ that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
47
+ that cannot run (no project Playwright or browser) fails it with a `browser-audit`
48
+ error naming what to install. Under the acceptance policy, draft
47
49
  acceptance and guarded patches/transactions audit the candidate's affected UI
48
50
  scenarios (all after configuration, foundation, token or asset changes) and reject
49
- the change on any `a11y-axe` error or a `browser-audit` failure to run. Declare
51
+ the change on any of those errors or a `browser-audit` failure. A render that fails is
52
+ retried on its own, up to 3 attempts; retried passes are listed under `retries`, and a scenario
53
+ that still fails is a `browser-audit` error naming it and the last cause. Declare
50
54
  `"sideEffects": ["**/*.css"]` in the project's `package.json`, as the starters do, so a
51
55
  component change audits only the scenarios that import it. See
52
56
  ads://guides/accessibility.
@@ -58,7 +62,7 @@ implicitly requiring them at acceptance.
58
62
  disable tests or weaken configuration to make a failing change pass.
59
63
 
60
64
  Defaults: both script lists are empty, acceptance `behaviorChecks:false`,
61
- validation `behaviorChecks:true`, both `browserAudit:false`. No lint/test/build script names are inferred.
65
+ validation `behaviorChecks:true`, both `browserAudit:true`. No lint/test/build script names are inferred.
62
66
  Every listed script must exist; commands are trusted project configuration, not
63
67
  MCP arguments. `mcp.mutationChecks` is a configuration error: list those scripts in
64
68
  `acceptance.checks` and set `acceptance.behaviorChecks`. `mcp.mutationCheckTimeoutMs`
@@ -30,6 +30,8 @@ horizontal writing mode. In the inspected Linaria implementation, `padding` and
30
30
  it can override the intended size. Shared atom reuse and CSS splitting can make
31
31
  this visible in a larger build even when an isolated view appears correct.
32
32
  The order of class names in HTML does not decide equal-specificity rule order.
33
+ Queries on one property therefore use exclusive ranges, such as
34
+ `(min-width: 768px) and (max-width: 1023.98px)` beside `(min-width: 1024px)`.
33
35
  Valid tokens, successful extraction and a passing source check do not establish
34
36
  the intended computed value.
35
37
 
@@ -103,7 +103,8 @@ generated `tokens/themes.generated.css` and `tokens/themes.generated.ts`. Run `a
103
103
  assets` after editing tokens or `ds.config.json` themes and brands without a running
104
104
  showcase or MCP server (`themes-generated` fails while they are stale). `ads audit`
105
105
  runs axe-core in every rendered UI scenario (`a11y-axe` errors; see
106
- ads://guides/accessibility). Set `assets.iconSource` to an SVG inside the ADS's
106
+ ads://guides/accessibility), the non-text contrast check (`a11y-non-text-contrast`) and the
107
+ overflow check at 390, 768 and 1280 px (`layout-overflow`; see ads://guides/tokens). Set `assets.iconSource` to an SVG inside the ADS's
107
108
  `assets/brand/`, relative to the ADS folder; no source means generation is a no-op.
108
109
  Integrate that directory through the app's existing asset mount. Fixed token
109
110
  names and prefixes are required; project values and artwork remain project-owned.