Skip to content

feat(render-html): Enlarge initial diagram fit on common viewports#164

Merged
mhiro2 merged 4 commits into
mainfrom
tweak/render-html-initial-fit-padding
May 16, 2026
Merged

feat(render-html): Enlarge initial diagram fit on common viewports#164
mhiro2 merged 4 commits into
mainfrom
tweak/render-html-initial-fit-padding

Conversation

@mhiro2
Copy link
Copy Markdown
Owner

@mhiro2 mhiro2 commented May 16, 2026

Summary

  • Improve the viewer's initial fit so diagrams no longer render at ~33% on a 14" MacBook for the custom playground fixture.
  • Hide the minimap by default to return ~180px of vertical bottom inset to the diagram, and tighten computeFit padding from 40 to 20.
  • Surface a toolbar toggle and M shortcut for revealing the minimap, with accessible labelling and stable popstate behaviour.

Changes

  • a996870 : fix(render-html): tighten minimap toggle a11y and hash restore
    • Stabilise the toggle button's accessible name as "Minimap" while keeping aria-pressed for state and flipping only the hover title between "Show minimap (M)" / "Hide minimap (M)"
    • Advertise the shortcut on the button via aria-keyshortcuts="M"
    • Add a { silent: true } option to ViewerMinimapApi.setHidden so hash restore no longer queues a debounced pushState and spuriously grows the back-stack
  • 08f1ab0 : feat(render-html): hide minimap by default to enlarge initial fit
    • Start the viewer with #minimap-shell hidden so getAvailableViewport returns the freed bottom inset to the diagram
    • Persist visibility via mv=1 (replacing the previous mh=1 since the default flipped)
  • 5cf01cb : feat(render-html): add minimap visibility toggle
    • Add a minimap toggle button to the viewer-controls bar and an M keyboard shortcut, guarded against modifier keys to avoid clashing with Cmd+M
    • Expose ViewerMinimapApi (isHidden / setHidden) through the runtime, emit relune:minimap-toggled, and persist state in the URL hash
  • f07ed4e : refactor(render-html): tighten initial fit padding
    • Reduce computeFit padding from 40 to 20 so the initial scale uses more of the available viewport on common laptop screens

mhiro2 added 4 commits May 15, 2026 13:09
Reduce the symmetric padding used by computeFit from 40px to 20px so
the initial fit-to-screen scale is meaningfully larger on medium and
large diagrams. The viewport already accounts for minimap, viewer
controls, drawer and heading insets via getAvailableViewport, so a
smaller fit padding avoids stacking margin on top of those overlays
while keeping the diagram comfortably visible.
Add a viewer-controls button and an "M" keyboard shortcut that toggle
the minimap shell's hidden state. The toggle exposes a new
runtime.minimap API, emits relune:minimap-toggled, and is persisted in
the URL hash via the mh parameter so shared links retain the chosen
minimap visibility. Toggling also re-fits the diagram so the freed
viewport area is used immediately, addressing the "diagram looks too
small" feedback when the minimap overlay is not needed.
The minimap shell reserves ~180px of vertical bottom inset in
getAvailableViewport, which left the initial fit scale uncomfortably
small on common laptop viewports (e.g. 33% on 14" MacBook for the
custom playground fixture).

Start the viewer with the minimap hidden; users can reveal it via the
toolbar toggle or the `M` shortcut, and the button's title/aria-label
flips to "Show minimap (M)" / "Hide minimap (M)" so the interaction is
discoverable. Persist visibility via `mv=1` in the hash (replacing the
previous `mh=1` since the default flipped).
Keep the toggle button's accessible name stable as "Minimap" so
assistive tech reads the action and pressed state cleanly instead of
mixing them ("Hide minimap, pressed"). The hover title still flips
between Show/Hide so sighted users see the next action. Advertise the
M shortcut via aria-keyshortcuts now that the minimap is hidden by
default and discoverability matters more.

Add a silent option to ViewerMinimapApi.setHidden and use it when
restoring from the hash. Previously the restore emitted
relune:minimap-toggled, which queued a debounced hash write that ran
after restoringFromPopstate had flipped back to false, pushing a
spurious history entry on back/forward navigation.
@mhiro2 mhiro2 self-assigned this May 16, 2026
@mhiro2 mhiro2 added the enhancement New feature or request label May 16, 2026
@github-actions
Copy link
Copy Markdown

Code Metrics Report

main (c9be562) #164 (48767cb) +/-
Coverage 94.4% 94.4% +0.0%
Test Execution Time 1m44s 1m38s -6s
Details
  |                     | main (c9be562) | #164 (48767cb) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          94.4% |          94.4% | +0.0% |
  |   Files             |            100 |            100 |     0 |
  |   Lines             |          36825 |          36842 |   +17 |
+ |   Covered           |          34784 |          34801 |   +17 |
+ | Test Execution Time |          1m44s |          1m38s |   -6s |

Code coverage of files in pull request scope (99.9% → 99.9%)

Files Coverage +/- Status
crates/relune-render-html/src/components.rs 100.0% 0.0% modified
crates/relune-render-html/src/css.rs 100.0% 0.0% modified
crates/relune-render-html/src/html.rs 99.8% +0.0% modified

Reported by octocov

@github-actions
Copy link
Copy Markdown

Schema review

Tip

✅ No risk findings — schema changes look safe to merge.

@mhiro2 mhiro2 merged commit 99b90c7 into main May 16, 2026
6 checks passed
@mhiro2 mhiro2 deleted the tweak/render-html-initial-fit-padding branch May 16, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant