Skip to content

feat(docs): rewrite mermaid modal with click-to-view, zoom buttons, and drag-to-scroll - #140

Merged
JusterZhu merged 1 commit into
mainfrom
docs/core-execution-flow
Jun 21, 2026
Merged

feat(docs): rewrite mermaid modal with click-to-view, zoom buttons, and drag-to-scroll#140
JusterZhu merged 1 commit into
mainfrom
docs/core-execution-flow

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

Summary

This PR completely rewrites the mermaid diagram modal, replacing the panzoom-based approach that had persistent centering and scroll-range issues with a simpler, more reliable implementation.

The Problem

PRs #136--#138 added panzoom-based zoom/pan but had cascading issues:

  • SVG dimensions read as 0 during init → diagrams invisible
  • Flex centering conflicted with panzoom coordinates
  • transform: scale() didn't expand scroll range → content cut off after zoom
  • contain: 'outside' prevented zooming out from fit size

The Fix

Abandon panzoom entirely. Use native browser scroll + CSS transform:

FeatureImplementation
Zoom+ / - buttons stepping through 12 levels (0.25x--4x)
PanDrag-to-scroll via scrollLeft/scrollTop (document-level mousemove tracking)
Scroll rangeTwo-layer wrapper: outer gets real px width/height = nat x scale, inner uses transform: scale() to fill it
1:1 resetButton to reset zoom to 100%
CloseEsc key or X button, clicking backdrop

Files Changed

FileChange
website/src/theme/Mermaid/index.jsRewritten: no panzoom, dual-wrapper, drag-to-scroll
website/src/theme/Mermaid/styles.module.cssDeleted — CSS in custom.css
website/src/css/custom.cssAdded .gu-viewer, .gu-wrap-outer, .gu-wrap-inner, .gu-toolbar, .gu-tb-btn, .gu-tb-pct
website/package.jsonRemoved @panzoom/panzoom dependency

🤖 Generated with Claude Code

…nd drag-to-scroll
Replace panzoom-based modal with a simpler, more reliable approach:
- Click inline diagram to open a fullscreen modal
- + / - buttons step through zoom levels (0.25x to 4x)
- 1:1 reset button and current zoom % display
- Drag-to-scroll (pan) via scrollLeft/scrollTop
- Two-layer wrapper for correct scroll range after zoom
* Outer: explicit px size = natural x scale (correct overflow)
* Inner: transform:scale() fills the outer visually
- Esc to close, locked body scroll
- Dark theme support, grab cursor
- Removes @panzoom/panzoom dependency
Co-Authored-By: Claude <noreply@anthropic.com>
CopilotAI review requested due to automatic review settings June 21, 2026 08:15

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JusterZhu
JusterZhu merged commit 25282b0 into mainJun 21, 2026
2 checks passed
@JusterZhu
JusterZhu deleted the docs/core-execution-flow branch June 21, 2026 08:20
Sign up for freeto 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.

2 participants

@JusterZhu