Skip to content

docs(design-system-docs): rewrite typography for EDS 2.0#4866

Merged
eddiman merged 9 commits intomainfrom
docs/4861-typography-documentation
May 8, 2026
Merged

docs(design-system-docs): rewrite typography for EDS 2.0#4866
eddiman merged 9 commits intomainfrom
docs/4861-typography-documentation

Conversation

@eddiman
Copy link
Copy Markdown
Contributor

@eddiman eddiman commented Apr 28, 2026

Summary

Rewrites the Typography foundation page to match the EDS 2.0 system. The previous page documented EDS 1.0 named text styles (H1bold, Body short, Ingress, etc.) which no longer exist — EDS 2.0 uses a modular type scale (xs6xl) anchored at lg and shifted per density mode.

The new page covers:

  • Principles — sourced from the Spacing & Typography Principles Figma
  • Typefaces — Inter (UI), Equinor (headings), Commit Mono (code), with the eds-uprights-vf.css loading warning kept from the old page
  • Modular type scale — full table + Storybook iframe demo
  • Densityspacious (default) and comfortable; relaxed is hidden until tokens are finalised
  • Line-heightdefault vs squished, with full multiplier math behind a <details>
  • Baseline-grid alignment — single-line vs multi-line behaviour, with the multi-line button anti-pattern
  • Categorisation — Elements / Selectables / Containers / Pages
  • Tokens — full --eds-typography-* reference
  • Implementation in Figma — kept from the old page
  • Do's and Don'ts

Live demos re-use the existing Foundation/Typography.stories.tsx stories so the doc stays in sync with the code automatically.

Closes #4861

Test plan

  • pnpm docu:build — clean (only pre-existing photography-page anchor warnings)
  • pnpm docu:serve — typography page returns HTTP 200
  • Visual review of the rendered page on the deploy preview
  • Confirm the embedded Storybook iframe heights look right (currently 520 / 640 px)

eddiman added 5 commits April 28, 2026 15:43
Replace EDS 1.0 named text styles with the modular type scale,
density and line-height model. Adds principles, baseline-grid
alignment, the Element/Selectable/Container/Page categorisation,
and a token reference. Embeds the Storybook UIText and LongFormText
stories as live demos.

Closes #4861
Typography in Figma is a single component driven by variable modes
on the instance, not per-layer text styles or frame-level modes.
Mirrors how the matching CSS variables resolve in code.
Cascade only applies while modes remain at default; explicit mode
overrides on an instance break the inheritance.
Renders the modular scale at every step in both Inter and Equinor
inline, using rem values from spacious density. Replaces the static
'Inter scale' and 'Equinor scale' Figma exports — the specimen
stays accurate to the scale automatically and shows both typefaces
together so the x-height adjustment is visible.
Adds a px column for both Inter and Equinor so readers can see the
rendered size alongside the sample, matching the original Figma layout.
@eddiman eddiman marked this pull request as ready for review April 30, 2026 11:33
@pomfrida
Copy link
Copy Markdown
Collaborator

pomfrida commented May 6, 2026

@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 6, 2026

Claude finished @pomfrida's task in 4m 25s —— View job


Review — docs(design-system-docs): rewrite typography for EDS 2.0

Overall this is a strong rewrite — the principles, scale derivation, line-height multipliers, density model and category framing all align with the source material in Typography.stories.tsx and the typography token pipeline in eds-tokens. A few issues to address before merge.


Blocking — Tokens table is wrong

apps/design-system-docs/docs/foundation/design-tokens/typography.md — the Tokens reference table (lines 235–245) doesn't match the tokens actually emitted by @equinor/eds-tokens:

Doc claims Actual token
--eds-font-weight-lighter / -normal / -bolder The --eds-font-weight-* namespace doesn't exist. Font-weight tokens live under typography: globally --eds-typography-font-weight (set by [data-font-weight="lighter|normal|bolder"]) and per family/size: --eds-typography-{family}-{size}-font-weight-{lighter|normal|bolder} (e.g. --eds-typography-ui-body-lg-font-weight-normal). See packages/eds-core-react/src/components/next/Foundation/elements.css:37-42.
--eds-typography-letter-spacing-tight / -normal / -loose The token name uses tracking, not letter-spacing--eds-typography-tracking-tight|normal|wide|loose. The CSS property the token resolves to is letter-spacing (packages/eds-tokens/src/css/typography.css:30), but the token identifier is tracking. The doc also drops the wide variant — there are four modes, not three. See packages/eds-tokens/src/css/index-variables.css:97-101 and the trackingConfig array in createSpacingAndTypographyVariables.ts:809-814.

Both rows are user-facing token names — anyone copy-pasting from this table will hit unresolved CSS variables. Fix this →


Should fix

Specimen block fallback fonts (lines 50–106). The inline styles use fontFamily: 'Equinor, serif' for the heading column. Equinor is a sans-serif typeface, so if the font fails to load (deploy preview without eds-uprights-vf.css, browser blocking the CDN, etc.) the fallback will switch to a serif that looks dramatically wrong. Change to Equinor, sans-serif to keep the optical weight in the same family.

Storybook demos only show 7 of 10 steps. Typography.stories.tsx:40 defines sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'], so the embedded iframes don't show 4xl, 5xl or 6xl — but the prose and the table on this page document the full xs6xl scale. Either extend the array in the story to cover the full scale, or add a one-line note under the iframe explaining the demo is truncated. Fix this →

The x-height explanation reads backwards (line 35). "Equinor is rendered slightly larger at every step than Inter — its taller x-height needs a small upward bump" — Inter has a notably tall x-height; display/heading typefaces like Equinor typically have a shorter x-height, which is why they need to be sized up to match Inter's optical size. As written, the cause and effect are reversed.

Commit Mono dangles. Listed in the typefaces table on line 33 but never appears in the Loading section, the scale, the tokens, or anywhere else. Either describe how/when it's loaded (it isn't part of eds-uprights-vf.css), or note explicitly that monospace is reserved for code blocks and the family stack is up to the consumer.


Nits

  • Storybook story panel still exposes relaxed (Typography.stories.tsx:20) even though the doc deliberately hides it. A reader who toggles the radio in the iframe sees undefined values. Either drop relaxed from argTypes.options or leave a disabled-style note in the story description (the argTypes.density.description already calls it a POC, which helps — but the option is still selectable).
  • Tokens table uses &middot; HTML entities to inline alternatives within a single cell (lines 240, 243). It works, but since the rest of the file uses pure Markdown tables, splitting these into separate rows or a sub-list would be more consistent and easier to scan.
  • "View in Storybook" links (lines 146, 184) — worth a click on the deploy preview to make sure the path-format URL still resolves; Storybook's URL conventions sometimes change between major versions.
  • Density example (line 159) could clarify that data-density cascades through the typography axes too — readers may wonder whether they need to also set data-font-size, data-font-family, etc. on every element. (The text "Components within that ancestor then read the cascaded base" is correct but doesn't make the data-* axis relationship explicit.)

Verified ✓

  • Modular-scale multipliers and resulting pixel values (table, lines 125–136) — math checks out against pow(2, n/5) rounded to 0.5 px increments.
  • Line-height formula and per-step values (lines 188–202) — 1.39 − (n/9)³ × 0.29 and 1.13 − (n/9)³ × 0.13 reproduce the table.
  • Storybook story IDs (eds-2-0-beta-foundation-typography--ui-text / --long-form-text) match meta.title + story export names.
  • Density modes (spacious default, comfortable) match the build pipeline; hiding relaxed is the right call given its POC status.
  • text-box: trim-both ex alphabetic matches packages/eds-tokens/src/css/typography.css:36.
  • The eds-uprights-vf.css warning correctly identifies the equinor-font.css-only failure mode.

  • Read the changed file
  • Cross-check claims against the codebase (tokens, density modes, type scale)
  • Verify embedded Storybook URLs and stories exist
  • Check links and anchors
  • Post review feedback
    · docs/4861-typography-documentation

Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
Comment thread apps/design-system-docs/docs/foundation/design-tokens/typography.md Outdated
eddiman added 3 commits May 8, 2026 11:58
- Fix Tokens table: correct font-weight to namespaced form, rename
  letter-spacing to tracking, add header font-size and line-height rows
- Reverse x-height explanation: Equinor has shorter x-height than Inter,
  not taller (verified from font OS/2 metrics: 0.480 vs 0.546)
- Switch Equinor specimen fallback from serif to sans-serif
- Extract repeated specimen label inline styles into .specimen-label
- Add WCAG callout reserving xs for decoration
- Convert :::info **Do** / :::danger **Don't** to bracketed-title syntax
- Un-indent closing ::: markers so Docusaurus parses them
- Drop deprecated frameborder attribute from Storybook iframes
- Add note that iframe demos only show xs-3xl
- Clarify density cascade reaches every typography axis
- Remove Commit Mono until it is properly shipped with tokens
Replace the inline specimen grid (hardcoded fontSize values per row) with
a TypeSpecimen component that resolves fontSize from
--eds-typography-{ui-body,header}-{size}-font-size and reads back the
computed pixel value via getComputedStyle. The label and rendered text
now come from the same source — if the token scale changes, both update.
@eddiman
Copy link
Copy Markdown
Contributor Author

eddiman commented May 8, 2026

im looking into the lint errors

Copy link
Copy Markdown
Collaborator

@Chibuzor-Nwemambu Chibuzor-Nwemambu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic Work! ✅

Somethings I noticed which aren't a blocker though:

  • The px size labels in the specimen grid flash in blank on first render. Initialising with '…' instead of '' would avoid that.
  • If the EDS token stylesheet isn't loaded, the size labels would show "NaNpx". A small isNaN check in formatPx would make it fall back gracefully.

Let's Go 🔥 🚚

typescript-eslint cannot resolve React types when linting files under
apps/design-system-docs because tsconfig.eslint.json (matched first by
**/*.tsx) doesn't include React in its project graph. The codebase
already downgrades no-unsafe-return / -assignment / -argument to warn
globally; extend the same treatment to no-unsafe-call and
no-unsafe-member-access, scoped to the docs app, so CI doesn't fail on
hooks usage in docs-only React components.
Copy link
Copy Markdown
Collaborator

@Chibuzor-Nwemambu Chibuzor-Nwemambu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌🏾

@eddiman eddiman merged commit 2ffce4b into main May 8, 2026
11 checks passed
@eddiman eddiman deleted the docs/4861-typography-documentation branch May 8, 2026 12:04
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.

Update Typography documentation

3 participants