Custom JavaScript
Style picker (prefs.js)
Provides a modal for choosing primary and accent colors. Persists to localStorage.__style_picker.
How it works
- On
DOMContentLoadedandDOMContentSwitch, restores saved colors by settingdata-md-color-primaryanddata-md-color-accenton<body>. - Injects a palette button into the header (before the dark/light toggle).
- Opens a modal with color swatches on click.
- Reset clears saved prefs and reloads, returning to Material defaults.
Persistence
Uses localStorage with key __style_picker (stringified JSON {primary, accent}).
Mermaid zoom (mermaid-zoom.js)
Adds pan and zoom to all Mermaid SVG diagrams.
How it works
- A
MutationObserverwatches.md-contentfor newsvgelements that are children of.mermaid. - On
DOMContentSwitch(instant navigation), scans for any Mermaid SVGs already present. - Wraps each SVG in a transparent overlay and attaches
wheel(zoom) andmousedown/mousemove/mouseup(pan) handlers. - Zoom centers on cursor position using CSS
transform: scale()+translate().
Page transitions
On DOMContentSwitch, the .md-content element gets a CSS animation (fade in + translateY) via @keyframes pageEnter. The animation is reset on each navigation via requestAnimationFrame.