Repository navigation
feat(frontend): add an app-wide font size preference - #501
Merged
Merged
Conversation
Comment on lines
28
to
+30
| var snapshot = JSON.parse(localStorage.getItem('ocm-appearance')); | ||
| var fontSize = localStorage.getItem('ocm-font-size'); | ||
| if (fontSize) document.documentElement.style.fontSize = fontSize; |
Contributor
There was a problem hiding this comment.
Fragile boot order
The font size is read only after JSON.parse(localStorage.getItem('ocm-appearance')), and both share one try. If the appearance snapshot is corrupted, the parse throws and the stored font size is skipped, so the page flashes at the default size until React applies the preference. Reading and applying ocm-font-size before parsing the snapshot keeps the two values independent.
Suggested change
| var snapshot = JSON.parse(localStorage.getItem('ocm-appearance')); | |
| var fontSize = localStorage.getItem('ocm-font-size'); | |
| if (fontSize) document.documentElement.style.fontSize = fontSize; | |
| var fontSize = localStorage.getItem('ocm-font-size'); | |
| if (fontSize) document.documentElement.style.fontSize = fontSize; | |
| var snapshot = JSON.parse(localStorage.getItem('ocm-appearance')); |
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
Summary
fontSizepreference (small, medium, large, extra large) that sets the root font size, so rem-based text and spacing across the app scale together.ocm-font-sizekey before first paint and apply it on preference change, so there is no flash.max(16px, 1rem), so inputs scale up but never drop below 16px.Tests
Frontend theme, settings and hook tests pass, including new
applyFontSizecoverage. Shared, backend and frontend typecheck and lint are clean.PR Type
Enhancement
Description
Add
small/medium/large/xlargefont size preferenceScale root
font-sizeso all rem-based UI scalesPersist scale to
ocm-font-sizeand replay before first paintKeep mobile inputs at
max(16px, 1rem)to block zoomDiagram Walkthrough
File Walkthrough
6 files
Add FontSizeSchema enum, type and medium defaultAllow assistant to patch fontSize preferenceAdd applyFontSize and shared storage helperApply font size when preferences changeAdd validated Font size select to settingsReplay stored font size before first paint1 files
Document fontSize in assistant settings prompt1 files
Cover font size application and boot key1 files
Scale mobile input anti-zoom font size