@phcdevworks/spectre-tokens 4.13.0 → 4.15.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.13.0 |
20
+ | Current version/status | 4.15.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,191 @@ 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. Large headings and display text resize
355
+ with the viewport (see [Responsive text roles](#responsive-text-roles)).
356
+ 2. **Size presets** `font.{xs…9xl}` (`--sp-font-lg-size`,
357
+ `--sp-font-lg-line-height`, `--sp-font-lg-weight`,
358
+ `--sp-font-lg-letter-spacing`): a size together with the line height and
359
+ weight that suit it. The sizes match Tailwind's scale:
360
+
361
+ | Step | xs | sm | md | lg | xl | 2xl | 3xl | 4xl | 5xl | 6xl | 7xl | 8xl | 9xl |
362
+ | ---- | -- | -- | -- | -- | -- | --- | --- | --- | --- | --- | --- | --- | --- |
363
+ | px | 12 | 14 | 16 | 18 | 20 | 24 | 30 | 36 | 48 | 60 | 72 | 96 | 128 |
364
+
365
+ `md` is Tailwind's `base`.
366
+ 3. **Plain sizes** `fontSize.{12…128}` (`--sp-font-size-18`): one size with
367
+ no line height or weight attached. Pair them with the scales below.
368
+
369
+ ```css
370
+ .price {
371
+ font-size: var(--sp-font-size-18);
372
+ line-height: var(--sp-leading-snug);
373
+ font-weight: var(--sp-font-weight-semibold);
374
+ letter-spacing: var(--sp-tracking-tight);
375
+ }
376
+
377
+ a {
378
+ text-decoration-color: var(--sp-link-underline);
379
+ text-decoration-thickness: var(--sp-text-decoration-thickness-thin);
380
+ text-underline-offset: var(--sp-text-decoration-offset-md);
381
+ }
382
+ ```
383
+
384
+ | Scale | Steps | CSS variable |
385
+ | --- | --- | --- |
386
+ | `fontWeight` | `normal` 400, `medium` 500, `semibold` 600, `bold` 700, `extrabold` 800, `black` 900 | `--sp-font-weight-*` |
387
+ | `leading` (line height, unitless) | `none` 1, `tight` 1.25, `snug` 1.375, `normal` 1.5, `relaxed` 1.625, `loose` 2 | `--sp-leading-*` |
388
+ | `tracking` (letter-spacing) | `tightest` −0.075em through `widest` 0.1em | `--sp-tracking-*` |
389
+ | `textDecoration` | `thickness.{thin,base,thick}` (1/2/3px), `offset.{sm,md,lg}` (0.125/0.2/0.3em) | `--sp-text-decoration-*` |
390
+
391
+ ### Responsive text roles
392
+
393
+ Headings `h1`–`h5` and display `1`–`3` are mobile first. The role's own
394
+ value is the phone size, and `typography.responsive.md.*` holds the size from
395
+ the `md` breakpoint (768px) up. In CSS, `@media (min-width: 768px)` re-points
396
+ `--sp-heading-*-size`/`-line-height` and `--sp-display-*-size`/`-line-height`
397
+ at `--sp-typography-responsive-md-*`, so consumers keep using one variable
398
+ and need no breakpoint of their own.
399
+
400
+ | Role | Below 768px | 768px and up |
401
+ | --- | --- | --- |
402
+ | `display.1` | 36px | 72px |
403
+ | `display.2` | 36px | 60px |
404
+ | `display.3` | 36px | 48px |
405
+ | `display.4`–`6` | 36 / 30 / 24px | same |
406
+ | `heading.h1` | 36px | 60px |
407
+ | `heading.h2` | 30px | 48px |
408
+ | `heading.h3` | 24px | 36px |
409
+ | `heading.h4` | 20px | 30px |
410
+ | `heading.h5` | 20px | 24px |
411
+ | `heading.h6` | 20px | same |
412
+
413
+ Weights and families do not change. Each size keeps the line height of its
414
+ scale step.
415
+
416
+ ### Action colour
417
+
418
+ `action` is the theme's own action colour: the one a site uses for its main
419
+ buttons, stat units, and quote rules. It defaults to `brand`.
420
+
421
+ | Token | CSS variable | Default (light) |
422
+ | --- | --- | --- |
423
+ | `action.bg`, `bgHover`, `bgActive` | `--sp-action-bg`, `-bg-hover`, `-bg-active` | `brand` 700, 800, 900 |
424
+ | `action.text` | `--sp-action-text` | white |
425
+ | `action.focusRing` | `--sp-action-focus-ring` | `brand` 500 at 40% |
426
+ | `action.onPage`, `onSurface` | `--sp-action-on-page`, `-on-surface` | `brand` 700 |
427
+ | `action.rail` | `--sp-action-rail` | `brand` 700 |
428
+
429
+ A theme sets the colour with an attribute on the root element, not by
430
+ declaring `--sp-*`:
431
+
432
+ ```html
433
+ <html data-spectre-action="emerald">
434
+ ```
435
+
436
+ The value is `brand`, `accent`, `info`, or any `colors.palette` family except
437
+ `yellow` and `integration-icy-blue`, which miss a contrast minimum. Hover and
438
+ active shades come from the same family. In dark mode the text and rail
439
+ roles move to step 400, and high-contrast mode uses 800/900/900 fills and
440
+ 900 text. `check:contrast` checks every selectable family against every pair.
441
+
442
+ The attribute works on `<html>` only. The role variables are resolved on the
443
+ root, so putting it on a nested element has no effect. Colour modes still
444
+ apply anywhere, and they pick up the root's family.
445
+
446
+ ### Accent rails
447
+
448
+ A rail is the coloured edge on a card, badge, quote, and similar components.
449
+ Each component that has one carries the same contract under
450
+ `component.<name>.accent`: one colour per tone (`neutral`, `brand`, `info`,
451
+ `success`, `warning`, `danger`, `cta`, `accent`) plus a single `thickness`
452
+ (`0.25rem`). The components are `card`, `badge`, `testimonial`,
453
+ `pricingCard`, `nav`, `footer`, `modal`, `toast`, `tooltip`, `dropdown`,
454
+ `listGroup`, and `quote`. `footer.light` has its own tone colours and uses
455
+ `footer`'s thickness. Every rail colour is mode-aware.
456
+
457
+ ```css
458
+ .card--brand {
459
+ border-inline-start: var(--sp-component-card-accent-thickness) solid
460
+ var(--sp-component-card-accent-brand);
461
+ }
462
+
463
+ .toast--danger {
464
+ border-inline-start: var(--sp-toast-accent-thickness) solid
465
+ var(--sp-toast-accent-danger);
466
+ }
467
+ ```
468
+
469
+ `card` and `input` keep a legacy `component-` segment in their variable
470
+ names. Every other component uses its own name, such as `--sp-badge-accent-*`
471
+ or `--sp-quote-accent-*`. Which edge the rail sits on, and how it's drawn, is
472
+ up to the downstream component.
473
+
474
+ ### Accent and inverse roles
475
+
476
+ `colors.accent` is the second brand colour. It has its own semantic roles, so
477
+ consumers never reach for the raw palette:
478
+
479
+ - `text.onPage.accent` and `text.onSurface.accent` (`--sp-text-on-page-accent`)
480
+ are accent text that passes contrast on the page or a card.
481
+ - `text.onInverse.{default,muted,brand,accent}` is text on dark (inverse)
482
+ backgrounds, such as a dark hero or footer.
483
+ - `buttons.accent` and `buttons.accentOutline` are filled and outlined accent
484
+ buttons. Button variables join camelCase names without hyphens, for example
485
+ `--sp-button-accentoutline-bghover`.
486
+ - `component.stepper.tone.{brand,accent}.{active,done}` colours a stepper in
487
+ either brand colour.
488
+ - `component.quote` covers a quote's text, attribution name and role, an
489
+ accent-coloured quotation mark, a plain border, and an accent rail
490
+ (`--sp-quote-*`).
491
+
492
+ ### Footer
493
+
494
+ `component.footer` is its own contract, separate from navigation: `bg`,
495
+ `text`, `heading`, `muted`, `link`, `linkHover`, `border`, `divider`,
496
+ `chipBg`, and an accent rail (`--sp-footer-*`). It is dark by default.
497
+ `component.footer.light` (`--sp-footer-light-*`) has the same roles for a
498
+ light footer.
499
+
500
+ ### Extended palette
501
+
502
+ `colors.palette` holds the full extended colour ramps (`red` through `stone`,
503
+ `slate`, `zinc`, the `mauve`/`olive`/`mist`/`taupe` neutrals, and the named
504
+ brand and integration colours), emitted as `--sp-color-palette-<name>-<step>`.
505
+ Like `colors`, it is raw palette: use it for data visualisation or a brand
506
+ colour that has no semantic role, not for normal UI.
507
+
508
+ ### HTML element coverage
509
+
510
+ Spectre aims to style every standard HTML element from tokens alone.
511
+ [`element-coverage.json`](element-coverage.json) maps all 115 elements in the
512
+ HTML Living Standard's element index, and 14 styleable pseudo-elements, to
513
+ the token paths that style them. Elements with no visual styling of their own
514
+ (`<div>`, `<meta>`, `<template>`, …) are marked as such, with a reason. The
515
+ `check:elements` step of `npm run check` fails if an element is unmapped or
516
+ mapped to a path that doesn't exist. [TOKEN_REFERENCE.md](TOKEN_REFERENCE.md)
517
+ has the generated table.
518
+
519
+ Element roles include:
520
+
521
+ | Element | Variables |
522
+ | --- | --- |
523
+ | `<del>`, `<ins>`, `<mark>`, `<kbd>`, `<code>`, `<pre>`, `<blockquote>`, `<hr>` | `--sp-prose-*` |
524
+ | `<dt>`, `<dd>` | `--sp-prose-dt-text`, `--sp-prose-dd-text` |
525
+ | `<figcaption>`, `<caption>`, `<tfoot>` | `--sp-prose-figcaption-text`, `--sp-table-caption-text`, `--sp-table-footer-*` |
526
+ | `<meter>` | `--sp-meter-track`, `--sp-meter-fill-{optimum,suboptimum,critical}` |
527
+ | `<option>`, `<optgroup>` | `--sp-select-option-*`, `--sp-select-optgroup-label-text` |
528
+ | `::marker` | `--sp-prose-marker`, `--sp-prose-marker-accent` |
529
+ | `::selection`, `::spelling-error`, `::grammar-error` | `--sp-selection-*`, `--sp-proofing-{spelling,grammar}` |
530
+ | Code highlighting | `--sp-code-syntax-{keyword,string,comment,function,…}` |
531
+ | Article spacing | `--sp-layout-prose-flow-{paragraph,heading,list,…}` |
532
+
342
533
  ### Token model
343
534
 
344
535
  The generated token object includes these namespaces:
@@ -370,8 +561,10 @@ The generated token object includes these namespaces:
370
561
  - `leading`
371
562
  - `textDecoration`
372
563
  - `fontWeight`
564
+ - `fontSize`
373
565
  - `control`
374
566
  - `elevation`
567
+ - `action`
375
568
 
376
569
  The exported runtime token object is a flattened string-based tree generated
377
570
  from `tokens/`. Source-only wrapper fields such as `value` and `metadata` are
@@ -384,7 +577,10 @@ Downstream packages building recipes on the CSS output should use
384
577
  [DOWNSTREAM_PARITY.md](DOWNSTREAM_PARITY.md), which groups every published
385
578
  `--sp-*` variable into the family a recipe or stylesheet consumes. Run
386
579
  `npm run audit:parity` (optionally `-- <sibling-repo>`) for a checklist of the
387
- families a checked-out downstream repo has not consumed yet.
580
+ families a checked-out downstream repo has not consumed yet, and
581
+ `npm run audit:downstream` for a read-only report of raw `--sp-*`
582
+ redeclarations, hardcoded visual values, and workaround comments across the
583
+ downstream repos.
388
584
 
389
585
  The `layout` namespace includes section, stack, and container spacing tokens,
390
586
  plus fixed layout width tokens for common consumer shells: