Skip to content

fix(framework): set the root font size the rem scale assumes - #636

Merged
DavidBabinec merged 1 commit into
mainfrom
fix/root-font-size
Oct 13, 2026
Merged

DavidBabinec merged 1 commit into
mainfrom
fix/root-font-size

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

The bug

The framework converts type and spacing tokens to rem against rootFontSize (10 in the Core preset), but nothing set html { font-size }. At the 16px browser default every token rendered 1.6x larger than the scale shows, in the canvas and on the published site.

The fix

A new optional emitRootFontSize preference makes the shared framework root CSS start with html { font-size: 62.5%; } (rootFontSize / 16 as a percentage, so browser font-size preferences still work), feeding both framework.css and the canvas iframes. The Core preset sets it for new frameworks; stored preferences without the field mean off, so existing sites render byte for byte as before. Site settings > Publishing gets a toggle to opt in.

Verification

rootFontSize.test.ts covers publisher and canvas output, legacy preferences, preset merge, and the 16px and px cases; 4 of its 6 tests fail without the fix.

bun test src/__tests__/framework/rootFontSize.test.ts
 6 pass
 0 fail

Notes

The full suite hit one timeout in authStepUp.test.ts while other suites ran in parallel; that file passes 3 of 3 alone on both main and this branch. Existing sites can opt in from Settings > Publishing.

The framework converts every type and spacing token to rem against
rootFontSize (10 in the Core preset), but nothing set html font-size, so at
the 16px browser default every token rendered 1.6x larger than the scale
says. A new emitRootFontSize preference makes the framework emit
html { font-size: 62.5% } (rootFontSize / 16 as a percentage) in both the
published framework.css and the canvas iframes. The Core preset turns it on
for new frameworks; existing sites have no stored value, which means off, so
they keep rendering exactly as before. Site settings > Publishing gets a
toggle to opt in.
@DavidBabinec
DavidBabinec merged commit b853dd3 into main Oct 13, 2026
11 checks passed
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