@phcdevworks/spectre-tokens 3.5.0 → 4.1.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 +89 -119
- package/dist/index.cjs +417 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +321 -0
- package/dist/index.d.cts +403 -25
- package/dist/index.d.ts +403 -25
- package/dist/index.js +417 -62
- package/dist/index.js.map +1 -1
- package/dist/tokens.dtcg.json +1354 -0
- package/package.json +13 -14
- package/tokens/palette.json +341 -1
- package/tokens/typography.json +91 -40
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# @phcdevworks/spectre-tokens
|
|
2
2
|
|
|
3
|
-
`@phcdevworks/spectre-tokens` is the design-token package of the Spectre
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
`@phcdevworks/spectre-tokens` is the design-token package of the Spectre system.
|
|
4
|
+
It provides a complete, UI-ready token surface for downstream Spectre packages
|
|
5
|
+
and compatible applications.
|
|
6
6
|
|
|
7
7
|
Maintained by [PHCDevworks](https://go.phcdev.co). It defines the visual
|
|
8
|
-
language, semantic roles, and token contracts that downstream consumers can
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
language, semantic roles, and token contracts that downstream consumers can rely
|
|
9
|
+
on without filling gaps with raw palette values or local token inventions.
|
|
10
|
+
Downstream UI packages define structure; adapter packages translate Spectre
|
|
11
|
+
contracts for specific frameworks and runtimes.
|
|
12
12
|
|
|
13
13
|
## Repository Snapshot
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ translate Spectre contracts for specific frameworks and runtimes.
|
|
|
17
17
|
| Project team | `project-design` |
|
|
18
18
|
| Repository role | Spectre L1 design-token contract |
|
|
19
19
|
| Package/artifact | `@phcdevworks/spectre-tokens` |
|
|
20
|
-
| Current version/status |
|
|
20
|
+
| Current version/status | 4.1.0 |
|
|
21
21
|
|
|
22
22
|
## Standard Workflow
|
|
23
23
|
|
|
@@ -30,17 +30,18 @@ translate Spectre contracts for specific frameworks and runtimes.
|
|
|
30
30
|
|
|
31
31
|
## Documentation Map
|
|
32
32
|
|
|
33
|
-
| Guide
|
|
34
|
-
|
|
|
35
|
-
| Agent rules
|
|
36
|
-
| Claude Code
|
|
37
|
-
| Codex
|
|
38
|
-
| Copilot
|
|
39
|
-
| Jules
|
|
40
|
-
| Roadmap
|
|
41
|
-
| Todo
|
|
42
|
-
|
|
|
43
|
-
|
|
|
33
|
+
| Guide | Path |
|
|
34
|
+
| --------------- | ---------------------------------------- |
|
|
35
|
+
| Agent rules | [AGENTS.md](AGENTS.md) |
|
|
36
|
+
| Claude Code | [CLAUDE.md](CLAUDE.md) |
|
|
37
|
+
| Codex | [CODEX.md](CODEX.md) |
|
|
38
|
+
| Copilot | [COPILOT.md](COPILOT.md) |
|
|
39
|
+
| Jules | [JULES.md](JULES.md) |
|
|
40
|
+
| Roadmap | [ROADMAP.md](ROADMAP.md) |
|
|
41
|
+
| Todo | [TODO.md](TODO.md) |
|
|
42
|
+
| Token reference | [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md) |
|
|
43
|
+
| Changelog | [CHANGELOG.md](CHANGELOG.md) |
|
|
44
|
+
| Security | [SECURITY.md](SECURITY.md) |
|
|
44
45
|
|
|
45
46
|
[](https://www.npmjs.com/package/@phcdevworks/spectre-tokens)
|
|
46
47
|
[](https://github.com/phcdevworks/spectre-tokens/actions/workflows/ci.yml)
|
|
@@ -61,7 +62,7 @@ and runtimes.
|
|
|
61
62
|
[Changelog](CHANGELOG.md) | [Token Contract](TOKEN_CONTRACT.md) |
|
|
62
63
|
[Roadmap](ROADMAP.md) | [Security Policy](SECURITY.md)
|
|
63
64
|
|
|
64
|
-
## Source
|
|
65
|
+
## Source Of Truth
|
|
65
66
|
|
|
66
67
|
`tokens/` is the source of truth. `contract.manifest.json` is the
|
|
67
68
|
machine-readable contract authority. Everything else is derived from them or
|
|
@@ -78,17 +79,16 @@ validated against them.
|
|
|
78
79
|
After any source change: run `npm run build` to regenerate outputs, then
|
|
79
80
|
`npm run check` to validate the full contract.
|
|
80
81
|
|
|
81
|
-
## What
|
|
82
|
+
## What This Package Owns
|
|
82
83
|
|
|
83
84
|
- Visual language expressed as token data in `tokens/`
|
|
84
85
|
- Semantic roles and token contracts consumed downstream
|
|
85
|
-
- Generated token outputs for JavaScript, TypeScript, CSS variables, and
|
|
86
|
-
Tailwind theme exports
|
|
86
|
+
- Generated token outputs for JavaScript, TypeScript, CSS variables, and DTCG
|
|
87
87
|
- Theme and mode definitions used by downstream consumers
|
|
88
88
|
|
|
89
89
|
This package is the correct place to define token meaning.
|
|
90
90
|
|
|
91
|
-
## What
|
|
91
|
+
## What This Package Does Not Own
|
|
92
92
|
|
|
93
93
|
- Component structure or composition. That belongs in downstream UI packages
|
|
94
94
|
such as
|
|
@@ -100,17 +100,17 @@ This package is the correct place to define token meaning.
|
|
|
100
100
|
- Example app architecture. The `example/` directory documents token usage; it
|
|
101
101
|
is not the contract source and should not become a downstream UI layer.
|
|
102
102
|
|
|
103
|
-
## When
|
|
103
|
+
## When To Use This Package
|
|
104
104
|
|
|
105
105
|
- You are building a Spectre ecosystem package and need the visual language
|
|
106
106
|
contract.
|
|
107
|
-
- You need design token values in JavaScript, TypeScript, CSS variables, or
|
|
108
|
-
|
|
107
|
+
- You need design token values in JavaScript, TypeScript, CSS variables, or DTCG
|
|
108
|
+
format.
|
|
109
109
|
- You want a single source of truth for semantic roles: `surface`, `text`,
|
|
110
110
|
`component`, `buttons`, `forms`, `modes`.
|
|
111
111
|
- You are consuming tokens as named values, not inventing new token meaning.
|
|
112
112
|
|
|
113
|
-
## When
|
|
113
|
+
## When Not To Use This Package
|
|
114
114
|
|
|
115
115
|
- You need UI components or component structure — use
|
|
116
116
|
[`@phcdevworks/spectre-ui`](https://github.com/phcdevworks/spectre-ui).
|
|
@@ -126,7 +126,7 @@ This package is the correct place to define token meaning.
|
|
|
126
126
|
npm install @phcdevworks/spectre-tokens
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
## Quick
|
|
129
|
+
## Quick Start
|
|
130
130
|
|
|
131
131
|
### CSS import
|
|
132
132
|
|
|
@@ -152,21 +152,7 @@ const card = {
|
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
Use the generated Tailwind preset when you want the package to populate theme
|
|
158
|
-
values from the token contract:
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
// tailwind.config.ts
|
|
162
|
-
import { tailwindPreset } from '@phcdevworks/spectre-tokens'
|
|
163
|
-
|
|
164
|
-
export default {
|
|
165
|
-
presets: [tailwindPreset]
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Semantic tokens vs raw palette tokens
|
|
155
|
+
## Semantic Tokens Vs Raw Palette Tokens
|
|
170
156
|
|
|
171
157
|
Semantic tokens express UI meaning. Raw palette tokens expose the fixed color
|
|
172
158
|
ramp. Always prefer semantic tokens for UI surfaces, text, buttons, forms, and
|
|
@@ -174,15 +160,15 @@ mode-aware styling.
|
|
|
174
160
|
|
|
175
161
|
### Semantic namespaces (prefer for all UI work)
|
|
176
162
|
|
|
177
|
-
| Namespace | What it expresses
|
|
178
|
-
| ----------- |
|
|
163
|
+
| Namespace | What it expresses |
|
|
164
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
179
165
|
| `surface` | Background roles: page, card, input, overlay, subtle, hero (gradient, hero sections only), hover, selected, active, divider |
|
|
180
|
-
| `text` | Foreground roles: default, muted, subtle, meta, on-surface, on-page
|
|
181
|
-
| `component` | Role-specific tokens for icon boxes, badges, ratings, testimonials, pricing cards, nav, modal, toast, tooltip, dropdown
|
|
182
|
-
| `buttons` | Button state tokens: default, hover, active, disabled, CTA
|
|
183
|
-
| `forms` | Form state tokens: default, focused, error, disabled
|
|
184
|
-
| `link` | Inline link color roles: default, hover, active, visited
|
|
185
|
-
| `modes` | Mode-aware overrides under `modes.default` and `modes.dark`
|
|
166
|
+
| `text` | Foreground roles: default, muted, subtle, meta, on-surface, on-page |
|
|
167
|
+
| `component` | Role-specific tokens for icon boxes, badges, ratings, testimonials, pricing cards, nav, modal, toast, tooltip, dropdown |
|
|
168
|
+
| `buttons` | Button state tokens: default, hover, active, disabled, CTA |
|
|
169
|
+
| `forms` | Form state tokens: default, focused, error, disabled |
|
|
170
|
+
| `link` | Inline link color roles: default, hover, active, visited |
|
|
171
|
+
| `modes` | Mode-aware overrides under `modes.default` and `modes.dark` |
|
|
186
172
|
|
|
187
173
|
```ts
|
|
188
174
|
import tokens from '@phcdevworks/spectre-tokens'
|
|
@@ -216,7 +202,7 @@ const chart = {
|
|
|
216
202
|
|
|
217
203
|
Do not use `colors` as a substitute for semantic tokens in normal UI surfaces.
|
|
218
204
|
|
|
219
|
-
## Consumer
|
|
205
|
+
## Consumer Usage
|
|
220
206
|
|
|
221
207
|
### JavaScript and TypeScript tokens
|
|
222
208
|
|
|
@@ -235,14 +221,10 @@ const card = {
|
|
|
235
221
|
}
|
|
236
222
|
```
|
|
237
223
|
|
|
238
|
-
Use named exports when you need generated helpers
|
|
224
|
+
Use named exports when you need generated helpers:
|
|
239
225
|
|
|
240
226
|
```ts
|
|
241
|
-
import tokens, {
|
|
242
|
-
generateCssVariables,
|
|
243
|
-
tailwindPreset,
|
|
244
|
-
tailwindTheme
|
|
245
|
-
} from '@phcdevworks/spectre-tokens'
|
|
227
|
+
import tokens, { generateCssVariables } from '@phcdevworks/spectre-tokens'
|
|
246
228
|
|
|
247
229
|
const css = generateCssVariables(tokens)
|
|
248
230
|
```
|
|
@@ -264,41 +246,33 @@ CSS variable contract.
|
|
|
264
246
|
.app-shell {
|
|
265
247
|
width: var(--sp-layout-sidebar-width);
|
|
266
248
|
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
The CSS entry point is intended for consumers that want the token contract as
|
|
270
|
-
variables rather than reading values in JavaScript.
|
|
271
|
-
|
|
272
|
-
### Tailwind preset
|
|
273
249
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
250
|
+
h1 {
|
|
251
|
+
font-family: var(--sp-heading-h1-family);
|
|
252
|
+
font-size: var(--sp-heading-h1-size);
|
|
253
|
+
line-height: var(--sp-heading-h1-line-height);
|
|
254
|
+
font-weight: var(--sp-heading-h1-weight);
|
|
255
|
+
letter-spacing: var(--sp-heading-h1-letter-spacing);
|
|
256
|
+
}
|
|
279
257
|
|
|
280
|
-
|
|
281
|
-
|
|
258
|
+
body {
|
|
259
|
+
font-family: var(--sp-body-family);
|
|
260
|
+
font-size: var(--sp-body-size);
|
|
261
|
+
line-height: var(--sp-body-line-height);
|
|
262
|
+
font-weight: var(--sp-body-weight);
|
|
263
|
+
letter-spacing: var(--sp-body-letter-spacing);
|
|
282
264
|
}
|
|
283
265
|
```
|
|
284
266
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
The generated Tailwind theme includes the layout width mappings
|
|
289
|
-
`maxWidth.container`, `maxWidth.prose`, and `width.sidebar`, derived from
|
|
290
|
-
`layout.container.maxWidth`, `layout.container.maxWidthProse`, and
|
|
291
|
-
`layout.sidebar.width`.
|
|
267
|
+
The CSS entry point is intended for consumers that want the token contract as
|
|
268
|
+
variables rather than reading values in JavaScript.
|
|
292
269
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
```
|
|
270
|
+
`typography.heading.{h1..h6}` and `typography.body` are semantic role tokens —
|
|
271
|
+
each a complete
|
|
272
|
+
`{ fontFamily, fontSize, lineHeight, fontWeight, letterSpacing }` object
|
|
273
|
+
referencing `typography.scale.*` and `typography.families.*` — so downstream
|
|
274
|
+
consumers get a heading/body contract instead of hand-picking a raw
|
|
275
|
+
`typography.scale` step per heading level.
|
|
302
276
|
|
|
303
277
|
### Token model
|
|
304
278
|
|
|
@@ -332,12 +306,15 @@ The exported runtime token object is a flattened string-based tree generated
|
|
|
332
306
|
from `tokens/`. Source-only wrapper fields such as `value` and `metadata` are
|
|
333
307
|
internal generation details and are not part of the public package contract.
|
|
334
308
|
|
|
309
|
+
See [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md) for the exhaustive, generated
|
|
310
|
+
list of every token path, resolved value, and usage note.
|
|
311
|
+
|
|
335
312
|
The `layout` namespace includes section, stack, and container spacing tokens,
|
|
336
313
|
plus fixed layout width tokens for common consumer shells:
|
|
337
314
|
`layout.container.maxWidth`, `layout.container.maxWidthProse`, and
|
|
338
315
|
`layout.sidebar.width`.
|
|
339
316
|
|
|
340
|
-
## Public
|
|
317
|
+
## Public Contract Guarantees
|
|
341
318
|
|
|
342
319
|
`contract.manifest.json` is the machine-readable contract authority for this
|
|
343
320
|
package.
|
|
@@ -345,7 +322,7 @@ package.
|
|
|
345
322
|
It defines:
|
|
346
323
|
|
|
347
324
|
- public namespaces
|
|
348
|
-
- required output surfaces for JavaScript, CSS, and
|
|
325
|
+
- required output surfaces for JavaScript, CSS, and DTCG
|
|
349
326
|
- protected semantic groups
|
|
350
327
|
|
|
351
328
|
Every contract-facing surface in this repository must match that manifest.
|
|
@@ -374,7 +351,7 @@ Guidance:
|
|
|
374
351
|
- Do not invent local light/dark token contracts when this package already
|
|
375
352
|
provides the semantic path.
|
|
376
353
|
|
|
377
|
-
## Protected
|
|
354
|
+
## Protected Token Families
|
|
378
355
|
|
|
379
356
|
The following semantic groups are locked. Their values must not change without
|
|
380
357
|
explicit approval from Bradley Potts. This applies to all contributors and all
|
|
@@ -391,7 +368,7 @@ AI agents — apparent visual improvements still require human sign-off.
|
|
|
391
368
|
recorded baseline. An intentional change requires updating the baseline as part
|
|
392
369
|
of an approved, classified release.
|
|
393
370
|
|
|
394
|
-
## Downstream
|
|
371
|
+
## Downstream Boundaries
|
|
395
372
|
|
|
396
373
|
Downstream packages should never redefine locally:
|
|
397
374
|
|
|
@@ -406,7 +383,7 @@ Downstream packages may:
|
|
|
406
383
|
- map these tokens into framework-specific delivery
|
|
407
384
|
- use raw palette values when the usage is intentionally non-semantic
|
|
408
385
|
|
|
409
|
-
## Upgrade
|
|
386
|
+
## Upgrade Expectations For Consumers
|
|
410
387
|
|
|
411
388
|
Consumers should treat this package as a SemVer-governed contract.
|
|
412
389
|
|
|
@@ -415,7 +392,7 @@ Practical guidance:
|
|
|
415
392
|
- additive token paths are intended to be safe for existing consumers
|
|
416
393
|
- semantic shifts may keep the same path but still affect visual meaning
|
|
417
394
|
- renames and removals are breaking
|
|
418
|
-
- generated JS, TS, CSS, and
|
|
395
|
+
- generated JS, TS, CSS, and DTCG outputs are expected to stay aligned
|
|
419
396
|
|
|
420
397
|
If a downstream package depends on specific token paths or semantic meaning:
|
|
421
398
|
|
|
@@ -436,27 +413,21 @@ with a `Contract change type:` line before release.
|
|
|
436
413
|
|
|
437
414
|
Renames and removals are always breaking regardless of perceived scope.
|
|
438
415
|
|
|
439
|
-
## Package
|
|
416
|
+
## Package Exports / API Surface
|
|
440
417
|
|
|
441
418
|
### Root package
|
|
442
419
|
|
|
443
420
|
`@phcdevworks/spectre-tokens` exports:
|
|
444
421
|
|
|
445
422
|
- `default` / `tokens`
|
|
446
|
-
- `tailwindTheme`
|
|
447
|
-
- `tailwindPreset`
|
|
448
423
|
- `generateCssVariables`
|
|
449
|
-
- TypeScript types including `SpectreTokens`, `
|
|
450
|
-
`
|
|
424
|
+
- TypeScript types including `SpectreTokens`, `SpectreModeTokens`, and
|
|
425
|
+
`SpectreModeName`
|
|
451
426
|
|
|
452
427
|
Example:
|
|
453
428
|
|
|
454
429
|
```ts
|
|
455
|
-
import tokens, {
|
|
456
|
-
generateCssVariables,
|
|
457
|
-
tailwindPreset,
|
|
458
|
-
tailwindTheme
|
|
459
|
-
} from '@phcdevworks/spectre-tokens'
|
|
430
|
+
import tokens, { generateCssVariables } from '@phcdevworks/spectre-tokens'
|
|
460
431
|
|
|
461
432
|
const css = generateCssVariables(tokens, {
|
|
462
433
|
selector: ':root',
|
|
@@ -468,27 +439,26 @@ const css = generateCssVariables(tokens, {
|
|
|
468
439
|
|
|
469
440
|
- `@phcdevworks/spectre-tokens/index.css`
|
|
470
441
|
|
|
471
|
-
## Relationship
|
|
442
|
+
## Relationship To The Rest Of Spectre
|
|
472
443
|
|
|
473
444
|
Spectre keeps responsibilities separate:
|
|
474
445
|
|
|
475
446
|
- [`@phcdevworks/spectre-tokens`](https://github.com/phcdevworks/spectre-tokens)
|
|
476
447
|
defines visual language, semantic roles, and token contracts
|
|
477
448
|
- [`@phcdevworks/spectre-ui`](https://github.com/phcdevworks/spectre-ui) turns
|
|
478
|
-
those contracts into reusable CSS,
|
|
449
|
+
those contracts into reusable CSS, utility tooling, and shared styling
|
|
479
450
|
behavior
|
|
480
451
|
- Adapter packages translate Spectre contracts for framework-specific delivery
|
|
481
452
|
|
|
482
453
|
That separation keeps token meaning centralized while letting the package system
|
|
483
454
|
expand by responsibility.
|
|
484
455
|
|
|
485
|
-
## Consumer
|
|
456
|
+
## Consumer Checklist
|
|
486
457
|
|
|
487
458
|
For downstream packages and compatible apps:
|
|
488
459
|
|
|
489
460
|
- import tokens from the package root when you need runtime values
|
|
490
461
|
- import `index.css` when you need generated CSS variables
|
|
491
|
-
- use `tailwindPreset` when you need Tailwind theme integration
|
|
492
462
|
- prefer semantic namespaces for UI behavior
|
|
493
463
|
- use raw palette values only when fixed palette access is intentional
|
|
494
464
|
- treat `tokens/` as source of truth and generated outputs as derived
|
|
@@ -503,14 +473,14 @@ npm install
|
|
|
503
473
|
npm run check
|
|
504
474
|
```
|
|
505
475
|
|
|
506
|
-
This project expects Node.js `^22.12.0 || >=24.0.0` and npm `
|
|
476
|
+
This project expects Node.js `^22.12.0 || >=24.0.0` and npm `12.0.1`.
|
|
507
477
|
|
|
508
478
|
### Common commands
|
|
509
479
|
|
|
510
480
|
| Command | What it does |
|
|
511
481
|
| ------------------------ | ------------------------------------------------------------ |
|
|
512
482
|
| `npm run build` | Regenerate all outputs — run after any token source change |
|
|
513
|
-
| `npm run check` | Full validation gate —
|
|
483
|
+
| `npm run check` | Full validation gate — every step must pass before commit |
|
|
514
484
|
| `npm run lint` | Run ESLint against all source files |
|
|
515
485
|
| `npm run format` | Apply Prettier formatting to all files |
|
|
516
486
|
| `npm run generate` | Regenerate `src/generated/tokens.ts` from token sources only |
|
|
@@ -544,17 +514,17 @@ treated as downstream UI primitives.
|
|
|
544
514
|
| `check:docs` fails | README or TOKEN_CONTRACT.md has drifted from the manifest | Update the doc to match the current contract |
|
|
545
515
|
| `check:classification` fails | A contract-authority file changed without a classification entry | Add `Contract change type: additive`, `semantic change`, or `breaking` to `CHANGELOG.md [Unreleased]` |
|
|
546
516
|
|
|
547
|
-
## AI
|
|
517
|
+
## AI And Automation Boundaries
|
|
548
518
|
|
|
549
519
|
Claude Code (`claude-sonnet-4-6`) is the primary development agent for this
|
|
550
|
-
repository. Codex handles releases and production stabilization
|
|
551
|
-
|
|
552
|
-
development support.
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
520
|
+
repository. Codex handles releases and production stabilization, including
|
|
521
|
+
cutting tagged releases and GitHub Releases. Jules handles small automated fixes
|
|
522
|
+
and generated-output sync. GitHub Copilot provides development support.
|
|
523
|
+
|
|
524
|
+
All AI agents with repository access (Claude Code, Codex, Copilot, Jules) have
|
|
525
|
+
commit, push, and tag authority in this repository. Publishing to npm remains
|
|
526
|
+
Bradley Potts's sole authority. See [AGENTS.md](AGENTS.md) for the full
|
|
527
|
+
commit-policy and release-authority grant.
|
|
558
528
|
|
|
559
529
|
**Protected from automated change:** locked color families (`success`,
|
|
560
530
|
`warning`, `danger`, CTA/brand-action), `contract.manifest.json`, and
|