Skip to content

Commit 25282b0

Browse files
JusterZhuclaude
andauthored
feat(docs): rewrite mermaid modal with click-to-view, zoom buttons, and drag-to-scroll (#140)
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>
1 parent 1c1ecf9 commit 25282b0

5 files changed

Lines changed: 149 additions & 332 deletions

File tree

website/package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"@docusaurus/preset-classic": "3.1.1",
1919
"@docusaurus/theme-mermaid": "^3.1.1",
2020
"@mdx-js/react": "^3.0.0",
21-
"@panzoom/panzoom": "^4.6.2",
2221
"clsx": "^2.0.0",
2322
"prism-react-renderer": "^2.3.0",
2423
"react": "^18.0.0",

website/src/css/custom.css

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,68 @@
636636
color: var(--ifm-color-primary);
637637
}
638638

639+
/* ════════════════════════════════════════════════════════════════
640+
MERMAID FULLSCREEN MODAL
641+
════════════════════════════════════════════════════════════════ */
642+
643+
/* Inline hint */
644+
.gu-mermaid-inline { max-width: 100%; cursor: zoom-in; }
645+
.gu-mermaid-inline > svg { max-width: 100%; }
646+
647+
/* Backdrop */
648+
.gu-backdrop {
649+
position: fixed; inset: 0; z-index: 9999;
650+
background: rgba(0, 0, 0, 0.78);
651+
backdrop-filter: blur(6px);
652+
display: flex; flex-direction: column;
653+
align-items: center; justify-content: center;
654+
}
655+
656+
/* Toolbar */
657+
.gu-toolbar {
658+
position: fixed; top: 12px; right: 12px; z-index: 10001;
659+
display: flex; align-items: center; gap: 8px;
660+
background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px);
661+
border-radius: 10px; padding: 8px 14px; user-select: none;
662+
}
663+
.gu-tb-btn {
664+
display: inline-flex; align-items: center; justify-content: center;
665+
width: 34px; height: 34px; border: none; border-radius: 8px;
666+
background: transparent; color: #ddd; font-size: 18px; cursor: pointer;
667+
transition: background 0.15s;
668+
}
669+
.gu-tb-btn:hover { background: rgba(255, 255, 255, 0.18); }
670+
.gu-tb-pct {
671+
color: rgba(255, 255, 255, 0.6); font-size: 13px; min-width: 42px; text-align: center;
672+
}
673+
674+
/* Viewer — scroll to pan, wide diagrams start from left, tall from top */
675+
.gu-viewer {
676+
width: 95vw; height: 90vh;
677+
overflow: auto;
678+
background: #fff;
679+
border-radius: 12px;
680+
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
681+
cursor: grab;
682+
user-select: none;
683+
}
684+
.gu-viewer:active { cursor: grabbing; }
685+
[data-theme='dark'] .gu-viewer { background: #1a1a2e; }
686+
687+
/* Outer wrapper: explicit px size = scale × natural dimensions.
688+
Viewer overflow:auto sees this → always correct scroll range. */
689+
.gu-wrap-outer {
690+
overflow: hidden;
691+
}
692+
/* Inner: transform:scale fills outer visually */
693+
.gu-wrap-inner {
694+
transform-origin: 0 0;
695+
}
696+
.gu-wrap-inner > div > svg {
697+
display: block;
698+
max-width: none;
699+
}
700+
639701
/* ════════════════════════════════════════════════════════════════
640702
PRINT-FRIENDLY
641703
════════════════════════════════════════════════════════════════ */

0 commit comments

Comments
 (0)