Repository navigation
fix(framework): set the root font size the rem scale assumes - #636
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
The framework converts type and spacing tokens to rem against
rootFontSize(10 in the Core preset), but nothing sethtml { 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
emitRootFontSizepreference makes the shared framework root CSS start withhtml { font-size: 62.5%; }(rootFontSize / 16 as a percentage, so browser font-size preferences still work), feeding bothframework.cssand 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.tscovers publisher and canvas output, legacy preferences, preset merge, and the 16px and px cases; 4 of its 6 tests fail without the fix.Notes
The full suite hit one timeout in
authStepUp.test.tswhile 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.