diff options
| author | rtkay123 <dev@kanjala.com> | 2026-02-01 12:18:24 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-02-01 12:18:24 +0200 |
| commit | 6a9d21bc87f8a738e14f27a1305bf04d0c4b7a0c (patch) | |
| tree | 99e31ad0ef707c7e0ce79a58cac86f876fd00da7 /docs/book/mermaid-init.js | |
| parent | 08b73aca5b6bfce3c807fb5b017ca13acddf4413 (diff) | |
| download | sellershut-6a9d21bc87f8a738e14f27a1305bf04d0c4b7a0c.tar.bz2 sellershut-6a9d21bc87f8a738e14f27a1305bf04d0c4b7a0c.zip | |
docs: user and auth entity model
Diffstat (limited to 'docs/book/mermaid-init.js')
| -rw-r--r-- | docs/book/mermaid-init.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/docs/book/mermaid-init.js b/docs/book/mermaid-init.js new file mode 100644 index 0000000..0469ff1 --- /dev/null +++ b/docs/book/mermaid-init.js @@ -0,0 +1,39 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +(() => { + const darkThemes = ['ayu', 'navy', 'coal']; + const lightThemes = ['light', 'rust']; + + const classList = document.getElementsByTagName('html')[0].classList; + + let lastThemeWasLight = true; + for (const cssClass of classList) { + if (darkThemes.includes(cssClass)) { + lastThemeWasLight = false; + break; + } + } + + const theme = lastThemeWasLight ? 'default' : 'dark'; + mermaid.initialize({ startOnLoad: true, theme }); + + // Simplest way to make mermaid re-render the diagrams in the new theme is via refreshing the page + + for (const darkTheme of darkThemes) { + document.getElementById(darkTheme).addEventListener('click', () => { + if (lastThemeWasLight) { + window.location.reload(); + } + }); + } + + for (const lightTheme of lightThemes) { + document.getElementById(lightTheme).addEventListener('click', () => { + if (!lastThemeWasLight) { + window.location.reload(); + } + }); + } +})(); |
