@phcdevworks/spectre-tokens 4.12.0 → 4.14.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.12.0 |
20
+ | Current version/status | 4.14.0 |
21
21
 
22
22
  ## Standard Workflow
23
23
 
@@ -166,11 +166,11 @@ mode-aware styling.
166
166
  | ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
167
167
  | `surface` | Background roles: page, card, input, overlay, subtle, hero (gradient, hero sections only), hover, selected, active, divider |
168
168
  | `text` | Foreground roles: default, muted, subtle, meta, on-surface, on-page |
169
- | `component` | Role-specific tokens for navigation, overlays, feedback, data display, loading, forms, cards, badges, and content patterns |
169
+ | `component` | Role-specific tokens for navigation, overlays, feedback, data display, loading, forms, cards, badges, and content patterns |
170
170
  | `buttons` | Button state tokens: default, hover, active, disabled, CTA |
171
171
  | `forms` | Form state tokens: default, focused, error, disabled |
172
172
  | `link` | Inline link color roles: default, hover, active, visited |
173
- | `modes` | Mode-aware overrides under `modes.default` and `modes.dark` |
173
+ | `modes` | Mode-aware overrides under `modes.default`, `modes.dark`, and `modes.highContrast` (plus a CSS-only `light` and `system` mode) |
174
174
 
175
175
  ```ts
176
176
  import tokens from '@phcdevworks/spectre-tokens'
@@ -311,10 +311,16 @@ light.
311
311
  `modes.highContrast` is a third mode alongside `default` and `dark`. It is
312
312
  light-based, and every text pair in it meets WCAG AAA (7:1). Borders and
313
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.
314
+ root, or on a section, to apply it. Buttons and the valid/invalid form
315
+ states don't change between light and dark, but high-contrast mode overrides
316
+ them (`modes.highContrast.buttons` and `.forms.{valid,invalid}`), so those
317
+ also meet 7:1.
318
+
319
+ Links change in every mode. `modes.dark.link` lightens `default`, `hover`,
320
+ `active`, `visited`, and the underline colours so they meet 4.5:1 on dark
321
+ pages and cards, and `modes.highContrast.link` raises them to 7:1.
322
+ `link.onInverse` and `link.onInverseHover` are for `surface.inverse`, so they
323
+ keep the same value in every mode.
318
324
 
319
325
  `control.{sm,md,lg}` gives the shared height, inline padding, and icon size
320
326
  for buttons, inputs, and selects (`--sp-control-md-height`,
@@ -339,6 +345,135 @@ and z-index variables, so the surface follows the active color mode.
339
345
  text selection, caret, scrollbar, skeleton-loading, and keycap colors. All of
340
346
  them are set for every mode.
341
347
 
348
+ ### Type scales
349
+
350
+ There are three ways to set text size, from most to least opinionated:
351
+
352
+ 1. **Text roles** (`--sp-heading-h1-*`, `--sp-display-1-*`, `--sp-body-*`,
353
+ `--sp-lead-*`): size, line height, weight, and letter-spacing for a
354
+ specific job. Use these first.
355
+ 2. **Size presets** `font.{xs…9xl}` (`--sp-font-lg-size`,
356
+ `--sp-font-lg-line-height`, `--sp-font-lg-weight`,
357
+ `--sp-font-lg-letter-spacing`): a size together with the line height and
358
+ weight that suit it. The sizes match Tailwind's scale:
359
+
360
+ | Step | xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl | 7xl | 8xl | 9xl |
361
+ | ---- | -- | -- | -- | -- | -- | --- | --- | --- | --- | --- | --- | --- | --- |
362
+ | px | 12 | 14 | 16 | 18 | 20 | 24 | 30 | 36 | 48 | 60 | 72 | 96 | 128 |
363
+
364
+ `md` is Tailwind's `base`.
365
+ 3. **Plain sizes** `fontSize.{12…128}` (`--sp-font-size-18`): one size with
366
+ no line height or weight attached. Pair them with the scales below.
367
+
368
+ ```css
369
+ .price {
370
+ font-size: var(--sp-font-size-18);
371
+ line-height: var(--sp-leading-snug);
372
+ font-weight: var(--sp-font-weight-semibold);
373
+ letter-spacing: var(--sp-tracking-tight);
374
+ }
375
+
376
+ a {
377
+ text-decoration-color: var(--sp-link-underline);
378
+ text-decoration-thickness: var(--sp-text-decoration-thickness-thin);
379
+ text-underline-offset: var(--sp-text-decoration-offset-md);
380
+ }
381
+ ```
382
+
383
+ | Scale | Steps | CSS variable |
384
+ | --- | --- | --- |
385
+ | `fontWeight` | `normal` 400, `medium` 500, `semibold` 600, `bold` 700, `extrabold` 800, `black` 900 | `--sp-font-weight-*` |
386
+ | `leading` (line height, unitless) | `none` 1, `tight` 1.25, `snug` 1.375, `normal` 1.5, `relaxed` 1.625, `loose` 2 | `--sp-leading-*` |
387
+ | `tracking` (letter-spacing) | `tightest` −0.075em through `widest` 0.1em | `--sp-tracking-*` |
388
+ | `textDecoration` | `thickness.{thin,base,thick}` (1/2/3px), `offset.{sm,md,lg}` (0.125/0.2/0.3em) | `--sp-text-decoration-*` |
389
+
390
+ ### Accent rails
391
+
392
+ A rail is the coloured edge on a card, badge, quote, and similar components.
393
+ Each component that has one carries the same contract under
394
+ `component.<name>.accent`: one colour per tone (`neutral`, `brand`, `info`,
395
+ `success`, `warning`, `danger`, `cta`, `accent`) plus a single `thickness`
396
+ (`0.25rem`). The components are `card`, `badge`, `testimonial`,
397
+ `pricingCard`, `nav`, `footer`, `modal`, `toast`, `tooltip`, `dropdown`,
398
+ `listGroup`, and `quote`. `footer.light` has its own tone colours and uses
399
+ `footer`'s thickness. Every rail colour is mode-aware.
400
+
401
+ ```css
402
+ .card--brand {
403
+ border-inline-start: var(--sp-component-card-accent-thickness) solid
404
+ var(--sp-component-card-accent-brand);
405
+ }
406
+
407
+ .toast--danger {
408
+ border-inline-start: var(--sp-toast-accent-thickness) solid
409
+ var(--sp-toast-accent-danger);
410
+ }
411
+ ```
412
+
413
+ `card` and `input` keep a legacy `component-` segment in their variable
414
+ names. Every other component uses its own name, such as `--sp-badge-accent-*`
415
+ or `--sp-quote-accent-*`. Which edge the rail sits on, and how it's drawn, is
416
+ up to the downstream component.
417
+
418
+ ### Accent and inverse roles
419
+
420
+ `colors.accent` is the second brand colour. It has its own semantic roles, so
421
+ consumers never reach for the raw palette:
422
+
423
+ - `text.onPage.accent` and `text.onSurface.accent` (`--sp-text-on-page-accent`)
424
+ are accent text that passes contrast on the page or a card.
425
+ - `text.onInverse.{default,muted,brand,accent}` is text on dark (inverse)
426
+ backgrounds, such as a dark hero or footer.
427
+ - `buttons.accent` and `buttons.accentOutline` are filled and outlined accent
428
+ buttons. Button variables join camelCase names without hyphens, for example
429
+ `--sp-button-accentoutline-bghover`.
430
+ - `component.stepper.tone.{brand,accent}.{active,done}` colours a stepper in
431
+ either brand colour.
432
+ - `component.quote` covers a quote's text, attribution name and role, an
433
+ accent-coloured quotation mark, a plain border, and an accent rail
434
+ (`--sp-quote-*`).
435
+
436
+ ### Footer
437
+
438
+ `component.footer` is its own contract, separate from navigation: `bg`,
439
+ `text`, `heading`, `muted`, `link`, `linkHover`, `border`, `divider`,
440
+ `chipBg`, and an accent rail (`--sp-footer-*`). It is dark by default.
441
+ `component.footer.light` (`--sp-footer-light-*`) has the same roles for a
442
+ light footer.
443
+
444
+ ### Extended palette
445
+
446
+ `colors.palette` holds the full extended colour ramps (`red` through `stone`,
447
+ `slate`, `zinc`, the `mauve`/`olive`/`mist`/`taupe` neutrals, and the named
448
+ brand and integration colours), emitted as `--sp-color-palette-<name>-<step>`.
449
+ Like `colors`, it is raw palette: use it for data visualisation or a brand
450
+ colour that has no semantic role, not for normal UI.
451
+
452
+ ### HTML element coverage
453
+
454
+ Spectre aims to style every standard HTML element from tokens alone.
455
+ [`element-coverage.json`](element-coverage.json) maps all 115 elements in the
456
+ HTML Living Standard's element index, and 14 styleable pseudo-elements, to
457
+ the token paths that style them. Elements with no visual styling of their own
458
+ (`<div>`, `<meta>`, `<template>`, …) are marked as such, with a reason. The
459
+ `check:elements` step of `npm run check` fails if an element is unmapped or
460
+ mapped to a path that doesn't exist. [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md)
461
+ has the generated table.
462
+
463
+ Element roles include:
464
+
465
+ | Element | Variables |
466
+ | --- | --- |
467
+ | `<del>`, `<ins>`, `<mark>`, `<kbd>`, `<code>`, `<pre>`, `<blockquote>`, `<hr>` | `--sp-prose-*` |
468
+ | `<dt>`, `<dd>` | `--sp-prose-dt-text`, `--sp-prose-dd-text` |
469
+ | `<figcaption>`, `<caption>`, `<tfoot>` | `--sp-prose-figcaption-text`, `--sp-table-caption-text`, `--sp-table-footer-*` |
470
+ | `<meter>` | `--sp-meter-track`, `--sp-meter-fill-{optimum,suboptimum,critical}` |
471
+ | `<option>`, `<optgroup>` | `--sp-select-option-*`, `--sp-select-optgroup-label-text` |
472
+ | `::marker` | `--sp-prose-marker`, `--sp-prose-marker-accent` |
473
+ | `::selection`, `::spelling-error`, `::grammar-error` | `--sp-selection-*`, `--sp-proofing-{spelling,grammar}` |
474
+ | Code highlighting | `--sp-code-syntax-{keyword,string,comment,function,…}` |
475
+ | Article spacing | `--sp-layout-prose-flow-{paragraph,heading,list,…}` |
476
+
342
477
  ### Token model
343
478
 
344
479
  The generated token object includes these namespaces:
@@ -367,6 +502,10 @@ The generated token object includes these namespaces:
367
502
  - `component`
368
503
  - `modes`
369
504
  - `tracking`
505
+ - `leading`
506
+ - `textDecoration`
507
+ - `fontWeight`
508
+ - `fontSize`
370
509
  - `control`
371
510
  - `elevation`
372
511
 
@@ -381,7 +520,10 @@ Downstream packages building recipes on the CSS output should use
381
520
  [DOWNSTREAM_PARITY.md](DOWNSTREAM_PARITY.md), which groups every published
382
521
  `--sp-*` variable into the family a recipe or stylesheet consumes. Run
383
522
  `npm run audit:parity` (optionally `-- <sibling-repo>`) for a checklist of the
384
- families a checked-out downstream repo has not consumed yet.
523
+ families a checked-out downstream repo has not consumed yet, and
524
+ `npm run audit:downstream` for a read-only report of raw `--sp-*`
525
+ redeclarations, hardcoded visual values, and workaround comments across the
526
+ downstream repos.
385
527
 
386
528
  The `layout` namespace includes section, stack, and container spacing tokens,
387
529
  plus fixed layout width tokens for common consumer shells: