@designtools/tokens 0.4.0 → 0.5.0
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/CHANGELOG.md +85 -0
- package/README.md +84 -15
- package/dist/{chunk-MCLZSLHE.js → chunk-D6675UF5.js} +242 -129
- package/dist/cli.js +140 -46
- package/dist/index.d.ts +197 -20
- package/dist/index.js +13 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `@designtools/tokens`. Dates are release dates; versions follow semver, with breaking changes in the minor slot while the package is pre-1.0.
|
|
4
|
+
|
|
5
|
+
## 0.4.0
|
|
6
|
+
|
|
7
|
+
Partial regeneration, and the bug that made it necessary.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **The semantic bridge now follows `--seed-shade`.** Re-anchoring the ramp left the bridge on its hardcoded steps, so a brand colour anchored at 700 sat on `--color-primary-700` while `--primary` still pointed at 500 — the brand colour unreachable through `bg-primary`, with nothing in the output to say so. Mappings are now offsets from the anchor, resolved at emit time and clamped to the ends of the ramp. `--ring` moves with them, being primary-derived; `muted`, `border`, `input` and `shadow` do not, being neutral-derived.
|
|
12
|
+
- **Alias pairs no longer drift apart.** `destructive`/`red`, `success`/`green` and `warning`/`yellow` are two names for one scale, but `--color` moved only the name you typed, so `bg-red-500` and `bg-destructive-500` could silently differ in the same file. Overriding either now moves both.
|
|
13
|
+
- **The plain `css` format emits `.dark` and `.light` hooks.** Without them a project driving dark mode off a class — how Tailwind's own dark variant works — got no dark mode at all, and nothing in the build to say why.
|
|
14
|
+
- **The bridge constants had two copies**, one emitting `var()` references and one computing the values `--report` measures, so the CSS could disagree with its own contrast report. Now a single source in `bridge.ts`.
|
|
15
|
+
- **The parity harness and the fixture generator both dropped `seedShade`** on the way into `exportTokens` — the same desync in test form. The `seed-shade` fixture had been pinning the wrong value as faithfully as it would have pinned the right one.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`--ramps <names>`** — scope output to colour families. A family is one colour plus everything computed against it: its ramp, its alias ramp, and its semantic tokens. That is the safe unit to regenerate alone, because the contrast search that picks its foregrounds runs inside it.
|
|
20
|
+
- **`--merge`** — rewrite only the declarations a run generates into the file at `--out`, preserving every other line byte for byte. A family spans four blocks (`:root`, light, dark, and the `prefers-color-scheme` fallback); the media copy is the one a hand-splice forgets, leaving system-dark on the old colour.
|
|
21
|
+
- **`--check` honours `--ramps` and `--merge`.** A full check on a part-hand-edited file reports drift forever and cannot tell a wanted edit from a mistake; a scoped check compares only what the run generates.
|
|
22
|
+
- **The output states its own override contract**, built from the selectors each file actually emitted: the blocks are unlayered, here is the specificity to match, check both colour schemes, and a `--color-*` ramp step cannot be intercepted this way at all because Tailwind inlines its literal value into every utility.
|
|
23
|
+
- **`--report` covers what a palette can be silently wrong about** — where the semantics landed against their anchor, peak chroma per ramp (a seed can be chromatic by the numbers and still read as grey), and surface and utility contrast, which nothing had measured before. Ring is judged against 1.4.11's 3:1 rather than the body-text bar; border is reported without a verdict, since the generator cannot tell a decorative rule from a control boundary. These are reported but not scored, so the number stays comparable with earlier versions.
|
|
24
|
+
- npm metadata: keywords (there were none), homepage, bugs, and `repository.directory`.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- `--vanilla` and `--replace-palette` warn instead of being silently ignored. For an agent a silent no-op is worse than an error: it leaves a false belief about the output.
|
|
29
|
+
|
|
30
|
+
### Notes
|
|
31
|
+
|
|
32
|
+
- **Default output is effectively unchanged.** Across all five formats the only differences in the entire release are two selector lines and a comment block — every colour value in every default fixture is byte-identical. Only a non-default `--seed-shade` moves, which is the bug being fixed.
|
|
33
|
+
- **`--merge` against a file generated before 0.4.0** will refuse: the old file carries the previous dark selectors, so a new slice cannot place its blocks. It leaves the file untouched rather than half-applying. Regenerate once, then `--merge`.
|
|
34
|
+
- On the default seed, `--report` shows the focus ring clearing neither mode against the canvas (1.82:1 light, 2.71:1 dark). Left as-is because changing it shifts every palette; it is at least visible now.
|
|
35
|
+
|
|
36
|
+
## 0.3.0
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **`tailwind-v4` clears Tailwind's stock palette by default** (`--color-*: initial`), so a colour class the file does not define fails to compile rather than rendering off-brand. If a project does not own `--color-slate-900`, `bg-slate-900` yields Tailwind's stock slate — off-brand, compiles cleanly, reads as deliberate in review, and survives a re-theme. Better a build error.
|
|
41
|
+
- `--no-replace-palette` opts out, for an existing Tailwind codebase still using stock hues. `--replace-palette` becomes a no-op.
|
|
42
|
+
|
|
43
|
+
Tailwind's `transparent`, `current` and `inherit` are not part of the `--color-*` namespace and are unaffected.
|
|
44
|
+
|
|
45
|
+
## 0.2.1
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- The 0.2 API was missing from the package barrel. `selectTokenSections`, the section and shade helpers and the provenance functions all worked from the CLI — which imports modules directly — while being unreachable to programmatic callers. Added a test asserting every CLI capability is exported.
|
|
50
|
+
|
|
51
|
+
## 0.2.0
|
|
52
|
+
|
|
53
|
+
Made the Tailwind v4 output usable, and gave the CLI a verification story.
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- **`@theme static`, not plain `@theme`.** Tailwind tree-shakes a plain theme block down to the tokens some utility references, silently and with no build error. Measured on a default palette that dropped **47 of 140** colour tokens, including every `red`/`green`/`yellow` ramp, so `bg-red-500` fell back to Tailwind's stock red.
|
|
58
|
+
- **Semantic aliases are re-bound in every mode block.** Custom properties inherit their *computed* value, so `--color-primary: var(--primary)` declared only in `@theme` captured the light value and did not re-resolve inside a scoped `[data-theme="dark"]` subtree — a dark card on a light page kept the light colour. `<html class="dark">` happened to work either way, being the same element, which is why it went unnoticed.
|
|
59
|
+
- **`tailwind-v4` mode selectors match the `css` export** — `[data-theme="dark"], .dark` rather than `.dark` alone — and it gained the `prefers-color-scheme` fallback it had never had.
|
|
60
|
+
- **Primitive naming converged on `--color-*` across formats**, so `css` and `tailwind-v4` are interchangeable. Previously each was internally consistent but they could not be mixed.
|
|
61
|
+
- **A seed outside 15–98% lightness no longer inverts the ramp.** It was reproduced exactly at its anchor while its neighbours were clamped, so `#0a0a0a` gave shade 500 lighter than 600. Pre-existing; reproduces at the default anchor on 0.1.6.
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
- **`--seed-shade <25..950>`** — place the brand colour somewhere other than 500. Brand colours arrive as whatever they are, and a deep navy or pale tint pinned to the middle leaves no headroom on one side. Each side's easing curve is resampled onto its new step count and the chroma envelope follows the anchor.
|
|
66
|
+
- **`--shades <tailwind|full|list>`** — choose which steps exist. Tokens naming a dropped step snap to the nearest emitted one, and every substitution is reported, because snapping changes a design decision.
|
|
67
|
+
- **`--only <ramp|primitives|semantic|surface|utility>`** — slice by tier, to keep generated colour separable from hand-tuned files.
|
|
68
|
+
- **`--seed <file.json>` / `--stdin`** — replay a saved configuration; flags still win over it.
|
|
69
|
+
- **`--check`** — regenerate in memory and compare against `--out`, exiting non-zero on drift. Reads a provenance header, so it distinguishes a generator upgrade from a hand edit.
|
|
70
|
+
- **`--report`** — the measured contrast of every semantic pairing, with a score.
|
|
71
|
+
- **`--replace-palette`** — clear Tailwind's stock palette (default from 0.3.0).
|
|
72
|
+
- A provenance header naming the version and a fingerprint of the inputs.
|
|
73
|
+
- Structural invariant tests, covering what a golden fixture cannot: bytes can be stable and still be incoherent CSS. Chief among them, every `var(--x)` an export emits must resolve to a `--x:` the same output defines.
|
|
74
|
+
|
|
75
|
+
### Removed
|
|
76
|
+
|
|
77
|
+
- **shadcn/ui compatibility aliases** (`--background`, `--card`, `--secondary`, `--sidebar-*`, `--chart-*`) and the **`lovable` format**, which was a shadcn-shaped `globals.css`. `exportToLovable` and `ExportOptions.compat` are gone.
|
|
78
|
+
|
|
79
|
+
### Deprecated
|
|
80
|
+
|
|
81
|
+
- `--vanilla` — the aliases it switched off no longer exist, so it is the only behaviour.
|
|
82
|
+
|
|
83
|
+
## 0.1.7 — do not use
|
|
84
|
+
|
|
85
|
+
Published by mistake: this is the breaking 0.2.0 payload under a patch version, so a caretted `^0.1.6` resolves to it and picks up breaking changes with no version signal. Use `0.1.6` for the old behaviour or `0.2.1`+ for the new.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ And **every foreground is measured, not assumed.** For each background it genera
|
|
|
14
14
|
|
|
15
15
|
```
|
|
16
16
|
light mode (wcag, target aa)
|
|
17
|
-
AA primary/default 5.
|
|
17
|
+
AA primary/default 5.19:1
|
|
18
18
|
- neutral/default 4.30:1
|
|
19
19
|
score: 93% (14/15 pairings)
|
|
20
20
|
```
|
|
@@ -96,6 +96,16 @@ Held near-neutral at the light end so tints stay clean, at full strength through
|
|
|
96
96
|
|
|
97
97
|
Hue is held constant across the whole scale — no Bezold–Brücke correction, no artistic rotation — so shade 900 is unmistakably the same colour as shade 100.
|
|
98
98
|
|
|
99
|
+
### Every colour is one a screen can show
|
|
100
|
+
|
|
101
|
+
OKLCH can describe colours more saturated than any screen displays, and near white and near black a screen can show very little chroma at all. A saturated seed held at full chroma down its ramp goes out of gamut at both ends: in 0.4.0, `#2f6fed` produced 36 of 48 primitives across its primary and status ramps that no browser renders as written.
|
|
102
|
+
|
|
103
|
+
So each step's chroma is capped at the most sRGB holds at that step's lightness and hue. Lightness and hue never move, only chroma, so a step keeps its place in the ramp. The value in the file is the colour on the page, in every browser.
|
|
104
|
+
|
|
105
|
+
Contrast is measured on the colour that is displayed, too. A browser maps an out-of-gamut colour into the screen's gamut when it paints (the CSS Color 4 algorithm), and the checks measure that same mapped colour, so a value that arrives out of gamut, such as a seed or a hand-edited token, is scored as it will be seen. Before 0.5.0, APCA scored such pairings Lc 0 and the foreground search chose blind.
|
|
106
|
+
|
|
107
|
+
For wide-gamut displays there is [`--gamut p3`](#--gamut--which-displays).
|
|
108
|
+
|
|
99
109
|
### Foregrounds are searched, not mapped
|
|
100
110
|
|
|
101
111
|
For every background it generates, the tool computes real contrast against each candidate shade and picks the one **closest to a comfortable target among those clearing your floor** — not the first that scrapes past, which would hand you the least legible passing option every time. If nothing in the colour's own scale qualifies it falls back to the neutral scale, then to black or white.
|
|
@@ -202,6 +212,15 @@ So an agent's contract is *scope, merge, verify* — and a bad merge is caught r
|
|
|
202
212
|
|
|
203
213
|
`destructive`/`red`, `success`/`green` and `warning`/`yellow` are two names for one scale, so overriding either moves both. Without that, `--color destructive=…` would leave `bg-red-500` on the old colour and the two names would silently disagree inside the same file.
|
|
204
214
|
|
|
215
|
+
## Upgrading to 0.5.0
|
|
216
|
+
|
|
217
|
+
0.5.0 changes output for any saturated seed, so `--check` will report the version change until you regenerate. What moves:
|
|
218
|
+
|
|
219
|
+
- **Ramp steps that were outside sRGB** have their chroma capped to fit. Lightness and hue are unchanged, and a step that was already displayable is byte-identical. Pale and muted seeds are often untouched.
|
|
220
|
+
- **hex, rgb and hsl output of those steps** is the gamut-mapped colour a browser paints, not a channel-by-channel clip that shifted hue.
|
|
221
|
+
- **Some foregrounds**, where the search can now measure a background it could not before.
|
|
222
|
+
- **`--seed-shade` moves the primary only.** If you relied on it moving the neutral or status colours, anchor them explicitly with `--neutral-seed-shade` and `--color name=colour@shade`.
|
|
223
|
+
|
|
205
224
|
## Programmatic use
|
|
206
225
|
|
|
207
226
|
```ts
|
|
@@ -213,14 +232,19 @@ const css = exportTokens(tokens, "css", { colorFormat: "oklch" });
|
|
|
213
232
|
|
|
214
233
|
`generateTokens` returns a structured `TokenSystem`; `exportTokens` serialises it. Everything the CLI does is available here. No browser, DOM, or React — it runs anywhere.
|
|
215
234
|
|
|
216
|
-
|
|
235
|
+
The anchors have to be passed to both: **`seedShade`** (the primary's) and **`seedShades`** (every other family's, by name). The semantic bridge is expressed as offsets from each anchor, so an export that does not know where the seeds sit emits `var()` references the resolved values in `tokens` disagree with. Pass the same values to each, as the CLI does:
|
|
217
236
|
|
|
218
237
|
```ts
|
|
219
|
-
const
|
|
220
|
-
const tokens = generateTokens(
|
|
221
|
-
|
|
238
|
+
const anchors = { seedShade: 800, seedShades: { neutral: 200, accent: 300 } } as const;
|
|
239
|
+
const tokens = generateTokens(
|
|
240
|
+
{ primary: "#1e3a5f", neutral: "#e7e5e4", additionalColors: { accent: "#fde68a" } },
|
|
241
|
+
anchors
|
|
242
|
+
);
|
|
243
|
+
const css = exportTokens(tokens, "css", { colorFormat: "oklch", ...anchors });
|
|
222
244
|
```
|
|
223
245
|
|
|
246
|
+
With `gamut: "p3"`, the wide-gamut tiers are on `tokens.p3`, and the checks take the gamut to measure on: `checkSemanticContrast(tokens.p3.semantic.light, "p3")`.
|
|
247
|
+
|
|
224
248
|
## Output formats
|
|
225
249
|
|
|
226
250
|
| `--format` | File under `--format all` | What it is |
|
|
@@ -243,7 +267,7 @@ const css = exportTokens(tokens, "css", { colorFormat: "oklch", seedShade });
|
|
|
243
267
|
|---|---|---|
|
|
244
268
|
| `--primary <colour>` | — | Your brand colour. Required unless `--seed` supplies it. |
|
|
245
269
|
| `--neutral <colour>` | `#747474` | Neutral seed. Drives greys, surfaces, borders. |
|
|
246
|
-
| `--color <name>=<colour
|
|
270
|
+
| `--color <name>=<colour>[@<shade>]` | — | An extra named scale. Repeatable. `@<shade>` anchors its seed on that step. |
|
|
247
271
|
| `--seed <file.json>` | — | Replay a saved configuration. Flags given alongside it win, so a seed is defaults rather than a lock. |
|
|
248
272
|
| `--stdin` | off | Read that same JSON from standard input. |
|
|
249
273
|
|
|
@@ -253,12 +277,14 @@ A seed file:
|
|
|
253
277
|
{
|
|
254
278
|
"primaryColor": "#7c3aed",
|
|
255
279
|
"neutralColor": "#747474",
|
|
256
|
-
"additionalColors": [{ "name": "accent", "color": "#f59e0b" }],
|
|
280
|
+
"additionalColors": [{ "name": "accent", "color": "#f59e0b", "seedShade": 500 }],
|
|
257
281
|
"colorFormat": "hex",
|
|
258
282
|
"contrastAlgorithm": "apca",
|
|
259
283
|
"contrastTarget": "aaa",
|
|
260
284
|
"lightnessStrategy": "perceptual",
|
|
261
285
|
"seedShade": 500,
|
|
286
|
+
"neutralSeedShade": 500,
|
|
287
|
+
"gamut": "srgb",
|
|
262
288
|
"shades": [25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950],
|
|
263
289
|
"shadeOverrides": {}
|
|
264
290
|
}
|
|
@@ -271,7 +297,9 @@ A seed file:
|
|
|
271
297
|
| `--contrast` | `wcag` · `apca` | `wcag` | Which algorithm picks foregrounds. |
|
|
272
298
|
| `--target` | `aa-large` · `aa` · `aaa` | `aa` | Minimum the foreground search must clear. |
|
|
273
299
|
| `--lightness` | `fixed` · `perceptual` | `fixed` | How lightness is spread across the steps. |
|
|
274
|
-
| `--seed-shade` | `25`…`950` | `500` | Which step your
|
|
300
|
+
| `--seed-shade` | `25`…`950` | `500` | Which step your primary lands on. |
|
|
301
|
+
| `--neutral-seed-shade` | `25`…`950` | `500` | Which step your neutral lands on. |
|
|
302
|
+
| `--gamut` | `srgb` · `p3` | `srgb` | Which displays to generate for. |
|
|
275
303
|
| `--shades` | `tailwind` · `full` · a list | `full` | Which steps to emit. |
|
|
276
304
|
| `--overrides <file.json>` | — | — | Per-token shade overrides. |
|
|
277
305
|
|
|
@@ -286,14 +314,24 @@ generate-tokens --primary "#fde68a" --seed-shade 200 # pale amber belongs nea
|
|
|
286
314
|
|
|
287
315
|
Your colour is still reproduced exactly, just at the step you name. The ramp keeps its shape — gentle at the light end, larger jumps at the dark end for text contrast — and peak chroma follows the seed.
|
|
288
316
|
|
|
289
|
-
**
|
|
317
|
+
**Each colour has its own anchor.** `--seed-shade` moves the primary only. The neutral takes `--neutral-seed-shade`, an added colour takes `@<shade>` on `--color`, and the derived status colours, which are built at mid lightness, stay on 500:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
generate-tokens --primary "#fde68a" --seed-shade 200 \
|
|
321
|
+
--neutral "#e7e5e4" --neutral-seed-shade 100 \
|
|
322
|
+
--color accent=#1e3a5f@800
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Before 0.5.0, `--seed-shade` moved every family. A pale brand colour anchored at 200 dragged the neutral to 200 with it, so `#CECECE` became `neutral-200` and the whole grey ramp darkened. A pale brand does not imply a pale grey.
|
|
326
|
+
|
|
327
|
+
**The semantics follow the anchor too.** `--primary`, its subdued and highlight variants, and `--ring` are positions relative to the seed, not fixed steps, and every other family's semantics are relative to that family's own anchor — so `bg-primary` is your brand colour wherever you anchor it. Before 0.4.0 they were pinned to 500, which meant anchoring a deep navy at 800 left `--primary` pointing at a pale mid-tone the brand never chose, with no way to reach the real one through `bg-primary` at all.
|
|
290
328
|
|
|
291
329
|
`muted`, `border`, `input` and `shadow` stay where they are: they read the neutral ramp, not your brand, and re-anchoring the whole UI's greys is a different thing from placing a brand colour.
|
|
292
330
|
|
|
293
331
|
`--report` prints where the bridge landed, so you can check rather than infer:
|
|
294
332
|
|
|
295
333
|
```
|
|
296
|
-
semantic bridge
|
|
334
|
+
semantic bridge for primary, anchored at 800 (neutral at 200; other families at 500)
|
|
297
335
|
light default 800 subdued 300 highlight 950 ring 700
|
|
298
336
|
dark default 900 subdued 500 highlight 700 ring 950
|
|
299
337
|
```
|
|
@@ -315,7 +353,33 @@ Some tokens name specific steps — `muted` and light `canvas` both sit on 25
|
|
|
315
353
|
canvas (light): 25 -> 50
|
|
316
354
|
```
|
|
317
355
|
|
|
318
|
-
A shade set needs at least three steps, and `--seed-shade
|
|
356
|
+
A shade set needs at least three steps, and every anchor (`--seed-shade`, `--neutral-seed-shade`, `@<shade>`) must be one of them.
|
|
357
|
+
|
|
358
|
+
#### `--gamut` — which displays
|
|
359
|
+
|
|
360
|
+
By default every colour is inside sRGB, the gamut every screen shows. Most phones and Macs can show more: Display P3 holds noticeably more chroma, most of all near white and near black, which is exactly where sRGB caps a vivid ramp hardest.
|
|
361
|
+
|
|
362
|
+
`--gamut p3` keeps the sRGB output exactly as it is and adds a wide-gamut layer after it. For `#2f6fed`:
|
|
363
|
+
|
|
364
|
+
```css
|
|
365
|
+
:root {
|
|
366
|
+
--color-primary-50: oklch(95.16% 0.0229 262.00); /* sRGB: every screen */
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
@media (color-gamut: p3) {
|
|
370
|
+
:root {
|
|
371
|
+
--color-primary-50: oklch(95.16% 0.0252 262.00); /* P3 screens */
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Only the ramps are re-declared: semantic, surface and utility tokens are `var()` references to ramp steps, so they follow, and Tailwind v4 utilities read `var(--color-*)` too. Every ramp step is re-declared, not just those that differ, so a `--merge` after a re-seed cannot leave a stale value behind that only P3 screens would show.
|
|
377
|
+
|
|
378
|
+
**Every foreground is chosen to pass on both.** The search scores each candidate on sRGB and on P3 and keeps the worse, so the step it picks clears the floor on either kind of screen, and both tiers read the same steps. Where no step clears it on both, it takes the one with the best worst case, as it does when no step clears it at all. `--report` measures both.
|
|
379
|
+
|
|
380
|
+
Values in the layer are always printed as `oklch`, since `hex`, `rgb()` and `hsl()` can only hold sRGB. `tailwind-v3` and `dtcg` cannot carry the layer and say so on stderr; `json` carries it as `p3`.
|
|
381
|
+
|
|
382
|
+
A seed outside sRGB is reported on stderr, since its step will not be the colour as given: its chroma is reduced to fit, keeping lightness and hue. With `--gamut p3` the wide layer keeps it as given if P3 can show it.
|
|
319
383
|
|
|
320
384
|
### Selection
|
|
321
385
|
|
|
@@ -413,7 +477,7 @@ You get `bg-primary`, `text-primary-foreground`, `bg-canvas`, `border-border` **
|
|
|
413
477
|
|
|
414
478
|
Three details carry the weight, each verified against a real Tailwind compile:
|
|
415
479
|
|
|
416
|
-
**`@theme static`, never plain `@theme`.** Tailwind tree-shakes a plain theme block down to only the tokens some utility references — silently, with no build error. On a default palette that drops **
|
|
480
|
+
**`@theme static`, never plain `@theme`.** Tailwind tree-shakes a plain theme block down to only the tokens some utility references — silently, with no build error. On a default palette that drops **47 of 140** colour tokens, including every `red`/`green`/`yellow` ramp, so `bg-red-500` quietly falls back to Tailwind's stock red.
|
|
417
481
|
|
|
418
482
|
**Semantic aliases appear in the theme block *and* every mode block.** The `@theme` entry registers the name so the utility exists. But custom properties inherit their *computed* value, so an alias declared only on `:root` captures the light value and will not re-resolve inside a scoped `[data-theme="dark"]` subtree — a dark card on a light page would keep the light colour. (`<html class="dark">` works either way, being the same element, which is why this is easy to miss.)
|
|
419
483
|
|
|
@@ -449,7 +513,7 @@ Two consequences, both of which have cost real projects real time:
|
|
|
449
513
|
|
|
450
514
|
Then check **both** colour schemes, not whichever your tool defaults to.
|
|
451
515
|
|
|
452
|
-
**
|
|
516
|
+
**Change a ramp step through its seed, not by overriding it.** Tailwind v4 utilities do read ramp steps through `var()` (checked against a Tailwind 4.3 compile), which is what lets the `--gamut p3` layer work. The one exception is an opacity modifier: `bg-primary-500/50` also emits the step's literal value as a fallback for browsers without `color-mix()`, and an override cannot reach that. But a hand-overridden step is a fork of the palette that the contrast search never saw and `--check` cannot detect. If you need a ramp step to change, change the seed and regenerate, or point the call sites at a token you do own.
|
|
453
517
|
|
|
454
518
|
Generated files carry this contract in their own header, built from the selectors that file actually emitted.
|
|
455
519
|
|
|
@@ -457,7 +521,8 @@ If you find yourself hand-writing a colour beside the generated file, that is th
|
|
|
457
521
|
|
|
458
522
|
## Guarantees
|
|
459
523
|
|
|
460
|
-
- **Deterministic.** Same inputs and version produce byte-identical output. No randomness, clocks, or environment reads. (
|
|
524
|
+
- **Deterministic.** Same inputs and version produce byte-identical output. No randomness, clocks, or environment reads. (A grey has no meaningful hue, so `hsl` output prints it as 0 rather than float noise that differs across engines.)
|
|
525
|
+
- **Displayable.** Every value is inside sRGB, so the colour in the file is the colour on the page, and contrast is measured on the colour a browser paints. With `--gamut p3`, the wide layer is inside Display P3.
|
|
461
526
|
- **Two test tiers.** Golden fixtures pin the bytes; structural invariants pin what a fixture cannot — chiefly that every `var(--x)` an export emits resolves to a `--x:` the same output defines. Bytes can be stable and still be incoherent CSS.
|
|
462
527
|
- **Two dependencies**, both pure JS: `culori` (colour maths) and `apca-w3` (APCA contrast).
|
|
463
528
|
- **ESM**, Node 18+.
|
|
@@ -476,9 +541,13 @@ npm test # vitest
|
|
|
476
541
|
|
|
477
542
|
```
|
|
478
543
|
src/ types, oklch, primitives, semantic, generate, export, seed, shades, index, cli
|
|
479
|
-
test/ fixture parity, export invariants, shade behaviour, public API
|
|
544
|
+
test/ fixture parity, export invariants, shade behaviour, gamut, public API
|
|
480
545
|
```
|
|
481
546
|
|
|
547
|
+
## Changelog
|
|
548
|
+
|
|
549
|
+
[CHANGELOG.md](CHANGELOG.md) — what changed in each release, and why.
|
|
550
|
+
|
|
482
551
|
## Licence
|
|
483
552
|
|
|
484
553
|
CC-BY-NC-4.0
|