Repository navigation
feat(markdown): adapt mermaid fullscreen to touch-first devices - #471
Merged
Merged
Conversation
On a phone, or a tablet without a mouse, fullscreen showed the desktop controls: an Esc badge and help that mentioned keys and the scroll wheel. It now reads the primary input with `(hover: none) and (pointer: coarse)` and follows changes, so a narrow desktop window keeps the keyboard controls and a tablet switches when a keyboard attaches. On touch: - A Close button with an icon replaces the Esc badge. Its accessible name, "Close full screen", contains the visible label. - Help describes what works: drag with one finger to move, the - and + buttons to zoom (pinch is blocked in fullscreen), tap the percentage to reset, Close to exit. The diagram's accessible label follows. - Close, help and the zoom bar buttons are 44px touch targets. - The open help toggle keeps "?" instead of "x", so it does not sit as a second "x" next to Close. A darker fill shows it is open. On desktop the help's Move line read "hold scroll wheel or tap & drag". It now reads "drag or arrow keys", like the accessible label.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Mode: standard. I reviewed the touch-first adaptation of the Mermaid fullscreen view in @docubook/markdown, plus its docs, changeset and tests. Verdict: READY.
useTouchPrimary()hook: detects the primary input with(hover: none) and (pointer: coarse)and followschangeevents. It starts asfalse, so SSR and hydration stay safe because fullscreen controls only render on the client afterrendered. WithoutmatchMediait keeps the desktop controls.- Touch exit: a labeled "Close" button replaces the
Esc<kbd>badge. Its accessible name, "Close full screen", contains the visible label. The window-levelkeydownhandler still runs, so a tablet with a keyboard keepsEsc. - Help content:
HELP_ROWSholds thepointerandtouchwording and replaces the four hardcoded rows. The desktop "Move" row drops the mixed touch and scroll-wheel phrasing. The viewportaria-labelfollows the same wording. - Touch targets: on touch, Close, help, zoom −/+ and reset are 44px.
ControlButtongets an optionalsizethat defaults to 28, so desktop and the inline "Enter full screen" button don't change. - Help toggle: on touch it keeps "?" and shows the open state with a darker fill.
aria-expandedstill carries the state. - Tests / docs / changeset: four new tests stub
matchMedia, including one that switches back to the desktop controls on a media change. The docs page gets a touch section, and there is a@docubook/markdownpatch changeset.
I checked the remaining concerns and none of them is a problem:
- No existing
matchMediahelper is duplicated. MediaQueryList.addEventListeneris fine for flame's es2020 client target.- Pinch is already blocked by the non-passive
touchstarthandler andtouchAction: "none", so the help is right to point to the zoom bar.
claude-opus-5-5 | 𝕏
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.

Summary
On a phone, or a tablet without a mouse, the Mermaid fullscreen view showed the desktop controls: an Esc badge to exit and help that mentioned keys and the scroll wheel. Fullscreen now adapts to touch-first devices.
Detection
useTouchPrimary()reads the primary input withmatchMedia("(hover: none) and (pointer: coarse)")and listens for changes. It is keyed on the input, not the viewport width: a narrow desktop window still has a keyboard and keeps the Esc badge. A tablet switches back to the desktop controls when a keyboard and trackpad attach. WithoutmatchMediathe component keeps the desktop controls.On touch
Close: a button with an × icon and a visible "Close" label replaces the Esc badge. Its accessible name, "Close full screen", contains the visible label.
Help: describes what works on touch. Pinch is blocked in fullscreen, so zoom points at the zoom bar.
The diagram's accessible label follows the same wording.
Touch targets: Close, help and the zoom bar buttons are 44px.
Help toggle: on desktop it shows "×" while the panel is open. On touch it keeps "?" and shows the open state with a darker fill, so it does not sit as a second "×" next to Close.
aria-expandedcarries the state.On desktop
The help's Move line read "hold scroll wheel or tap & drag", which mixed in touch wording. It now reads "drag or arrow keys", like the existing accessible label. Nothing else changes.
The Mermaid docs page describes the touch behavior.
Verification
Built flame's docs and opened a diagram in fullscreen in Chromium.
matchMediafor the touch path. They cover the Close button replacing the Esc badge, the touch help wording with no keys or scroll, the "?" toggle when open, the 44px targets, and the switch back to desktop controls on a media query change.tsc,oxlint, the flame docs build and the pre-push hook pass.