@reqvire-org/ads 0.3.46 → 0.3.47
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 +21 -11
- package/dist/a11y.mjs +4 -2
- package/dist/assets.mjs +20 -15
- package/dist/atomic-composition.mjs +3 -2
- package/dist/brand-assets.mjs +48 -11
- package/dist/brands.mjs +82 -0
- package/dist/browser-audit/worker.mjs +45 -0
- package/dist/browser-audit.mjs +117 -0
- package/dist/capture/worker.mjs +1 -0
- package/dist/capture-store.mjs +2 -0
- package/dist/capture.mjs +7 -4
- package/dist/check.mjs +38 -8
- package/dist/cli.mjs +45 -10
- package/dist/color-values.mjs +325 -0
- package/dist/config.mjs +16 -2
- package/dist/control-padding.mjs +93 -0
- package/dist/design-values.mjs +3 -2
- package/dist/finding-rules.mjs +61 -0
- package/dist/foundation.mjs +17 -4
- package/dist/icons.mjs +107 -0
- package/dist/init.mjs +3 -0
- package/dist/mcp/apps.mjs +9 -6
- package/dist/mcp/drafts.mjs +3 -0
- package/dist/mcp/mutations.mjs +17 -1
- package/dist/mcp/preview-widget.bundle.js +36 -36
- package/dist/mcp/project-widget.bundle.js +12 -12
- package/dist/mcp/server.mjs +21 -9
- package/dist/mcp/widget.bundle.js +17 -17
- package/dist/palette-generated.mjs +180 -0
- package/dist/preview-resources.mjs +12 -3
- package/dist/render-color-probe.mjs +148 -0
- package/dist/runtime-contracts.mjs +14 -4
- package/dist/scenarios.mjs +1 -1
- package/dist/showcase/client.bundle.js +28 -28
- package/dist/showcase/icons.js +146 -0
- package/dist/showcase/index.html +2 -1
- package/dist/showcase/style.css +19 -2
- package/dist/skills/README.md +2 -1
- package/dist/skills/ads-break-ui/SKILL.md +6 -5
- package/dist/skills/ads-break-ui/references/atomic-styles.md +12 -12
- package/dist/skills/ads-break-ui/references/contracts.md +13 -10
- package/dist/skills/ads-break-ui/references/design-data.md +137 -29
- package/dist/skills/ads-break-ui/references/validation.md +8 -4
- package/dist/skills/ads-designer/SKILL.md +23 -16
- package/dist/skills/ads-designer/references/accessibility.md +39 -5
- package/dist/skills/ads-designer/references/atomic-styles.md +12 -12
- package/dist/skills/ads-designer/references/branding.md +37 -10
- package/dist/skills/ads-designer/references/cli.md +8 -2
- package/dist/skills/ads-designer/references/contracts.md +13 -10
- package/dist/skills/ads-designer/references/design-data.md +137 -29
- package/dist/skills/ads-designer/references/validation.md +8 -4
- package/dist/skills/ads-import/SKILL.md +9 -8
- package/dist/skills/ads-import/references/atomic-styles.md +12 -12
- package/dist/skills/ads-import/references/cli.md +8 -2
- package/dist/skills/ads-import/references/contracts.md +13 -10
- package/dist/skills/ads-import/references/design-data.md +137 -29
- package/dist/skills/ads-import/references/tokens.md +7 -3
- package/dist/skills/ads-import/references/validation.md +8 -4
- package/dist/skills/ads-motion/SKILL.md +6 -5
- package/dist/skills/ads-motion/references/atomic-styles.md +12 -12
- package/dist/skills/ads-motion/references/contracts.md +13 -10
- package/dist/skills/ads-motion/references/design-data.md +137 -29
- package/dist/skills/ads-motion/references/validation.md +8 -4
- package/dist/skills/ads-port/SKILL.md +6 -5
- package/dist/skills/ads-port/references/atomic-styles.md +12 -12
- package/dist/skills/ads-port/references/cli.md +8 -2
- package/dist/skills/ads-port/references/contracts.md +13 -10
- package/dist/skills/ads-port/references/design-data.md +137 -29
- package/dist/skills/ads-port/references/validation.md +8 -4
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +11 -2
- package/dist/starters/react/ADS.md +43 -10
- package/dist/starters/react/README.md +14 -9
- package/dist/starters/react/design-system/assets/brand/README.md +8 -3
- package/dist/starters/react/design-system/assets/glyphs/README.md +4 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +6 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +3 -2
- package/dist/starters/react/design-system/components/Content/Icon/README.md +2 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +3 -9
- package/dist/starters/react/design-system/components/Content/Logo/README.md +4 -2
- package/dist/starters/react/design-system/controllers/Palette/Palette.ts +164 -0
- package/dist/starters/react/design-system/index.ts +3 -0
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +2 -5
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +11 -2
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/design-system/tokens/base.css +8 -5
- package/dist/starters/react/design-system/tokens/colors.css +167 -175
- package/dist/starters/react/design-system/tokens/elevation.css +14 -21
- package/dist/starters/react/design-system/tokens/themes.generated.css +142 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +402 -0
- package/dist/style-boundaries.mjs +2 -1
- package/dist/themes-generated.mjs +150 -0
- package/dist/themes-watch.mjs +42 -0
- package/dist/themes.mjs +214 -63
- package/dist/token-export.mjs +22 -11
- package/dist/token-policy.mjs +2 -1
- package/dist/token-quality.mjs +28 -25
- package/dist/tokens.mjs +27 -32
- package/dist/validation.mjs +18 -1
- package/dist/verification/browser.mjs +14 -3
- package/docs/ADS.md +41 -27
- package/docs/ARCHITECTURE.md +49 -22
- package/docs/CACHING.md +2 -3
- package/docs/CHANGELOG.md +97 -13
- package/docs/CONTRACTS.md +13 -10
- package/docs/GUIDE.md +89 -21
- package/docs/MCP.md +35 -25
- package/docs/benchmarks/bun-previews.md +5 -5
- package/docs/benchmarks/{gidi-preview-memory.md → preview-memory.md} +14 -12
- package/docs/benchmarks/turbo-poc.md +24 -6
- package/package.json +2 -1
|
@@ -109,11 +109,11 @@ helpers do not grant custom scenario CSS.
|
|
|
109
109
|
|
|
110
110
|
For atomic base/variant styling, helper/wrapper class composition, extracted
|
|
111
111
|
custom-property arithmetic, typed `@property` registrations, or an
|
|
112
|
-
`atomic-composition-review` / `atomic-composition-limit`
|
|
112
|
+
`atomic-composition-review` / `atomic-composition-limit` finding, read
|
|
113
113
|
[atomic style composition](references/atomic-styles.md). The same guide is served
|
|
114
114
|
as `ads://guides/atomic-styles`. It explains shorthand/logical conflicts and
|
|
115
115
|
matching-property fixes, plus the build resolver for preserving opaque custom
|
|
116
|
-
properties through extraction.
|
|
116
|
+
properties through extraction. Check review items in the real `cx` composition and verify
|
|
117
117
|
computed styles across affected sizes/states; retain intentional product behavior.
|
|
118
118
|
|
|
119
119
|
Controllers are UI behavior owners: private helpers stay with their component or
|
|
@@ -243,7 +243,7 @@ and any remaining limits.
|
|
|
243
243
|
## Shared token contract and theme values
|
|
244
244
|
|
|
245
245
|
Read [tokens.md](references/tokens.md). Shared token names, meanings, and value
|
|
246
|
-
types form the contract; concrete values and theme
|
|
246
|
+
types form the contract; concrete values and per-theme halves can differ between
|
|
247
247
|
projects. Different values for the same compatible token are expected.
|
|
248
248
|
|
|
249
249
|
ADS fixes token names and namespaces. The destination uses the architecture's
|
|
@@ -256,7 +256,7 @@ before writing them. This does not add foreign-prefix support to ADS tooling.
|
|
|
256
256
|
| Import mode | Token handling |
|
|
257
257
|
|-------------|----------------|
|
|
258
258
|
| Component, pattern, or style | Reuse destination semantic roles and values; add only genuinely missing shared decisions |
|
|
259
|
-
| `tokens`, or items plus an explicit values request | Import all source-provided token values and theme
|
|
259
|
+
| `tokens`, or items plus an explicit values request | Import all source-provided token values and per-theme halves; add missing definitions |
|
|
260
260
|
|
|
261
261
|
Inspect the complete source/target contract for additions and compatibility.
|
|
262
262
|
Preserve existing destination values during item imports, including starter
|
|
@@ -266,7 +266,7 @@ replacing existing registries, helpers, stylesheets, or themes wholesale. A trul
|
|
|
266
266
|
empty destination needs initial definitions and values before an item can render.
|
|
267
267
|
|
|
268
268
|
In `tokens` mode, apply the source values for compatible token names. Preserve
|
|
269
|
-
target-only tokens and theme
|
|
269
|
+
target-only tokens and per-theme halves the source does not define. Bring assets
|
|
270
270
|
needed by imported values, such as fonts. This mode already authorizes the value
|
|
271
271
|
changes; do not ask again merely because source and target values differ.
|
|
272
272
|
|
|
@@ -437,9 +437,10 @@ foundation CSS rather than assigning shared token values in JavaScript. Keep
|
|
|
437
437
|
full-app integration harnesses and workflow coverage in application test support.
|
|
438
438
|
|
|
439
439
|
Foundation CSS is checked, not an escape hatch. Value sheets define shared tokens
|
|
440
|
-
on the document root
|
|
441
|
-
three closed roles: root/body typography,
|
|
442
|
-
normalization; and global focus
|
|
440
|
+
on the document root (per-theme halves) or a brand's `[data-brand]`; `fonts.css`
|
|
441
|
+
holds font-face metadata. `base.css` has three closed roles: root/body typography,
|
|
442
|
+
canvas and theme defaults; limited native normalization; and global focus
|
|
443
|
+
indicators/reduced-motion rules. Every selector
|
|
443
444
|
branch, property and value must fit its role. Token-backed control skins, layout,
|
|
444
445
|
interactive state rules and owner hooks are rejected even through `:where()`.
|
|
445
446
|
Do not copy an unchecked upstream preflight or turn a component repair into a reset.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Atomic style composition
|
|
2
2
|
|
|
3
3
|
Use this guide when creating or migrating component/pattern styles, changing
|
|
4
|
-
base/size/state combinations, or reviewing `atomic-composition-review`
|
|
4
|
+
base/size/state combinations, or reviewing `atomic-composition-review` items.
|
|
5
5
|
It is also available as `ads://guides/atomic-styles` through ADS MCP.
|
|
6
6
|
|
|
7
7
|
## Why valid tokens can still render incorrectly
|
|
@@ -203,7 +203,7 @@ entire className; `<button {...props} className={cx(base, className)} />` compos
|
|
|
203
203
|
it explicitly. Keep the product's intended forwarding behavior when fixing an
|
|
204
204
|
overlap. Do not change the public API simply to make tracing easier.
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
Review items include a bounded `composition` path through traced helpers and
|
|
207
207
|
components. A `target` identifies a statically reached DOM element. This
|
|
208
208
|
establishes source composition, not that a scenario mounted it or that its
|
|
209
209
|
computed result is wrong. `writingModeDependent: true` identifies overlaps that
|
|
@@ -213,9 +213,9 @@ expand them safely. Token formulas, inheritance and runtime values still need
|
|
|
213
213
|
review. A margin shorthand and `margin-inline: auto` may agree horizontally but
|
|
214
214
|
disagree in vertical text, so horizontal equality alone is insufficient.
|
|
215
215
|
|
|
216
|
-
## Respond to a
|
|
216
|
+
## Respond to a review item
|
|
217
217
|
|
|
218
|
-
1. Follow the
|
|
218
|
+
1. Follow the review item's related file/line locations and inspect the actual `cx`
|
|
219
219
|
composition. Variant lookups may contribute several possible combinations.
|
|
220
220
|
2. In a current built preview, inspect computed properties and the winning CSS
|
|
221
221
|
rules. Establish whether extraction order, specificity, writing mode or an
|
|
@@ -231,7 +231,7 @@ Increasing specificity, adding `!important`, copying styles into scenarios or
|
|
|
231
231
|
moving component styling into `base.css` can hide the symptom while retaining
|
|
232
232
|
the conflict. Prefer resolving the composition itself. If an overlap is
|
|
233
233
|
intentional, document why its precedence is stable and verify the resulting
|
|
234
|
-
behavior rather than changing product capabilities to silence a
|
|
234
|
+
behavior rather than changing product capabilities to silence a review item.
|
|
235
235
|
|
|
236
236
|
Use existing behavior contracts and `ads_verify` for important geometry. Register
|
|
237
237
|
a check beside its owner, link its real scenario and use the project's browser
|
|
@@ -249,16 +249,16 @@ states, themes and supported writing modes. Wait for observable readiness; an
|
|
|
249
249
|
event-stream connection can prevent `networkidle` from settling. A generic
|
|
250
250
|
overlap scan cannot decide which dimensions the product intended. A failed
|
|
251
251
|
registered geometry assertion is blocking through the existing verification
|
|
252
|
-
contract; an overlap
|
|
252
|
+
contract; an overlap review item remains a review signal.
|
|
253
253
|
|
|
254
254
|
## What ADS checks
|
|
255
255
|
|
|
256
|
-
`atomic-composition-review` is a nonblocking
|
|
257
|
-
with `severity: "
|
|
258
|
-
errors; MCP checks and mutations preserve the
|
|
256
|
+
`atomic-composition-review` is a nonblocking review item, returned under `advisories`
|
|
257
|
+
with `severity: "review"`. CLI checks still exit successfully when there are no
|
|
258
|
+
errors; MCP checks and mutations preserve the review item and its guidance URI.
|
|
259
259
|
|
|
260
260
|
An unchanged advisory baseline is not evidence that the affected styles are
|
|
261
|
-
correct. Triage
|
|
261
|
+
correct. Triage review items that reach an edited owner or its shared helpers against
|
|
262
262
|
the actual DOM classes and computed styles in a compiled scenario. Interaction
|
|
263
263
|
checks may pass without measuring padding, alignment or sizing. When an intended
|
|
264
264
|
layout is known, add a focused rendered assertion for that contract; when keeping
|
|
@@ -285,7 +285,7 @@ unresolved DOM targets and traversal limits produce bounded
|
|
|
285
285
|
`atomic-composition-limit` informational advisories where known atomic styles
|
|
286
286
|
reach an unresolved composition. Ordinary externally supplied className values
|
|
287
287
|
remain open inputs, not guaranteed safe styles. Depth, work and alternative
|
|
288
|
-
limits keep source inspection bounded; an unreported path or an empty
|
|
288
|
+
limits keep source inspection bounded; an unreported path or an empty review
|
|
289
289
|
list does not establish visual correctness. Actual failed registered
|
|
290
290
|
browser/behavior checks remain blocking; potentially intentional source overlaps
|
|
291
|
-
remain
|
|
291
|
+
remain review items.
|
|
@@ -90,14 +90,20 @@ For an initialized project, from its root:
|
|
|
90
90
|
npx @reqvire-org/ads check
|
|
91
91
|
npx @reqvire-org/ads tokens --json
|
|
92
92
|
npx @reqvire-org/ads assets
|
|
93
|
+
npx @reqvire-org/ads audit
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
Use the selected real distribution; for a local tarball, invoke
|
|
96
97
|
`npx --yes --package "$ads_tool_package" ads check` instead. Other inspection
|
|
97
98
|
commands accept a directory; init deliberately does not.
|
|
98
99
|
|
|
99
|
-
Normal builds run native `ads check`, then
|
|
100
|
-
icons in `.ds/assets
|
|
100
|
+
Normal builds run native `ads check`, then `ads assets`: configured standard brand
|
|
101
|
+
icons in `.ds/assets/`, committed `assets.targets`, the `assets.glyphs` module and the
|
|
102
|
+
generated `tokens/themes.generated.css` and `tokens/themes.generated.ts`. Run `ads
|
|
103
|
+
assets` after editing tokens or `ds.config.json` themes and brands without a running
|
|
104
|
+
showcase or MCP server (`themes-generated` fails while they are stale). `ads audit`
|
|
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
|
|
101
107
|
`assets/brand/`, relative to the ADS folder; no source means generation is a no-op.
|
|
102
108
|
Integrate that directory through the app's existing asset mount. Fixed token
|
|
103
109
|
names and prefixes are required; project values and artwork remain project-owned.
|
|
@@ -154,11 +154,14 @@ valueFrom: ["paint", "scheme.day", "scheme.night"],
|
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Register each matching `config.*.<path>` in `paintInputs`. The producer may write
|
|
157
|
-
one declared field, or
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
one declared field, or a per-theme value built with the generated helpers from
|
|
158
|
+
`tokens/themes.generated.ts`: `themed({ light: entry.scheme.day, dark: entry.scheme.night })`
|
|
159
|
+
(keys exactly the declared themes) or `themedByScheme({ light: …, dark: … })` (each theme
|
|
160
|
+
takes the value for its color scheme). Every value is a declared field and the argument is
|
|
161
|
+
an object literal without spreads. The normal key/map/root proof still applies. Raw
|
|
162
|
+
constants, undeclared fields, `light-dark()`, extra writes and unknown transforms are
|
|
163
|
+
rejected. The browser audit checks an accessible color reference in every theme's branch;
|
|
164
|
+
a local SVG URL or `none` is not a color there.
|
|
162
165
|
|
|
163
166
|
Families cannot overlap shared tokens, private runtime
|
|
164
167
|
prefixes or other bindings. A broad family such as `--color-${key}` grants no
|
|
@@ -167,12 +170,12 @@ cannot be established. Registered paint consumers list their allowed binding IDs
|
|
|
167
170
|
borrowing a peer's binding family or private runtime variable remains invalid. Bindings are scoped
|
|
168
171
|
to their actual root; portals outside it need deliberate project integration.
|
|
169
172
|
|
|
170
|
-
A registered binding producer
|
|
171
|
-
`
|
|
172
|
-
|
|
173
|
-
undefined tokens and SVG URLs
|
|
173
|
+
A registered binding producer gives a per-theme value with `themed()` or
|
|
174
|
+
`themedByScheme()`; its output is `var(--ads-if-<theme>, <reference>)` once per declared
|
|
175
|
+
theme, in declared order. The App paint audit checks every branch and its observed effect
|
|
176
|
+
in the active theme. Raw colors, undefined tokens and SVG URLs in a branch remain invalid.
|
|
174
177
|
This derived binding form does not widen public paint-input types; use constrained
|
|
175
|
-
references for each theme input and verify
|
|
178
|
+
references for each theme input and verify every theme in browser checks.
|
|
176
179
|
|
|
177
180
|
The App audit checks current mounted instances, accessible values, local SVG
|
|
178
181
|
resources and computed paint-property responses. Visibility and complete rendered
|
|
@@ -74,7 +74,7 @@ Review that intent and do not disguise a new design decision as arithmetic.
|
|
|
74
74
|
|
|
75
75
|
## Review overlap without deleting legitimate roles
|
|
76
76
|
|
|
77
|
-
`token-overlap-review` is a nonblocking
|
|
77
|
+
`token-overlap-review` is a nonblocking review item for shared tokens with identical
|
|
78
78
|
normalized definitions across their declared theme/condition scopes. It identifies
|
|
79
79
|
the tokens and source. Inspect their consumers and roles. If one decision is being
|
|
80
80
|
copied, reuse one shared token or make its relationship explicit with an alias.
|
|
@@ -82,7 +82,7 @@ Equal values alone do not prove equal purpose: body text and strong text, spacin
|
|
|
82
82
|
and control sizes, or two motion roles may intentionally differ later. A light-only
|
|
83
83
|
match does not justify merging tokens whose dark/reduced-motion values differ.
|
|
84
84
|
|
|
85
|
-
For
|
|
85
|
+
For existing workspaces, convert independent component constants explicitly:
|
|
86
86
|
select an existing shared role when it means the same thing; centralize genuinely
|
|
87
87
|
missing decisions; remove private sheets/imports and contract fields; update token
|
|
88
88
|
sample coverage in the shared directory. Preserve themes, units, public APIs and
|
|
@@ -90,24 +90,25 @@ behavior unless changing the visual policy was explicitly intended. Review a Git
|
|
|
90
90
|
diff and run core, project and browser checks. There is no compatibility mode that
|
|
91
91
|
keeps independent component token definitions valid.
|
|
92
92
|
|
|
93
|
-
## Accessibility and rhythm
|
|
93
|
+
## Accessibility and rhythm checks
|
|
94
94
|
|
|
95
|
-
`ads check`
|
|
96
|
-
resolving `var()` aliases there):
|
|
95
|
+
`ads check` checks token values in every theme and brand. Each finding below is an error:
|
|
97
96
|
|
|
98
|
-
- `token-contrast
|
|
99
|
-
`--text-
|
|
100
|
-
`--bg-
|
|
101
|
-
|
|
102
|
-
`--border-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- `
|
|
106
|
-
-
|
|
107
|
-
|
|
97
|
+
- `token-contrast`: the roles that meet on screen fall below WCAG 2.2 AA: `--text-strong`,
|
|
98
|
+
`--text-body`, `--text-muted`, `--text-link` and `--accent-text` on `--bg-canvas`,
|
|
99
|
+
`--bg-surface` and `--bg-hover`; `--accent-fg` on `--accent` and `--accent-hover`; each
|
|
100
|
+
status's `-fg` on its solid and `-text` on its `-bg` (4.5:1); `--border-focus` and
|
|
101
|
+
`--border-strong` on the canvas and surface (3:1). Fix it by choosing a different ramp
|
|
102
|
+
step for the role, in the theme the message names, never with a one-off color.
|
|
103
|
+
- `token-rhythm`: a numbered spacing step leaves the scale `--space-N` = N × 2 px.
|
|
104
|
+
- `control-padding`: pad a control with the token for its size. A block sized with
|
|
105
|
+
`--control-height-<size>` pads its sides with `--control-padding-<size>`; the small gap
|
|
106
|
+
inside a track (segmented control, switch) uses `--control-inset` (add it to the spacing
|
|
107
|
+
tokens if the project has none). Anything that is not a control does not use
|
|
108
|
+
`--control-height-*`.
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
`token-overlap-review` (review) compares values only within a token family (`--radius-*`
|
|
111
|
+
with `--radius-*`): a radius equal to a spacing step is two scales meeting, not a duplicate.
|
|
111
112
|
|
|
112
113
|
## Exchange format
|
|
113
114
|
|
|
@@ -143,18 +144,125 @@ Name roles by element and purpose, the same in every theme; only their values ch
|
|
|
143
144
|
|
|
144
145
|
## Themes
|
|
145
146
|
|
|
146
|
-
Declare themes in `ds.config.json` (`themes: [{ name, scheme }]`, the first is the default
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
-
|
|
147
|
+
Declare themes in `ds.config.json` (`themes: [{ name, scheme }]`, the first is the default;
|
|
148
|
+
`scheme` sets `color-scheme` for native controls and scrollbars).
|
|
149
|
+
|
|
150
|
+
Write a token that differs per theme as one half per theme, named with the theme as suffix,
|
|
151
|
+
on `:root`:
|
|
152
|
+
|
|
153
|
+
```css
|
|
154
|
+
:root {
|
|
155
|
+
--color-accent-9-light: oklch(55% .2 280);
|
|
156
|
+
--color-accent-9-dark: oklch(70% .16 280);
|
|
157
|
+
--bg-canvas-light: var(--slate-1-light);
|
|
158
|
+
--bg-canvas-dark: var(--slate-2-dark);
|
|
159
|
+
--accent: var(--color-accent-9);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- A half is a plain value or refers to halves: `--text-muted-dark: var(--slate-11-dark)`,
|
|
164
|
+
never `var(--slate-11)` (`theme-half-reference`).
|
|
165
|
+
- Give every themed token a half for every declared theme (`theme-coverage`). Tokens that do
|
|
166
|
+
not change per theme stay single values; a role that aliases a ramp step
|
|
167
|
+
(`--accent: var(--color-accent-9)`) needs no halves.
|
|
168
|
+
- Never set token values under `[data-theme]` or `prefers-color-scheme` (`theme-old-form`),
|
|
169
|
+
and never set a token both as one value and as halves (`theme-half-conflict`).
|
|
170
|
+
- ADS writes `tokens/themes.generated.css` from the halves and the declared themes and
|
|
171
|
+
brands: `ads assets` writes it, and the showcase and MCP server rewrite it whenever tokens
|
|
172
|
+
or `ds.config.json` change. Commit it, never edit it; it is the last foundation import.
|
|
173
|
+
After editing tokens without a running showcase, run `ads assets` (`themes-generated`
|
|
174
|
+
fails when it is stale).
|
|
175
|
+
- `data-theme="<name>"` on `<html>` themes the page; on any element it themes that section
|
|
176
|
+
and everything inside it, down to the next `data-theme`. A themed section paints its own
|
|
177
|
+
canvas and text (`base.css`).
|
|
178
|
+
- Add a theme for a real need: high contrast, a dimmed reading mode. Add a half for it to
|
|
179
|
+
every themed token. Check a theme in the showcase (the theme button steps through declared
|
|
180
|
+
themes) and capture it by name.
|
|
181
|
+
- Show content that belongs to one theme (a dark logo variant) with the generated display
|
|
182
|
+
switch: `display: var(--display-dark, block)`. It is `none` outside the nearest dark
|
|
183
|
+
theme. Never style by theme or brand with a selector (`[data-theme="dark"] &`,
|
|
184
|
+
`:root[data-brand] &`): it ignores the nearest section (`theme-selector`). Give per-theme
|
|
185
|
+
values as token halves instead.
|
|
186
|
+
- A per-theme value that comes from data at runtime (a chart series color, a highlighter
|
|
187
|
+
color) uses the generated helpers, never `light-dark()` (`theme-light-dark`):
|
|
188
|
+
`style={{ "--series": themed({ light: a, dark: b }) }}` with every declared theme as a key,
|
|
189
|
+
or `themedByScheme({ light: a, dark: b })` when the data has only light and dark (each
|
|
190
|
+
theme takes the value for its scheme). Values are complete colors.
|
|
191
|
+
- To follow the OS setting, set `"followSystemTheme": true` in `ds.config.json`: a page
|
|
192
|
+
without `data-theme` takes the first declared theme whose scheme matches
|
|
193
|
+
`prefers-color-scheme`. An explicit `data-theme` always wins. Letting the user choose and
|
|
194
|
+
remembering it is application code: it sets `data-theme`.
|
|
195
|
+
|
|
196
|
+
## Brands
|
|
197
|
+
|
|
198
|
+
A brand is a second axis beside the theme: the theme sets the color mode, the brand sets
|
|
199
|
+
identity (an accent ramp, a font). Use brands for white label (one product, each customer's
|
|
200
|
+
accent, font and logo, each in light and dark), a product family, or a co-branded partner
|
|
201
|
+
section; without them every combination becomes a theme (`acme-light`, `acme-dark`, …).
|
|
202
|
+
|
|
203
|
+
Declare brands in `ds.config.json` (`brands: [{ name }]`, the first is the default; leave
|
|
204
|
+
`brands` out for one brand). The default brand's values are the ones on `:root`. Another
|
|
205
|
+
brand re-sets existing tokens on its own selector only, with every half of a themed token it
|
|
206
|
+
changes:
|
|
207
|
+
|
|
208
|
+
```css
|
|
209
|
+
[data-brand="acme"] {
|
|
210
|
+
--color-accent-9-light: oklch(55% .2 25);
|
|
211
|
+
--color-accent-9-dark: oklch(70% .16 25);
|
|
212
|
+
--font-sans: Georgia, serif;
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- `data-brand="<name>"` on `<html>` brands the page; on any element that section. Brand and
|
|
217
|
+
theme are independent: each element takes its nearest brand and its nearest theme, at any
|
|
218
|
+
nesting depth, including the default brand inside another brand's section.
|
|
219
|
+
- Errors: a brand that gives a themed token one value (`brand-theme-value`) or only some of
|
|
220
|
+
its halves or ramp steps (`brand-coverage`), a token only a brand defines
|
|
221
|
+
(`brand-new-token`), a declared brand without values (`brand-empty`), a `data-brand` name
|
|
222
|
+
the config does not declare (`brand-undeclared`). `token-contrast` runs for every brand
|
|
223
|
+
in every theme.
|
|
224
|
+
- A brand's logo is brand artwork (`ads://guides/branding`). Render every brand's logo and
|
|
225
|
+
show each with `display: var(--display-brand-<brand>, block)`, so a section shows its
|
|
226
|
+
nearest brand's logo.
|
|
227
|
+
- The showcase shows a brand selector next to the theme button; captures take `brand`;
|
|
228
|
+
`ads tokens --format dtcg --brand <name>` exports a brand (with `--theme`, one brand in
|
|
229
|
+
one theme).
|
|
230
|
+
|
|
231
|
+
## Colors in Canvas, WebGL and SVG renderers
|
|
232
|
+
|
|
233
|
+
A renderer that needs colors as values (a graph, a chart, a canvas) reads them from the
|
|
234
|
+
generated palette, never from the page per item. `tokens/themes.generated.ts` holds every
|
|
235
|
+
color token resolved for every context (`<theme>`, and `<brand>/<theme>` for other brands)
|
|
236
|
+
as `{ css, rgba }`: `css` is `#rrggbb`, or `rgba(…)` when translucent; `rgba` is sRGB
|
|
237
|
+
0–255 with alpha 0–1. Aliases, halves and `color-mix()` are resolved; out-of-gamut colors
|
|
238
|
+
are clipped per channel, as a canvas does. ADS writes it with `themes.generated.css`.
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import { paletteFor, observePalette } from "@ds";
|
|
242
|
+
|
|
243
|
+
let colors = paletteFor(container); // once per render pass
|
|
244
|
+
const fill = colors["--accent"].rgba; // inside the per-node loop
|
|
245
|
+
const stop = observePalette(container, next => { colors = next; redraw(); });
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
- `paletteFor(element)` returns the palette of the element's nearest theme and brand (and
|
|
249
|
+
the OS setting under `followSystemTheme`). Call it once per render or context change; look
|
|
250
|
+
colors up inside loops.
|
|
251
|
+
- `observePalette(element, callback)` calls back once when the element's theme or brand
|
|
252
|
+
changes; redraw from it instead of rebuilding the renderer. It returns the unsubscribe.
|
|
253
|
+
- `paletteContext(element)` returns the context key (`<theme>` or `<brand>/<theme>`) for
|
|
254
|
+
`palette[key]` or for caching per context.
|
|
255
|
+
- `resolveColor(element, value)` resolves a color that is not a palette token (currentColor,
|
|
256
|
+
a value from data) once, without inserting elements, and caches it.
|
|
257
|
+
- A token whose value cannot be resolved ahead of time (currentColor, relative color syntax,
|
|
258
|
+
system colors) is not in the palette in any context; `unresolved` lists it. Use
|
|
259
|
+
`resolveColor` for those.
|
|
260
|
+
- The palette reflects token sheets, not inline token overrides at runtime or `@media`
|
|
261
|
+
variants.
|
|
262
|
+
|
|
263
|
+
`render-color-probe` (review) flags a computed-style color read or `getImageData` inside a
|
|
264
|
+
per-item path (an array callback, a loop body, `nodeReducer`/`edgeReducer`, d3 `.attr`/
|
|
265
|
+
`.style` callbacks). Move the read out with `paletteFor`.
|
|
158
266
|
|
|
159
267
|
## Spacing
|
|
160
268
|
|
|
@@ -57,8 +57,8 @@ checks and semantic reuse; keep shared names canonical.
|
|
|
57
57
|
Normalize nonconforming source references to canonical ADS names during import,
|
|
58
58
|
preserving destination values unless this mode explicitly requests changes.
|
|
59
59
|
|
|
60
|
-
`tokens` requests all source-provided values, including unused tokens
|
|
61
|
-
|
|
60
|
+
`tokens` requests all source-provided values, including unused tokens, per-theme halves
|
|
61
|
+
and supported media variants. Do not ask for individual token selection. Apply those
|
|
62
62
|
values to compatible shared names, add missing definitions, and preserve target-only
|
|
63
63
|
tokens and variants that the source does not define. Brand artwork is a separate
|
|
64
64
|
`brand` selection; fonts required by imported values remain in scope. An item import can also
|
|
@@ -71,7 +71,11 @@ changes and validate affected consumers.
|
|
|
71
71
|
|
|
72
72
|
Import aliases as value relationships, preserving their theme resolution rather
|
|
73
73
|
than flattening them to literals. Convert values to the destination format when
|
|
74
|
-
needed, including canonical reference names
|
|
74
|
+
needed, including canonical reference names and units. Write a source's per-theme
|
|
75
|
+
values (a `[data-theme]` or `prefers-color-scheme` block, `light-dark()`) as destination
|
|
76
|
+
halves on `:root` (`--x-light`, `--x-dark`, one per declared theme, each referring only to
|
|
77
|
+
halves), and a source brand's values as halves on `[data-brand="<name>"]`; then run `ads
|
|
78
|
+
assets` to regenerate `tokens/themes.generated.css` and `tokens/themes.generated.ts`. Use
|
|
75
79
|
syntax-aware edits; substring replacement can corrupt similarly named tokens.
|
|
76
80
|
Retain the destination's registry/API shape and adapt existing static value maps
|
|
77
81
|
or SSR fallbacks when they need to agree with the imported values.
|
|
@@ -41,6 +41,10 @@ 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; draft and patch acceptance do not run it. See
|
|
47
|
+
ads://guides/accessibility.
|
|
44
48
|
- Draft create, edit and show are preview-only; they trigger neither policy.
|
|
45
49
|
`ads_verify` explicitly runs selected checks independently of either policy.
|
|
46
50
|
- Builds, hooks and CI trigger a policy only when their scripts invoke it. Use
|
|
@@ -49,11 +53,11 @@ implicitly requiring them at acceptance.
|
|
|
49
53
|
disable tests or weaken configuration to make a failing change pass.
|
|
50
54
|
|
|
51
55
|
Defaults: both script lists are empty, acceptance `behaviorChecks:false`,
|
|
52
|
-
validation `behaviorChecks:true`. No lint/test/build script names are inferred.
|
|
56
|
+
validation `behaviorChecks:true`, both `browserAudit:false`. No lint/test/build script names are inferred.
|
|
53
57
|
Every listed script must exist; commands are trusted project configuration, not
|
|
54
|
-
MCP arguments.
|
|
55
|
-
and
|
|
56
|
-
|
|
58
|
+
MCP arguments. `mcp.mutationChecks` is a configuration error: list those scripts in
|
|
59
|
+
`acceptance.checks` and set `acceptance.behaviorChecks`. `mcp.mutationCheckTimeoutMs`
|
|
60
|
+
bounds each project script; behavior profiles have separate budgets.
|
|
57
61
|
|
|
58
62
|
Report the chosen policy, scope and revision. Skipped tests are not passed tests;
|
|
59
63
|
acceptance evidence is not complete-validation evidence. The two policies keep
|
|
@@ -131,11 +131,11 @@ helpers do not grant custom scenario CSS.
|
|
|
131
131
|
|
|
132
132
|
For atomic base/variant styling, helper/wrapper class composition, extracted
|
|
133
133
|
custom-property arithmetic, typed `@property` registrations, or an
|
|
134
|
-
`atomic-composition-review` / `atomic-composition-limit`
|
|
134
|
+
`atomic-composition-review` / `atomic-composition-limit` finding, read
|
|
135
135
|
[atomic style composition](references/atomic-styles.md). The same guide is served
|
|
136
136
|
as `ads://guides/atomic-styles`. It explains shorthand/logical conflicts and
|
|
137
137
|
matching-property fixes, plus the build resolver for preserving opaque custom
|
|
138
|
-
properties through extraction.
|
|
138
|
+
properties through extraction. Check review items in the real `cx` composition and verify
|
|
139
139
|
computed styles across affected sizes/states; retain intentional product behavior.
|
|
140
140
|
|
|
141
141
|
Controllers are UI behavior owners: private helpers stay with their component or
|
|
@@ -306,9 +306,10 @@ foundation CSS rather than assigning shared token values in JavaScript. Keep
|
|
|
306
306
|
full-app integration harnesses and workflow coverage in application test support.
|
|
307
307
|
|
|
308
308
|
Foundation CSS is checked, not an escape hatch. Value sheets define shared tokens
|
|
309
|
-
on the document root
|
|
310
|
-
three closed roles: root/body typography,
|
|
311
|
-
normalization; and global focus
|
|
309
|
+
on the document root (per-theme halves) or a brand's `[data-brand]`; `fonts.css`
|
|
310
|
+
holds font-face metadata. `base.css` has three closed roles: root/body typography,
|
|
311
|
+
canvas and theme defaults; limited native normalization; and global focus
|
|
312
|
+
indicators/reduced-motion rules. Every selector
|
|
312
313
|
branch, property and value must fit its role. Token-backed control skins, layout,
|
|
313
314
|
interactive state rules and owner hooks are rejected even through `:where()`.
|
|
314
315
|
Do not copy an unchecked upstream preflight or turn a component repair into a reset.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Atomic style composition
|
|
2
2
|
|
|
3
3
|
Use this guide when creating or migrating component/pattern styles, changing
|
|
4
|
-
base/size/state combinations, or reviewing `atomic-composition-review`
|
|
4
|
+
base/size/state combinations, or reviewing `atomic-composition-review` items.
|
|
5
5
|
It is also available as `ads://guides/atomic-styles` through ADS MCP.
|
|
6
6
|
|
|
7
7
|
## Why valid tokens can still render incorrectly
|
|
@@ -203,7 +203,7 @@ entire className; `<button {...props} className={cx(base, className)} />` compos
|
|
|
203
203
|
it explicitly. Keep the product's intended forwarding behavior when fixing an
|
|
204
204
|
overlap. Do not change the public API simply to make tracing easier.
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
Review items include a bounded `composition` path through traced helpers and
|
|
207
207
|
components. A `target` identifies a statically reached DOM element. This
|
|
208
208
|
establishes source composition, not that a scenario mounted it or that its
|
|
209
209
|
computed result is wrong. `writingModeDependent: true` identifies overlaps that
|
|
@@ -213,9 +213,9 @@ expand them safely. Token formulas, inheritance and runtime values still need
|
|
|
213
213
|
review. A margin shorthand and `margin-inline: auto` may agree horizontally but
|
|
214
214
|
disagree in vertical text, so horizontal equality alone is insufficient.
|
|
215
215
|
|
|
216
|
-
## Respond to a
|
|
216
|
+
## Respond to a review item
|
|
217
217
|
|
|
218
|
-
1. Follow the
|
|
218
|
+
1. Follow the review item's related file/line locations and inspect the actual `cx`
|
|
219
219
|
composition. Variant lookups may contribute several possible combinations.
|
|
220
220
|
2. In a current built preview, inspect computed properties and the winning CSS
|
|
221
221
|
rules. Establish whether extraction order, specificity, writing mode or an
|
|
@@ -231,7 +231,7 @@ Increasing specificity, adding `!important`, copying styles into scenarios or
|
|
|
231
231
|
moving component styling into `base.css` can hide the symptom while retaining
|
|
232
232
|
the conflict. Prefer resolving the composition itself. If an overlap is
|
|
233
233
|
intentional, document why its precedence is stable and verify the resulting
|
|
234
|
-
behavior rather than changing product capabilities to silence a
|
|
234
|
+
behavior rather than changing product capabilities to silence a review item.
|
|
235
235
|
|
|
236
236
|
Use existing behavior contracts and `ads_verify` for important geometry. Register
|
|
237
237
|
a check beside its owner, link its real scenario and use the project's browser
|
|
@@ -249,16 +249,16 @@ states, themes and supported writing modes. Wait for observable readiness; an
|
|
|
249
249
|
event-stream connection can prevent `networkidle` from settling. A generic
|
|
250
250
|
overlap scan cannot decide which dimensions the product intended. A failed
|
|
251
251
|
registered geometry assertion is blocking through the existing verification
|
|
252
|
-
contract; an overlap
|
|
252
|
+
contract; an overlap review item remains a review signal.
|
|
253
253
|
|
|
254
254
|
## What ADS checks
|
|
255
255
|
|
|
256
|
-
`atomic-composition-review` is a nonblocking
|
|
257
|
-
with `severity: "
|
|
258
|
-
errors; MCP checks and mutations preserve the
|
|
256
|
+
`atomic-composition-review` is a nonblocking review item, returned under `advisories`
|
|
257
|
+
with `severity: "review"`. CLI checks still exit successfully when there are no
|
|
258
|
+
errors; MCP checks and mutations preserve the review item and its guidance URI.
|
|
259
259
|
|
|
260
260
|
An unchanged advisory baseline is not evidence that the affected styles are
|
|
261
|
-
correct. Triage
|
|
261
|
+
correct. Triage review items that reach an edited owner or its shared helpers against
|
|
262
262
|
the actual DOM classes and computed styles in a compiled scenario. Interaction
|
|
263
263
|
checks may pass without measuring padding, alignment or sizing. When an intended
|
|
264
264
|
layout is known, add a focused rendered assertion for that contract; when keeping
|
|
@@ -285,7 +285,7 @@ unresolved DOM targets and traversal limits produce bounded
|
|
|
285
285
|
`atomic-composition-limit` informational advisories where known atomic styles
|
|
286
286
|
reach an unresolved composition. Ordinary externally supplied className values
|
|
287
287
|
remain open inputs, not guaranteed safe styles. Depth, work and alternative
|
|
288
|
-
limits keep source inspection bounded; an unreported path or an empty
|
|
288
|
+
limits keep source inspection bounded; an unreported path or an empty review
|
|
289
289
|
list does not establish visual correctness. Actual failed registered
|
|
290
290
|
browser/behavior checks remain blocking; potentially intentional source overlaps
|
|
291
|
-
remain
|
|
291
|
+
remain review items.
|
|
@@ -154,11 +154,14 @@ valueFrom: ["paint", "scheme.day", "scheme.night"],
|
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Register each matching `config.*.<path>` in `paintInputs`. The producer may write
|
|
157
|
-
one declared field, or
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
one declared field, or a per-theme value built with the generated helpers from
|
|
158
|
+
`tokens/themes.generated.ts`: `themed({ light: entry.scheme.day, dark: entry.scheme.night })`
|
|
159
|
+
(keys exactly the declared themes) or `themedByScheme({ light: …, dark: … })` (each theme
|
|
160
|
+
takes the value for its color scheme). Every value is a declared field and the argument is
|
|
161
|
+
an object literal without spreads. The normal key/map/root proof still applies. Raw
|
|
162
|
+
constants, undeclared fields, `light-dark()`, extra writes and unknown transforms are
|
|
163
|
+
rejected. The browser audit checks an accessible color reference in every theme's branch;
|
|
164
|
+
a local SVG URL or `none` is not a color there.
|
|
162
165
|
|
|
163
166
|
Families cannot overlap shared tokens, private runtime
|
|
164
167
|
prefixes or other bindings. A broad family such as `--color-${key}` grants no
|
|
@@ -167,12 +170,12 @@ cannot be established. Registered paint consumers list their allowed binding IDs
|
|
|
167
170
|
borrowing a peer's binding family or private runtime variable remains invalid. Bindings are scoped
|
|
168
171
|
to their actual root; portals outside it need deliberate project integration.
|
|
169
172
|
|
|
170
|
-
A registered binding producer
|
|
171
|
-
`
|
|
172
|
-
|
|
173
|
-
undefined tokens and SVG URLs
|
|
173
|
+
A registered binding producer gives a per-theme value with `themed()` or
|
|
174
|
+
`themedByScheme()`; its output is `var(--ads-if-<theme>, <reference>)` once per declared
|
|
175
|
+
theme, in declared order. The App paint audit checks every branch and its observed effect
|
|
176
|
+
in the active theme. Raw colors, undefined tokens and SVG URLs in a branch remain invalid.
|
|
174
177
|
This derived binding form does not widen public paint-input types; use constrained
|
|
175
|
-
references for each theme input and verify
|
|
178
|
+
references for each theme input and verify every theme in browser checks.
|
|
176
179
|
|
|
177
180
|
The App audit checks current mounted instances, accessible values, local SVG
|
|
178
181
|
resources and computed paint-property responses. Visibility and complete rendered
|