Zoom the app with ⌘+ / ⌘− / ⌘0 - #194
Open
tosinamuda wants to merge 1 commit into
Open
Conversation
Compose had no way to make the text bigger. For a writing app whose
audience is not technical, that is an accessibility gap, not a missing
nicety.
Almost everything here is already sized in `rem` — 926 declarations
against 317 in `px`, and the `px` ones are overwhelmingly hairlines,
radii and shadows — and the editor package sizes its content in `rem`
and `em` too. So one root font size scales the whole app, chrome and
document alike:
--ui-zoom: 1;
font-size: calc(100% * var(--ui-zoom));
`100%` rather than a fixed base, so this multiplies whatever text size
the user's system already asks for instead of replacing it. Borders stay
`px` on purpose: a 1px rule is 1px at any zoom.
Six `px` font sizes (the New menu, the editor and source panes) became
`rem` so they scale with everything else, along with the boxes around
them that would otherwise have clipped the larger text.
**The window chrome deliberately does not scale.** macOS draws the
traffic lights at a position fixed when the window is created, and Tauri
2.11 exposes no way to move them afterwards — only a builder option. A
title bar that grew with zoom slid out from under lights that stayed put,
which is visible at 150% and worse above it. So the strip is pinned in
`px`, matching the `--traffic-lights-inset` that was already fixed for
the same reason. This is the rule browsers use for their own toolbars.
Discrete stops (0.8 … 2.0) rather than free multiplication, compared with
an epsilon: a stored 1.25 comes back from JSON as 1.2500000000000002, and
`step > current` would then skip 1.25 and jump to 1.5. A persisted scale
is untrusted and clamped — everything is sized off the root, so a bad
value there is not a cosmetic bug, it is an app nobody can read.
Applied in `main.tsx` before the first paint, not from a mount effect, so
launches don't render at 100% and jump; and the hook sits at the app root
rather than in MainApp, because the person most likely to need bigger
text is the one who cannot read the setup screen.
Settings → General gets a labelled control showing the current
percentage. The View menu is the macOS convention and carries the
shortcuts, but someone who needs larger text is the least likely to go
looking for a menu-bar item.
The accelerators are the physical keys. `muda` — the parser Tauri hands
these strings to — has no bare "Plus", only `NumpadPlus`, so
`CmdOrCtrl+Plus` parses as nothing and the item ships with no shortcut at
all: no build error, no runtime error, just a key that does nothing. Zoom
In uses `=`, and ⌘⇧= is caught in the web view where the shifted
character is what arrives. A test parses every accelerator against muda,
and a second asserts the "Plus" spelling still fails so the workaround
can be removed if that changes.
The menu moved out of a closure in `lib.rs` into `menu.rs` to be testable
at all; `lib.rs` drops 451 → 363 lines. Routing now reads the same id
list the menu is built from, so an item cannot ship with nothing
listening — two tests hold both directions of that.
576 front-end tests and 260 Rust tests pass. Verified live: the View menu
shows ⌘=, ⌘− and ⌘0; the menu item and the keys both step; the whole
interface scales together.
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.
Compose had no way to make the text bigger. For a writing app whose audience is not technical, that is an accessibility gap.
One property scales everything
The app was already well-placed for this: 926
remdeclarations against 317px, and thepxones are overwhelmingly hairlines (48), radii (90) and shadows (22). The editor package sizes its content inrem/emtoo. So one root font size scales chrome and document together:100%rather than a fixed base, so this multiplies whatever text size the user's system already asks for instead of replacing it. Borders staypxdeliberately — a 1px rule is 1px at any zoom.Six stray
pxfont sizes becamerem, along with the fixed-height boxes around them that would have clipped the larger text.The window chrome deliberately does not scale
macOS draws the traffic lights at a position fixed when the window is created, and Tauri 2.11 exposes
traffic_light_positiononly as a builder option — there is no runtime setter (the runtime trait has one; it is not public). A title bar that grew with zoom slid out from under lights that stayed put:So the strip is pinned in
px, matching--traffic-lights-inset, which was already fixed for exactly this reason. OS chrome doesn't scale, content does — the rule browsers apply to their own toolbars.Details worth knowing
1.25returns from JSON as1.2500000000000002, and a naivestep > currentskips 1.25 and jumps to 1.5. Covered by a test.main.tsx, not from a mount effect, so launches don't render at 100% and jump. The hook sits at the app root rather than inMainApp, because the person most likely to need bigger text is the one who cannot read the setup screen.The accelerator trap
muda— the parser Tauri hands these strings to — has no barePlus, onlyNumpadPlus. SoCmdOrCtrl+Plusparses as nothing and the item ships with no shortcut: no build error, no runtime error, just a key that does nothing. Zoom In uses=, and ⌘⇧= is caught in the web view where the shifted character is what actually arrives.A test parses every accelerator against muda, and a second asserts the
Plusspelling still fails, so the workaround can be deleted if that ever changes.To make that testable the menu moved out of a closure in
lib.rsintomenu.rs—lib.rsdrops 451 → 363 lines, back under budget. Event routing now reads the same id list the menu is built from, so an item cannot ship with nothing listening; two tests hold both directions.Verified
576 front-end tests, 260 Rust tests. Live on a bundled build: the View menu shows ⌘=, ⌘− and ⌘0; both the menu item and the keys step;
--ui-zoommoves 1 → 1.1 → 1.25 → 1.5 and the whole interface scales with it.Dark mode is the next piece — the token layer it needs is already in place, since the app and the editor package both read the same
--cds-*custom properties.