@phcdevworks/spectre-tokens 4.10.0 → 4.12.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
@@ -17,7 +17,7 @@ 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 | 4.10.0 |
20
+ | Current version/status | 4.12.0 |
21
21
 
22
22
  ## Standard Workflow
23
23
 
@@ -30,18 +30,20 @@ contracts for specific frameworks and runtimes.
30
30
 
31
31
  ## Documentation Map
32
32
 
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) |
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
+ | Grok | [GROK.md](GROK.md) |
41
+ | Roadmap | [ROADMAP.md](ROADMAP.md) |
42
+ | Todo | [TODO.md](TODO.md) |
43
+ | Token reference | [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md) |
44
+ | Downstream parity | [DOWNSTREAM_PARITY.md](DOWNSTREAM_PARITY.md) |
45
+ | Changelog | [CHANGELOG.md](CHANGELOG.md) |
46
+ | Security | [SECURITY.md](SECURITY.md) |
45
47
 
46
48
  [![npm version](https://img.shields.io/npm/v/@phcdevworks/spectre-tokens)](https://www.npmjs.com/package/@phcdevworks/spectre-tokens)
47
49
  [![CI](https://github.com/phcdevworks/spectre-tokens/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/phcdevworks/spectre-tokens/actions/workflows/ci.yml)
@@ -262,17 +264,80 @@ body {
262
264
  font-weight: var(--sp-body-weight);
263
265
  letter-spacing: var(--sp-body-letter-spacing);
264
266
  }
267
+
268
+ .hero-title {
269
+ font-size: var(--sp-display-1-size);
270
+ line-height: var(--sp-display-1-line-height);
271
+ font-weight: var(--sp-display-1-weight);
272
+ }
273
+
274
+ .intro {
275
+ font-size: var(--sp-lead-size);
276
+ line-height: var(--sp-lead-line-height);
277
+ }
278
+
279
+ input {
280
+ background: var(--sp-form-default-bg);
281
+ color: var(--sp-form-default-text);
282
+ }
265
283
  ```
266
284
 
267
285
  The CSS entry point is intended for consumers that want the token contract as
268
286
  variables rather than reading values in JavaScript.
269
287
 
270
- `typography.heading.{h1..h6}` and `typography.body` are semantic role tokens —
271
- each a complete
288
+ `typography.heading.{h1..h6}`, `typography.body`, `typography.display.{1..6}`,
289
+ and `typography.lead` are semantic role tokens — each a complete
272
290
  `{ fontFamily, fontSize, lineHeight, fontWeight, letterSpacing }` object
273
291
  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.
292
+ consumers get a text-role contract instead of hand-picking a raw
293
+ `typography.scale` step per heading level. Each role emits
294
+ `--sp-<role>-{family,size,line-height,weight,letter-spacing}` (for example
295
+ `--sp-heading-h1-size`, `--sp-display-1-size`, `--sp-lead-size`).
296
+
297
+ `--sp-form-default-{bg,text,placeholder}` are redeclared in the
298
+ `[data-spectre-theme="dark"]` block from `modes.dark.forms.default.*`, so they
299
+ follow the active mode. Other `forms.*` variables, including
300
+ `--sp-form-default-border`, keep their `:root` value in every mode, except
301
+ that high-contrast mode overrides `forms.valid.*` and `forms.invalid.*`.
302
+
303
+ Color modes apply wherever the attribute is set, not only on the root.
304
+ `data-spectre-theme="dark"`, `"high-contrast"`, or `"light"` on any element
305
+ switches every mode variable for that element and its descendants, so a
306
+ section can differ from the page (`light` restores default values inside a
307
+ dark ancestor). `data-spectre-theme="system"` follows the visitor's OS setting
308
+ through `prefers-color-scheme`, with no script. A page with no attribute is
309
+ light.
310
+
311
+ `modes.highContrast` is a third mode alongside `default` and `dark`. It is
312
+ light-based, and every text pair in it meets WCAG AAA (7:1). Borders and
313
+ dividers are darkened too. Set `data-spectre-theme="high-contrast"` on the
314
+ root, or on a section, to apply it. Buttons, links, and the valid/invalid form states don't
315
+ change between light and dark, but high-contrast mode overrides them
316
+ (`modes.highContrast.buttons`, `.link`, and `.forms.{valid,invalid}`), so
317
+ those also meet 7:1.
318
+
319
+ `control.{sm,md,lg}` gives the shared height, inline padding, and icon size
320
+ for buttons, inputs, and selects (`--sp-control-md-height`,
321
+ `--sp-control-md-padding-inline`, `--sp-control-md-icon-size`), and
322
+ `control.compact.*` is the denser set. Any element with
323
+ `data-spectre-density="compact"` swaps the default sizes for the compact
324
+ ones inside it. Every height except `lg` is below
325
+ `accessibility.minTouchTarget` (44px), so on touch layouts give smaller
326
+ controls a 44px hit area (for example with padding or a pseudo-element)
327
+ rather than shrinking it to the visible height.
328
+
329
+ `elevation.{flat,raised,overlay,modal}` pairs a shadow with its surface and
330
+ z-index, so consumers pick one level instead of combining raw steps. The
331
+ `--sp-elevation-*` variables are `var()` references to the shadow, surface,
332
+ and z-index variables, so the surface follows the active color mode.
333
+
334
+ `component.chart` is the data-visualization palette: eight categorical
335
+ `series` colors that differ in lightness as well as hue and meet 3:1 against
336
+ `chart.bg`, seven-step `sequential` and `diverging` ramps, and `grid`,
337
+ `axis`, and `label` roles. `component.selection`, `component.caret`,
338
+ `component.scrollbar`, `component.skeleton`, and `component.prose.kbd` cover
339
+ text selection, caret, scrollbar, skeleton-loading, and keycap colors. All of
340
+ them are set for every mode.
276
341
 
277
342
  ### Token model
278
343
 
@@ -302,6 +367,8 @@ The generated token object includes these namespaces:
302
367
  - `component`
303
368
  - `modes`
304
369
  - `tracking`
370
+ - `control`
371
+ - `elevation`
305
372
 
306
373
  The exported runtime token object is a flattened string-based tree generated
307
374
  from `tokens/`. Source-only wrapper fields such as `value` and `metadata` are
@@ -310,11 +377,28 @@ internal generation details and are not part of the public package contract.
310
377
  See [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md) for the exhaustive, generated list
311
378
  of every token path, resolved value, and usage note.
312
379
 
380
+ Downstream packages building recipes on the CSS output should use
381
+ [DOWNSTREAM_PARITY.md](DOWNSTREAM_PARITY.md), which groups every published
382
+ `--sp-*` variable into the family a recipe or stylesheet consumes. Run
383
+ `npm run audit:parity` (optionally `-- <sibling-repo>`) for a checklist of the
384
+ families a checked-out downstream repo has not consumed yet.
385
+
313
386
  The `layout` namespace includes section, stack, and container spacing tokens,
314
387
  plus fixed layout width tokens for common consumer shells:
315
388
  `layout.container.maxWidth`, `layout.container.maxWidthProse`,
316
389
  `layout.container.maxWidthWide`, and `layout.sidebar.width`.
317
390
 
391
+ Layout spacing sits on one 8px grid; `check:structure` fails on any off-grid
392
+ step. Section padding, section gap, stack gap, and container inline padding
393
+ run `sm | md | lg | xl | 2xl | 3xl | 4xl`. `sm`–`lg` are fixed. `xl`–`4xl`
394
+ are responsive: the base value applies on narrow viewports and
395
+ `layout.responsive.lg.*` takes over at the `lg` breakpoint. In CSS, the
396
+ `@media (min-width: 1024px)` block re-points `--sp-layout-*-{xl..4xl}` at
397
+ `--sp-layout-responsive-lg-*`, so consumers keep using one variable name.
398
+ `layout.hero.paddingTop` and `layout.hero.paddingBottom` (`sm | md | lg`)
399
+ reference section padding steps, and their CSS variables are `var()`
400
+ references that follow the responsive override.
401
+
318
402
  ## Public Contract Guarantees
319
403
 
320
404
  `contract.manifest.json` is the machine-readable contract authority for this
@@ -343,8 +427,12 @@ import tokens from '@phcdevworks/spectre-tokens'
343
427
 
344
428
  const darkPage = tokens.modes.dark.surface.page
345
429
  const darkText = tokens.modes.dark.text.onPage.default
430
+ const darkInputBg = tokens.modes.dark.forms.default.bg
346
431
  ```
347
432
 
433
+ Top-level `forms.default.{bg,text,placeholder}` hold the default (light)
434
+ values; read `modes.dark.forms.default.*` for their dark equivalents.
435
+
348
436
  Guidance:
349
437
 
350
438
  - Prefer semantic tokens for theme-aware UI.
@@ -509,7 +597,7 @@ treated as downstream UI primitives.
509
597
  | ---------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
510
598
  | `check:regression` fails | A token value changed vs the recorded baseline | Revert the unintended change, or update the baseline if the change was intentional |
511
599
  | `check:locked` fails | A protected color family was modified | Revert unless Bradley Potts has explicitly approved the change |
512
- | `check:contrast` fails | A text/background token pair does not meet WCAG AA | Adjust the token value or the `metadata.pair` reference in the source JSON |
600
+ | `check:contrast` fails | A token pair is below WCAG AA, AAA in high-contrast mode, or its `minContrast` | Adjust the token value or the `metadata.pair` reference in the source JSON |
513
601
  | `check:dist` fails | Generated dist is out of sync | Run `npm run build` then re-run `npm run check` |
514
602
  | `check:manifest` fails | A namespace exists in outputs but is not declared in `contract.manifest.json` | Add the namespace to the manifest or remove it from the source |
515
603
  | `check:docs` fails | README or TOKEN_CONTRACT.md has drifted from the manifest | Update the doc to match the current contract |