Skip to content

feat: add font-size and font-weight design tokens#12772

Draft
lokesh wants to merge 3 commits into
internetarchive:masterfrom
lokesh:font-size-weight-tokens
Draft

feat: add font-size and font-weight design tokens#12772
lokesh wants to merge 3 commits into
internetarchive:masterfrom
lokesh:font-size-weight-tokens

Conversation

@lokesh
Copy link
Copy Markdown
Collaborator

@lokesh lokesh commented May 19, 2026

Closes part of #11555 (the font sizes and weights checkboxes).

Summary

  • Adds static/css/tokens/font-sizes.css — 9-step t-shirt primitive scale (--font-size-2xs--font-size-3xl) + semantic tokens for headings (--font-size-heading-xsxxl), body, and UI (meta, label, button, code, chip).
  • Adds static/css/tokens/font-weights.css — 4 primitive weights + 4 semantic tokens (body, heading, emphasis, button).
  • Moves the existing M3-style font-size block out of font-families.css. The old names (--font-size-display-large, --font-size-title-medium, etc.) live on as deprecated aliases inside the new file, mapped to the new scale, so the ~150 existing references keep working until migrated.
  • Adds a Tokens showcase section to /developers/design with a live sample for every primitive and semantic token — pattern this for future token categories (colors, etc.).
  • Migrates components/footer.css as the first real consumer — three em-based font-size declarations swapped to var(--font-size-meta).

Design notes

  • rem-based so user font-size preferences are respected; consistent with spacing.css.
  • Heading tokens are visual styles, not HTML semantics. Pick the heading element based on document outline; pick the token based on visual weight. --font-size-heading-md can appear on any element.
  • Single heading-* ramp replaces the M3 display / headline / title split — those distinctions caused fuzziness in practice.
  • 9 primitive steps cover ~95% of current OL usage 1:1; the rare 22/45/57px values become one-offs or round-up on migration.

Test plan

  • All new tokens resolve correctly in browser (getComputedStyle(document.documentElement))
  • All deprecated aliases preserve original pixel values (label-medium=12px, title-large=22px, display-large=57px, etc.)
  • /developers/design renders showcase across primitives → semantic-headings → body → UI → weights
  • pre-commit run passes on changed files
  • Footer renders identically after migration (12.8px → 12px is imperceptible)
  • Follow-up: open an issue/checklist for the full em → token migration sweep across the rest of the codebase

Screenshots

Showcase preview

The new section appears under a Tokens group in the sidebar of /developers/design, with Font Sizes and Font Weights entries. Each token row shows: token name (monospace), value (rem · px), and a sample rendered at that size/weight.

lokesh added 3 commits May 19, 2026 15:16
Adds two-tier design tokens for font sizes and font weights, per the
pattern established by spacing/borders/line-heights (issue internetarchive#11555).

- New `tokens/font-sizes.css`: 9-step t-shirt primitive scale plus
  semantic tokens for headings, body, and UI. Heading tokens are
  decoupled from HTML element — `--font-size-heading-md` is a visual
  style, not a claim about `<h2>`. Material 3 vocabulary
  (display/headline/title/label) kept as deprecated aliases so
  existing ~150 references keep working through migration.
- New `tokens/font-weights.css`: 4 primitive weights + 4 semantic
  (body, heading, emphasis, button).
- Moves the M3 font-size block out of `font-families.css`.
- Adds a Tokens showcase section to `/developers/design` with live
  samples for every primitive and semantic token.
First real consumer of the new font-size tokens. Replaces three em-based
declarations that all computed to 12.8px with the absolute
--font-size-meta token (12px). The 0.8px shrink is imperceptible.

- footer { font-size: 0.8em } -> var(--font-size-meta)
- footer h2 { font-size: 1em } -> var(--font-size-meta) (still needed
  to override base h2's 24px size)
- footer ul li { font-size: 1em } -> var(--font-size-meta)
The semantic section already defines --font-size-body-large at 16px,
so the deprecated alias block doesn't need its own redefinition.
Added a section comment noting the name is preserved from the M3 vocabulary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant