Skip to content

feat(markdown): adapt mermaid fullscreen to touch-first devices - #471

Merged
gitfromwildan merged 1 commit into
mainfrom
feat/markdown-mermaid-fullscreen-touch
Nov 5, 2026
Merged

gitfromwildan merged 1 commit into
mainfrom
feat/markdown-mermaid-fullscreen-touch

Conversation

@gitfromwildan

Copy link
Copy Markdown
Member

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 with matchMedia("(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. Without matchMedia the 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.

    • Move — drag with one finger
    • Zoom — − and + buttons below
    • Reset — tap the zoom %
    • Exit — Close, top right

    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-expanded carries 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.

Phone, 390px with touch Desktop, 1280px
Touch query matches yes no
Exit button "× Close" "Esc Exit fullscreen"
Help touch wording keys and scroll wording
Close, help, zoom − and + 44px unchanged
Exit tapping Close exits Esc exits
  • Four new tests stub matchMedia for 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.
  • 127 markdown tests pass. tsc, oxlint, the flame docs build and the pre-push hook pass.

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.
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Nov 5, 2026 4:19pm UTC

@pullfrog pullfrog 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.

✅ 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 follows change events. It starts as false, so SSR and hydration stay safe because fullscreen controls only render on the client after rendered. Without matchMedia it 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-level keydown handler still runs, so a tablet with a keyboard keeps Esc.
  • Help content: HELP_ROWS holds the pointer and touch wording and replaces the four hardcoded rows. The desktop "Move" row drops the mixed touch and scroll-wheel phrasing. The viewport aria-label follows the same wording.
  • Touch targets: on touch, Close, help, zoom −/+ and reset are 44px. ControlButton gets an optional size that 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-expanded still 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/markdown patch changeset.

I checked the remaining concerns and none of them is a problem:

  • No existing matchMedia helper is duplicated.
  • MediaQueryList.addEventListener is fine for flame's es2020 client target.
  • Pinch is already blocked by the non-passive touchstart handler and touchAction: "none", so the help is right to point to the zoom bar.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit 3d7ac54 into main Nov 5, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the feat/markdown-mermaid-fullscreen-touch branch November 5, 2026 16:22
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.

1 participant