diff --git a/scripts/note_fallback.js b/scripts/note_fallback.js index c6a563b..fcda49a 100644 --- a/scripts/note_fallback.js +++ b/scripts/note_fallback.js @@ -79,31 +79,29 @@ (nativeDetails || nativePre).replaceWith(wrapper); applyHighlight(code); - var MMD_DARK = { - background: "transparent", - textColor: "#ebdbb2", - titleColor: "#fbf1c7", - lineColor: "#a89984", - edgeLabelBackground: "#3c3836", - nodeTextColor: "#fbf1c7", - primaryColor: "#458588", primaryTextColor: "#fbf1c7", primaryBorderColor: "#458588", - secondaryColor: "#b8bb26", secondaryTextColor: "#1d2021", secondaryBorderColor: "#b8bb26", - tertiaryColor: "#d3869b", tertiaryTextColor: "#1d2021", tertiaryBorderColor: "#d3869b" - }; - var MMD_LIGHT = { - background: "transparent", - textColor: "#3c3836", - titleColor: "#282828", - lineColor: "#928374", - edgeLabelBackground: "#ebdbb2", - nodeTextColor: "#1d2021", - primaryColor: "#83a598", primaryTextColor: "#1d2021", primaryBorderColor: "#076678", - secondaryColor: "#98971a", secondaryTextColor: "#fbf1c7", secondaryBorderColor: "#79740e", - tertiaryColor: "#b16286", tertiaryTextColor: "#fbf1c7", tertiaryBorderColor: "#8f3f71" - }; + function mermaidTheme() { + var cs = getComputedStyle(document.documentElement); + function v(n, fb) { return (cs.getPropertyValue(n) || "").trim() || fb; } + return { + background: "transparent", + textColor: v("--text-primary", "#c0caf5"), + titleColor: v("--text-heading", "#c0caf5"), + lineColor: v("--text-menu", "#9ece6a"), + edgeLabelBackground: v("--background-secondary", "#1a1b26"), + nodeTextColor: v("--text-heading", "#c0caf5"), + primaryColor: v("--background-active", "#7aa2f7"), + primaryTextColor: v("--text-menu-active", "#24283b"), + primaryBorderColor: v("--background-active", "#7aa2f7"), + secondaryColor: v("--background-highlight", "#292e42"), + secondaryTextColor: v("--text-primary", "#c0caf5"), + secondaryBorderColor: v("--background-highlight", "#292e42"), + tertiaryColor: v("--text-link", "#7aa2f7"), + tertiaryTextColor: v("--text-menu-active", "#24283b"), + tertiaryBorderColor: v("--text-link", "#7aa2f7") + }; + } function mermaidConfig() { - var light = document.documentElement.classList.contains("theme-light"); - return { startOnLoad: false, theme: "base", themeVariables: light ? MMD_LIGHT : MMD_DARK }; + return { startOnLoad: false, theme: "base", themeVariables: mermaidTheme() }; } function renderMermaid() { import("/assets/mermaid.core-BUJU3YJZ.js").then(function (mod) {