mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
feat(docs): click-to-zoom for mermaid diagrams
This commit is contained in:
1 parent
baf1daff61
commit
70e21c2eaa
2 files changed
+44
No files matched your search
@@ -184,6 +184,33 @@ footer a { color: var(--muted); }
|
|||||||
.mermaid {
|
.mermaid {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 1.5rem 0;
|
margin: 1.5rem 0;
|
||||||
|
cursor: zoom-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diagram-overlay {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.9);
|
||||||
|
z-index: 9999;
|
||||||
|
cursor: zoom-out;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diagram-overlay.open {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diagram-overlay svg {
|
||||||
|
max-width: 95vw;
|
||||||
|
max-height: 95vh;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
background: var(--bg);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
|||||||
Vendored
+17
@@ -51,6 +51,23 @@ for (const pre of document.querySelectorAll('pre.mermaid, pre > code.language-me
|
|||||||
node.replaceWith(div);
|
node.replaceWith(div);
|
||||||
}
|
}
|
||||||
await mermaid.run();
|
await mermaid.run();
|
||||||
|
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.className = 'diagram-overlay';
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
overlay.addEventListener('click', () => overlay.classList.remove('open'));
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Escape') overlay.classList.remove('open');
|
||||||
|
});
|
||||||
|
for (const diagram of document.querySelectorAll('.mermaid')) {
|
||||||
|
diagram.addEventListener('click', () => {
|
||||||
|
const svg = diagram.querySelector('svg');
|
||||||
|
if (!svg) return;
|
||||||
|
overlay.innerHTML = '';
|
||||||
|
overlay.appendChild(svg.cloneNode(true));
|
||||||
|
overlay.classList.add('open');
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user