Skip to content

Implement navigation drawer text size setting#1010

Open
TheNonPirate wants to merge 1 commit into
sillsdev:mainfrom
TheNonPirate:feature/navigation-drawer-text/1009
Open

Implement navigation drawer text size setting#1010
TheNonPirate wants to merge 1 commit into
sillsdev:mainfrom
TheNonPirate:feature/navigation-drawer-text/1009

Conversation

@TheNonPirate

@TheNonPirate TheNonPirate commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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

  • New Features
    • Added language-specific relative font sizing that dynamically adjusts typography in the settings menu and sidebar based on the configured writing system.

Convert font-relative-size trait from appdef.xml
and use it in Sidebar.svelte and Settings.svelte
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an optional fontRelativeSize field to WritingSystemConfig, parses the font-relative-size trait in parseWritingSystem inside convertConfig.ts, and consumes it in Settings.svelte and Sidebar.svelte to apply per-language dynamic inline font sizing. A stale commented-out text-on-image stub is also removed.

Changes

Writing System Font Relative Size

Layer / File(s) Summary
Config contract and trait parsing
config/index.d.ts, convert/convertConfig.ts
Adds fontRelativeSize?: string to WritingSystemConfig, extracts the font-relative-size trait in parseWritingSystem and includes it in the returned object. Removes a stale commented-out text-on-image stub from filterFeaturesNotReady.
Dynamic font sizing in Settings and Sidebar
src/lib/components/Settings.svelte, src/lib/components/Sidebar.svelte
Settings.svelte imports config, derives fontRelativeSize/fontSize from the active language's writing system, and applies style:font-size to the category container and all setting title/summary/control elements. Sidebar.svelte derives the same values and applies font-size to the drawer menu list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A font too small for my bunny eyes,
Now scales up to a comfortable size!
The writing system whispers its trait,
And fontSize percent seals the fate.
Each sidebar and setting sings in style —
Relative sizing, worth every compile! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: implementing text size setting for the navigation drawer, which is the core objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Normalize font-relative-size before writing config.

Line 943 and Line 954 currently pass through raw trait text. If XML contains values like 120% or non-numeric strings, downstream font-size becomes 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

📥 Commits

Reviewing files that changed from the base of the PR and between 59640a4 and 65b726e.

📒 Files selected for processing (4)
  • config/index.d.ts
  • convert/convertConfig.ts
  • src/lib/components/Settings.svelte
  • src/lib/components/Sidebar.svelte

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.

Navigation Drawer Text Size Option

1 participant