Implement navigation drawer text size setting#1010
Conversation
Convert font-relative-size trait from appdef.xml and use it in Sidebar.svelte and Settings.svelte
📝 WalkthroughWalkthroughAdds an optional ChangesWriting System Font Relative Size
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
convert/convertConfig.ts (1)
943-955:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winNormalize
font-relative-sizebefore writing config.Line 943 and Line 954 currently pass through raw trait text. If XML contains values like
120%or non-numeric strings, downstreamfont-sizebecomes invalid (120%%or invalid token) and scaling silently fails. Normalize once here (strip%, validate numeric, omit invalid values).Proposed fix
export function parseWritingSystem(element: Element, verbose: number): WritingSystemConfig { const type = element.attributes.getNamedItem('type')!.value; const fontFamily = element.getElementsByTagName('font-family')[0].innerHTML; - const fontRelativeSize = parseTrait(element, 'font-relative-size'); + const rawFontRelativeSize = parseTrait(element, 'font-relative-size').trim(); + const normalizedFontRelativeSize = rawFontRelativeSize.endsWith('%') + ? rawFontRelativeSize.slice(0, -1).trim() + : rawFontRelativeSize; + const fontRelativeSize = + /^\d+(\.\d+)?$/.test(normalizedFontRelativeSize) ? normalizedFontRelativeSize : undefined; const textDirection = parseTrait(element, 'text-direction'); const displaynamesTag = element.getElementsByTagName('display-names')[0]; const displayNames: Record<string, string> = {}; for (const form of displaynamesTag.getElementsByTagName('form')) { displayNames[parseLangAttribute(form)] = form.innerHTML; } const writingSystem: WritingSystemConfig = { type, fontFamily, textDirection, - fontRelativeSize, + ...(fontRelativeSize ? { fontRelativeSize } : {}), displayNames };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@convert/convertConfig.ts` around lines 943 - 955, The fontRelativeSize variable obtained from parseTrait on line 943 is passed directly to WritingSystemConfig without normalization, causing invalid downstream font-size values when XML contains entries like "120%" or non-numeric strings. After the parseTrait call that assigns fontRelativeSize, add normalization logic to strip the percent sign if present and validate the resulting value is numeric. Only include the normalized fontRelativeSize in the WritingSystemConfig object if it passes validation, otherwise omit it or set it to undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@convert/convertConfig.ts`:
- Around line 943-955: The fontRelativeSize variable obtained from parseTrait on
line 943 is passed directly to WritingSystemConfig without normalization,
causing invalid downstream font-size values when XML contains entries like
"120%" or non-numeric strings. After the parseTrait call that assigns
fontRelativeSize, add normalization logic to strip the percent sign if present
and validate the resulting value is numeric. Only include the normalized
fontRelativeSize in the WritingSystemConfig object if it passes validation,
otherwise omit it or set it to undefined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 90ce58f0-2f7e-4330-965f-015723fcfe44
📒 Files selected for processing (4)
config/index.d.tsconvert/convertConfig.tssrc/lib/components/Settings.sveltesrc/lib/components/Sidebar.svelte
Resolves #1009. The navigation drawer and settings page now scale their text size based on the interface language's text size setting, matching the native app.
Summary by CodeRabbit
Release Notes