@designtools/tokens 0.1.1

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 ADDED
@@ -0,0 +1,57 @@
1
+ # @designtools/tokens
2
+
3
+ Colour token generation from brand colours, as pure TypeScript. `generateTokens({ primary, neutral })` produces a `TokenSystem` — twelve-step OKLCH scales, contrast-checked semantic intents, surfaces, utilities, in light and dark — and `exportTokens(tokens, format)` serialises it, with CSS custom properties as the lead format and Tailwind v3/v4, DTCG, and Lovable as secondary outputs. No browser, DOM, or React.
4
+
5
+ Part of the `@designtools/*` suite; the `designtools-tokens` skill (in `skills/`) drives it at scaffold time.
6
+
7
+ ## Usage
8
+
9
+ Published, the CLI is `generate-tokens`:
10
+
11
+ ```
12
+ npx @designtools/tokens --primary "#4e9caf" # CSS custom properties to stdout
13
+ npx @designtools/tokens --primary "#4e9caf" --vanilla --out tokens.css
14
+ npx @designtools/tokens --primary "#4e9caf" --format all --out ./tokens
15
+ ```
16
+
17
+ From source in this monorepo (no build needed):
18
+
19
+ ```
20
+ npx tsx packages/tokens/src/cli.ts --primary "#4e9caf"
21
+ ```
22
+
23
+ Programmatic:
24
+
25
+ ```ts
26
+ import { generateTokens, exportTokens } from "@designtools/tokens";
27
+
28
+ const tokens = generateTokens({ primary: "#4e9caf", neutral: "#9aa1af" });
29
+ const css = exportTokens(tokens, "css", { colorFormat: "oklch" });
30
+ ```
31
+
32
+ Pass `--vanilla` (or `compat: false`) to omit the shadcn/ui aliases from the `css` and `tailwind-v4` outputs — the right default for Base UI / vanilla-CSS stacks. Full input/output contracts, options, and export formats live in `skills/designtools-tokens/SKILL.md`.
33
+
34
+ ## Layout
35
+
36
+ ```
37
+ src/ types, oklch, primitives, semantic, generate, export, index (barrel), cli
38
+ test/ parity tests, fixture cases, golden fixtures, fixture regenerator
39
+ ```
40
+
41
+ Runtime dependencies: `culori` (colour maths) and `apca-w3` (APCA contrast), both pure JS. Built with tsup to ESM plus a compiled `generate-tokens` bin; `dist/` is produced at build/publish time and is not committed.
42
+
43
+ ## Commands
44
+
45
+ ```
46
+ npm -w packages/tokens run build # tsup -> dist (ESM + generate-tokens bin + .d.ts)
47
+ npm -w packages/tokens run typecheck
48
+ npm -w packages/tokens run cli -- --primary "#4e9caf"
49
+ npm -w packages/tokens run fixtures # regenerate goldens — only when a behaviour change is intended
50
+ npm test # parity tests run in the repo's vitest suite
51
+ ```
52
+
53
+ ## Determinism and parity
54
+
55
+ Same seeds and options always produce byte-identical output — pure arithmetic, no randomness, clocks, or environment reads. `test/` pins that: the generator must reproduce the golden fixtures in `test/fixtures/`, which were generated from the original Colour Token Generator web-tool source. Regenerate them (`run fixtures`) only when a behaviour change is intended.
56
+
57
+ `src/` (except `index.ts` and `cli.ts`) is a verbatim copy of that web tool's library, so the two stay in step; `src/export.ts` is the one deliberate exception, carrying the `compat` toggle behind `--vanilla`, with its own fixtures. This package is the canonical source.