Repository navigation
fix(type-scale): drive raw tokens from base+ratio, semantic tokens as var() refs - #682
Conversation
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
a1e8d5f to
187d34d
Compare
| '--text-4xs': '0.5rem', // 8px - citation | ||
| '--text-3xs': '0.625rem', // 10px - micro | ||
| '--text-2xs': '0.6875rem', // 11px - small micro | ||
| '--text-xsm': '0.75rem', // 12px - supporting, badge | ||
| '--text-sm': '0.8125rem', // 13px - secondary text | ||
| '--text-base': '0.875rem', // 14px - body text (XDS default) | ||
| '--text-lg': '1rem', // 16px - large body | ||
| '--text-xl': '1.125rem', // 18px - h2 | ||
| '--text-2xl': '1.25rem', // 20px - h1 | ||
| '--text-3xl': '1.5rem', // 24px - editorial h2 | ||
| '--text-4xl': '2rem', // 32px - editorial h1, data viz | ||
| // Geometric scale: round(14 × 1.2^step) / 16, default base=14, ratio=1.2 | ||
| '--text-xsm': '0.625rem', // step -2: 10px (14 × 1.2⁻² ≈ 9.72 → 10) |
There was a problem hiding this comment.
I think the awkward part here is that --text-2xs is bigger than --text-xsm in the new geometric scale, but I guess we need to deprecate those. Probably nothing to action on here if we want to delete these.
| @@ -0,0 +1,174 @@ | |||
| # Type Scale Reference | |||
There was a problem hiding this comment.
This reference doc doesn't get shipped with the CLI so you might want to update the token docs in https://github.com/facebookexperimental/xds/blob/main/packages/cli/docs instead. This includes all our tokens though, so we may want to keep it dense for typescale specifically.
cixzhang
left a comment
There was a problem hiding this comment.
Seems good. We should update the token reference.
…LI docs - Sub-scale tokens (--text-4xs, --text-3xs, --text-2xs) are now computed from base+ratio at steps -5, -4, -3 instead of being static values. The entire size scale (11 tokens) is now a single geometric progression. - Default values change: 4xs 8→6px, 3xs 10→7px, 2xs 11→8px - CLI token docs (packages/cli/docs/tokens.md) updated with: - New text size values showing step + geometric formula - Full semantic type scale tokens (heading-*, text-*-size/weight/leading) - Named leading tokens section clarified as separate from type scale - TYPE_SCALE_REFERENCE.md updated to reflect the full 11-token scale Addresses review feedback from #682.
|
Addressed both review comments in 04f9c03: 1. Sub-scale tokens now computed from base+ratio — 2. CLI docs updated with semantic type scale tokens — All 1618 tests pass. |
…s var() refs Two-layer architecture: - Layer 1: Raw size tokens (--text-xsm…--text-4xl) from geometric progression, in rem - Layer 2: Semantic tokens — sizes as var() refs to Layer 1, line heights as hardcoded computed values (tiered target: <20px→1.5, 20-31px→1.4, ≥32px→1.25, then 4px grid snap) Named leading tokens (--leading-tight…--leading-relaxed) are NOT modified — they remain as intent-based ratios for component use. This ensures all 47 components using textSizeVars cascade correctly when typeScale is configured. Previously only semantic tokens were computed, leaving raw tokens static and out of sync. Co-authored-by: Navi <[email protected]>
- Type scale preview now resolves var() refs and shows px values for h1-h6 and large/body/supporting text types - Added Landing Page and Dashboard preview tabs alongside the existing component preview - Landing: hero, features grid, testimonial, CTA - Dashboard: KPI cards, data table, activity feed, progress bars Co-authored-by: Navi <[email protected]>
…b children) The XDSTabList component takes value/onChange props with XDSTab children, not a tabs array prop. All 3 usages were silently broken (rendering nothing). Co-authored-by: Navi <[email protected]>
…LI docs - Sub-scale tokens (--text-4xs, --text-3xs, --text-2xs) are now computed from base+ratio at steps -5, -4, -3 instead of being static values. The entire size scale (11 tokens) is now a single geometric progression. - Default values change: 4xs 8→6px, 3xs 10→7px, 2xs 11→8px - CLI token docs (packages/cli/docs/tokens.md) updated with: - New text size values showing step + geometric formula - Full semantic type scale tokens (heading-*, text-*-size/weight/leading) - Named leading tokens section clarified as separate from type scale - TYPE_SCALE_REFERENCE.md updated to reflect the full 11-token scale Addresses review feedback from #682.
04f9c03 to
b81f2bf
Compare
|
Let's resolve the conflicts and clean up TYPE_SCALE_REFERENCE.md |
Trims the reference doc to architecture + step mapping + line height formula. Full token docs live in packages/cli/docs/tokens.md (already updated). Co-authored-by: Navi <[email protected]>
Co-authored-by: Navi <[email protected]>
… var() refs (#682) * feat(type-scale): drive raw tokens from base+ratio, semantic tokens as var() refs Two-layer architecture: - Layer 1: Raw size tokens (--text-xsm…--text-4xl) from geometric progression, in rem - Layer 2: Semantic tokens — sizes as var() refs to Layer 1, line heights as hardcoded computed values (tiered target: <20px→1.5, 20-31px→1.4, ≥32px→1.25, then 4px grid snap) Named leading tokens (--leading-tight…--leading-relaxed) are NOT modified — they remain as intent-based ratios for component use. This ensures all 47 components using textSizeVars cascade correctly when typeScale is configured. Previously only semantic tokens were computed, leaving raw tokens static and out of sync. Co-authored-by: Navi <[email protected]> * feat(theme-editor): resolve type scale px values, add 3 preview tabs - Type scale preview now resolves var() refs and shows px values for h1-h6 and large/body/supporting text types - Added Landing Page and Dashboard preview tabs alongside the existing component preview - Landing: hero, features grid, testimonial, CTA - Dashboard: KPI cards, data table, activity feed, progress bars Co-authored-by: Navi <[email protected]> * fix(theme-editor): use correct XDSTabList API (value/onChange + XDSTab children) The XDSTabList component takes value/onChange props with XDSTab children, not a tabs array prop. All 3 usages were silently broken (rendering nothing). Co-authored-by: Navi <[email protected]> * fix(type-scale): extend geometric scale to sub-scale tokens, update CLI docs - Sub-scale tokens (--text-4xs, --text-3xs, --text-2xs) are now computed from base+ratio at steps -5, -4, -3 instead of being static values. The entire size scale (11 tokens) is now a single geometric progression. - Default values change: 4xs 8→6px, 3xs 10→7px, 2xs 11→8px - CLI token docs (packages/cli/docs/tokens.md) updated with: - New text size values showing step + geometric formula - Full semantic type scale tokens (heading-*, text-*-size/weight/leading) - Named leading tokens section clarified as separate from type scale - TYPE_SCALE_REFERENCE.md updated to reflect the full 11-token scale Addresses review feedback from #682. * chore: clean up TYPE_SCALE_REFERENCE.md — slim to internal reference Trims the reference doc to architecture + step mapping + line height formula. Full token docs live in packages/cli/docs/tokens.md (already updated). Co-authored-by: Navi <[email protected]> * chore: remove TYPE_SCALE_REFERENCE.md Co-authored-by: Navi <[email protected]> --------- Co-authored-by: Navi <[email protected]> Co-authored-by: cixzhang <[email protected]>
… var() refs (#682) * feat(type-scale): drive raw tokens from base+ratio, semantic tokens as var() refs Two-layer architecture: - Layer 1: Raw size tokens (--text-xsm…--text-4xl) from geometric progression, in rem - Layer 2: Semantic tokens — sizes as var() refs to Layer 1, line heights as hardcoded computed values (tiered target: <20px→1.5, 20-31px→1.4, ≥32px→1.25, then 4px grid snap) Named leading tokens (--leading-tight…--leading-relaxed) are NOT modified — they remain as intent-based ratios for component use. This ensures all 47 components using textSizeVars cascade correctly when typeScale is configured. Previously only semantic tokens were computed, leaving raw tokens static and out of sync. Co-authored-by: Navi <[email protected]> * feat(theme-editor): resolve type scale px values, add 3 preview tabs - Type scale preview now resolves var() refs and shows px values for h1-h6 and large/body/supporting text types - Added Landing Page and Dashboard preview tabs alongside the existing component preview - Landing: hero, features grid, testimonial, CTA - Dashboard: KPI cards, data table, activity feed, progress bars Co-authored-by: Navi <[email protected]> * fix(theme-editor): use correct XDSTabList API (value/onChange + XDSTab children) The XDSTabList component takes value/onChange props with XDSTab children, not a tabs array prop. All 3 usages were silently broken (rendering nothing). Co-authored-by: Navi <[email protected]> * fix(type-scale): extend geometric scale to sub-scale tokens, update CLI docs - Sub-scale tokens (--text-4xs, --text-3xs, --text-2xs) are now computed from base+ratio at steps -5, -4, -3 instead of being static values. The entire size scale (11 tokens) is now a single geometric progression. - Default values change: 4xs 8→6px, 3xs 10→7px, 2xs 11→8px - CLI token docs (packages/cli/docs/tokens.md) updated with: - New text size values showing step + geometric formula - Full semantic type scale tokens (heading-*, text-*-size/weight/leading) - Named leading tokens section clarified as separate from type scale - TYPE_SCALE_REFERENCE.md updated to reflect the full 11-token scale Addresses review feedback from #682. * chore: clean up TYPE_SCALE_REFERENCE.md — slim to internal reference Trims the reference doc to architecture + step mapping + line height formula. Full token docs live in packages/cli/docs/tokens.md (already updated). Co-authored-by: Navi <[email protected]> * chore: remove TYPE_SCALE_REFERENCE.md Co-authored-by: Navi <[email protected]> --------- Co-authored-by: Navi <[email protected]> Co-authored-by: cixzhang <[email protected]>
… var() refs (#682) * feat(type-scale): drive raw tokens from base+ratio, semantic tokens as var() refs Two-layer architecture: - Layer 1: Raw size tokens (--text-xsm…--text-4xl) from geometric progression, in rem - Layer 2: Semantic tokens — sizes as var() refs to Layer 1, line heights as hardcoded computed values (tiered target: <20px→1.5, 20-31px→1.4, ≥32px→1.25, then 4px grid snap) Named leading tokens (--leading-tight…--leading-relaxed) are NOT modified — they remain as intent-based ratios for component use. This ensures all 47 components using textSizeVars cascade correctly when typeScale is configured. Previously only semantic tokens were computed, leaving raw tokens static and out of sync. * feat(theme-editor): resolve type scale px values, add 3 preview tabs - Type scale preview now resolves var() refs and shows px values for h1-h6 and large/body/supporting text types - Added Landing Page and Dashboard preview tabs alongside the existing component preview - Landing: hero, features grid, testimonial, CTA - Dashboard: KPI cards, data table, activity feed, progress bars * fix(theme-editor): use correct XDSTabList API (value/onChange + XDSTab children) The XDSTabList component takes value/onChange props with XDSTab children, not a tabs array prop. All 3 usages were silently broken (rendering nothing). * fix(type-scale): extend geometric scale to sub-scale tokens, update CLI docs - Sub-scale tokens (--text-4xs, --text-3xs, --text-2xs) are now computed from base+ratio at steps -5, -4, -3 instead of being static values. The entire size scale (11 tokens) is now a single geometric progression. - Default values change: 4xs 8→6px, 3xs 10→7px, 2xs 11→8px - CLI token docs (packages/cli/docs/tokens.md) updated with: - New text size values showing step + geometric formula - Full semantic type scale tokens (heading-*, text-*-size/weight/leading) - Named leading tokens section clarified as separate from type scale - TYPE_SCALE_REFERENCE.md updated to reflect the full 11-token scale Addresses review feedback from #682. * chore: clean up TYPE_SCALE_REFERENCE.md — slim to internal reference Trims the reference doc to architecture + step mapping + line height formula. Full token docs live in packages/cli/docs/tokens.md (already updated). * chore: remove TYPE_SCALE_REFERENCE.md --------- Co-authored-by: cixzhang <[email protected]>
Summary
Restructures the type scale system so that
{ base, ratio }drives the raw size tokens, with semantic tokens becomingvar()references for sizes and hardcoded computed values for line heights. This fixes the core problem with PR #638: semantic tokens were computed from the ratio but the 47 components using rawtextSizeVars(Button, Badge, Table, etc.) were left static and out of sync.Named leading tokens (
--leading-tightthrough--leading-relaxed) are not modified — they remain as intent-based ratios for component use.Architecture
Step-to-Token Mapping
--text-xsm--text-sm--text-base--text-lg--text-xl--text-2xl--text-3xl--text-4xlLine Height Computation
Tiered target ratio based on font size, then 4px grid snap:
Default scale (14/1.2) verification
Raw CSS Output
Changes
expandTypeScale.tstargetLeadingRatio()tiered function +pxToRem(). Now emits 41 tokens: 8 raw size (rem) + 33 semantic (sizes as var refs, leadings as computed values).tokens.stylex.tstextSizeDefaultsaligned to geometric scale in rem.typeScaleDefaultssizes changed to var() refs, leadings updated to match tiered computation.lineHeightDefaultsunchanged.expandTypeScale.test.tsdefineTheme.test.tsgenerateThemeRules.test.tsTYPE_SCALE_REFERENCE.mdAll 1617 tests pass.