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