@designtools/tokens 0.2.1 → 0.3.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/README.md CHANGED
@@ -136,9 +136,10 @@ Supported by `css`, `tailwind-v4` and `json`; the other formats reject it rather
136
136
  | `--format` | `css` · `tailwind-v4` · `tailwind-v3` · `dtcg` · `json` · `all` | `css` | Serialiser. `all` writes every format into `--out` as a directory. |
137
137
  | `--color-format` | `oklch` · `hex` · `rgb` · `hsl` | `oklch` | How literal colour values are printed. |
138
138
  | `--out <path>` | — | stdout | File to write, or a directory when `--format all`. |
139
- | `--replace-palette` | flag | off | `tailwind-v4` only — see [Overriding Tailwind's palette](#overriding-tailwinds-palette). |
139
+ | `--no-replace-palette` | flag | off | `tailwind-v4` only — keep Tailwind's stock palette. See [Overriding Tailwind's palette](#overriding-tailwinds-palette). |
140
140
  | `--no-provenance` | flag | off | Omit the `Generated by …` header. |
141
- | `--vanilla` | flag | — | Accepted and ignored; removed in 0.3. See [Migrating from 0.1](#migrating-from-01). |
141
+ | `--vanilla` | flag | — | Accepted and ignored; removed in 0.4. |
142
+ | `--replace-palette` | flag | — | Accepted and ignored; this is the default from 0.3. |
142
143
 
143
144
  File names under `--format all`: `tokens.css`, `tailwind.css`, `tailwind.config.js`, `tokens.dtcg.json`, `tokens.json`.
144
145
 
@@ -209,15 +210,19 @@ Verified against a real Tailwind v4 compile and in a browser: `bg-primary` and `
209
210
 
210
211
  The generated ramps deliberately override Tailwind's stock ones, so `text-red-500` is the project's red. The instinct is to withhold primitives so people are pushed toward semantics, but that is the wrong failure mode: if a project does not own `--color-red-500`, then `text-red-500` yields Tailwind's stock red — off-brand, compiles cleanly, looks deliberate in review, and survives a re-theme. Emitting them makes the accident harmless.
211
212
 
212
- That covers only the ramps the generator emits, leaving ~17 stock hues, so `bg-slate-900` stays off-brand and available. `--replace-palette` clears the whole namespace:
213
+ Overriding only the ramps the generator emits would leave ~17 stock hues intact, so `bg-slate-900` would stay available and off-brand. **From 0.3 the generated theme clears the whole namespace by default:**
213
214
 
214
215
  ```css
215
216
  @theme static { --color-*: initial; }
216
217
  ```
217
218
 
218
- Any stock colour class then fails to compile rather than compiling wrong. It is off by default because it would break a project adopting the generator into an existing Tailwind codebase.
219
+ Any colour class the file does not define then fails to compile rather than rendering wrong. That is the point: an off-brand class becomes a build error you fix, instead of a shade nobody chose that reviews cleanly and survives a re-theme.
219
220
 
220
- ## Migrating from 0.1
221
+ The reset is emitted before the definitions, so it clears Tailwind's palette without touching the one just defined. Verified against a real compile: `bg-primary`, `bg-primary-500`, `bg-red-500` (the project's red) and `bg-black`/`bg-white` all compile, `bg-slate-900` fails. Tailwind's `transparent`, `current` and `inherit` are **not** part of the `--color-*` theme namespace, so `bg-transparent` and `text-current` keep working.
222
+
223
+ Pass `--no-replace-palette` when adopting the generator into an existing Tailwind codebase that still uses stock hues — otherwise every `bg-slate-*` in the project stops compiling at once.
224
+
225
+ ## Migrating from 0.1 / 0.2
221
226
 
222
227
  0.2 changes generated output. Existing projects will see their drift checks fail once; regenerate to adopt.
223
228
 
@@ -229,6 +234,7 @@ Any stock colour class then fails to compile rather than compiling wrong. It is
229
234
  | `tailwind-v4` restructured | Regenerate. The dark selector is now `[data-theme="dark"], .dark` rather than `.dark` alone, and there is now a `prefers-color-scheme` fallback matching the css export. |
230
235
  | `tailwind-v4` primitives renamed | `--primary-500` → `--color-primary-500`, matching the css export. Update any direct references. |
231
236
  | Output carries a provenance header | Expected. `--no-provenance` opts out. |
237
+ | **0.3:** `tailwind-v4` clears Tailwind's stock palette by default | Stock hues like `bg-slate-900` now fail to compile. Intended — see above. Pass `--no-replace-palette` to keep them, and `--replace-palette` is now a no-op. |
232
238
  | A seed outside 15–98% lightness no longer inverts the ramp | Bug fix. A near-black or near-white seed was reproduced exactly at its anchor while its neighbours were clamped, so 500 could come out darker than 600. The range now widens to admit the seed; the tight side collapses onto it instead. Only affects seeds outside that range. |
233
239
 
234
240
  The plain-CSS, `tailwind-v3` and `dtcg` outputs are otherwise unchanged apart from the header and the removed aliases.
@@ -1086,7 +1086,7 @@ function emitTailwindV4Mode(tokens, mode, colorFormat, shadeOverrides, aliases,
1086
1086
  lines.push(...emitThemeRebinding(aliases, indent));
1087
1087
  return lines;
1088
1088
  }
1089
- function exportToTailwindV4(tokens, colorFormat = "hex", shadeOverrides, replacePalette = false, sections, shades) {
1089
+ function exportToTailwindV4(tokens, colorFormat = "hex", shadeOverrides, replacePalette = true, sections, shades) {
1090
1090
  const lines = [];
1091
1091
  const active = resolveShades(shades);
1092
1092
  const want = sectionSet(sections);
@@ -1095,7 +1095,8 @@ function exportToTailwindV4(tokens, colorFormat = "hex", shadeOverrides, replace
1095
1095
  const wantModes = aliases.length > 0;
1096
1096
  lines.push("@theme static {");
1097
1097
  if (replacePalette) {
1098
- lines.push(" /* Clear Tailwind's stock palette \u2014 undefined colour classes now fail to compile */");
1098
+ lines.push(" /* Clear Tailwind's stock palette, so a colour class this file does not");
1099
+ lines.push(" define fails to compile instead of silently rendering off-brand. */");
1099
1100
  lines.push(" --color-*: initial;");
1100
1101
  lines.push("");
1101
1102
  }
@@ -1316,7 +1317,7 @@ function selectTokenSections(tokens, sections) {
1316
1317
  function exportTokens(tokens, format, options) {
1317
1318
  const colorFormat = options?.colorFormat ?? "hex";
1318
1319
  const shadeOverrides = options?.shadeOverrides;
1319
- const replacePalette = options?.replacePalette === true;
1320
+ const replacePalette = options?.replacePalette !== false;
1320
1321
  const sections = options?.sections;
1321
1322
  const shades = options?.shades;
1322
1323
  if (sections && sections.length > 0 && !SECTIONED_FORMATS.includes(format)) {
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  selectTokenSections,
19
19
  snapShade,
20
20
  withJsonProvenance
21
- } from "./chunk-757P7AQA.js";
21
+ } from "./chunk-3OG7U5V2.js";
22
22
 
23
23
  // src/cli.ts
24
24
  import { parseArgs } from "util";
@@ -80,10 +80,14 @@ Output:
80
80
  switch off are gone in 0.2, so vanilla is now the only
81
81
  behaviour. Kept for one version so existing calls do not
82
82
  break; it will be removed in 0.3.
83
- --replace-palette tailwind-v4 only: clear Tailwind's stock colour palette
84
- (--color-*: initial), so a colour class this tool does not
85
- define fails to compile instead of compiling off-brand.
86
- Breaks existing Tailwind codebases. Default: off.
83
+ --no-replace-palette tailwind-v4 only: keep Tailwind's stock colour palette.
84
+ By default the generated theme clears it
85
+ (--color-*: initial), so a colour class this tool does
86
+ not define fails to compile rather than silently
87
+ rendering off-brand. Pass this when adopting the
88
+ generator into an existing Tailwind codebase that still
89
+ uses stock hues like bg-slate-900.
90
+ --replace-palette Accepted and ignored; this is the default in 0.3.
87
91
  --no-provenance Omit the "Generated by \u2026" header. The header is what
88
92
  makes --check able to distinguish a generator upgrade
89
93
  from a hand edit, so dropping it costs you that.
@@ -143,6 +147,7 @@ try {
143
147
  out: { type: "string" },
144
148
  vanilla: { type: "boolean" },
145
149
  "replace-palette": { type: "boolean" },
150
+ "no-replace-palette": { type: "boolean" },
146
151
  seed: { type: "string" },
147
152
  check: { type: "boolean" },
148
153
  report: { type: "boolean" },
@@ -312,7 +317,7 @@ if (shades) {
312
317
  }
313
318
  }
314
319
  }
315
- var replacePalette = values["replace-palette"] === true;
320
+ var replacePalette = values["no-replace-palette"] !== true;
316
321
  var resolvedSeed = {
317
322
  primaryColor: primary,
318
323
  neutralColor: neutral,
package/dist/index.d.ts CHANGED
@@ -423,9 +423,10 @@ interface ExportOptions {
423
423
  colorFormat?: ColorFormat;
424
424
  shadeOverrides?: SemanticShadeOverrides;
425
425
  /**
426
- * Clear Tailwind's stock colour palette in the tailwind-v4 export, so any
427
- * colour class the generator does not define fails to compile rather than
428
- * compiling off-brand. Default: false.
426
+ * Clear Tailwind's stock colour palette in the tailwind-v4 export, so a colour
427
+ * class the generator does not define fails to compile rather than compiling
428
+ * off-brand. Default: true. Set false to keep the stock hues available, which
429
+ * an existing Tailwind codebase adopting the generator will need.
429
430
  */
430
431
  replacePalette?: boolean;
431
432
  /**
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  snapShade,
50
50
  stableStringify,
51
51
  withJsonProvenance
52
- } from "./chunk-757P7AQA.js";
52
+ } from "./chunk-3OG7U5V2.js";
53
53
  export {
54
54
  DEFAULT_NEUTRAL_COLOR,
55
55
  DEFAULT_SEED_SHADE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designtools/tokens",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Headless colour token generation from brand colours: OKLCH primitive scales, contrast-checked semantic intents, light/dark modes, and serialisers for CSS custom properties (lead), Tailwind v4 (@theme static) and v3, and DTCG. Pure TypeScript, deterministic.",
5
5
  "type": "module",
6
6
  "license": "CC-BY-NC-4.0",