Skip to content

Commit

Permalink
feat: patch mermaid to support auto dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Sep 23, 2024
1 parent 2062ce1 commit 0803270
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
},
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
}
},
"version": "0.4.0"
Expand Down
15 changes: 15 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/dist/mermaid.js b/dist/mermaid.js
index ef05f6a0f4869895ecfde055ca295b38f46fbf46..561793e757be9f0dfe90b339d01038dd77553242 100644
--- a/dist/mermaid.js
+++ b/dist/mermaid.js
@@ -14640,8 +14640,9 @@ ${config2.themeCSS}`;
const firstChild = svg2.firstChild;
const diagramClassDefs = (_b2 = (_a2 = diag.renderer).getClasses) == null ? void 0 : _b2.call(_a2, text2, diag);
const rules = createUserStyles(config2, diagramType, diagramClassDefs, idSelector);
+ const rulesDark = createUserStyles({...config2, themeVariables: theme.dark.getThemeVariables({})}, diagramType, diagramClassDefs, idSelector);
const style1 = document.createElement("style");
- style1.innerHTML = rules;
+ style1.innerHTML = rules + `@media (prefers-color-scheme: dark) {${rulesDark}}`;
svg2.insertBefore(style1, firstChild);
try {
await diag.renderer.draw(text2, id2, version$1, diag);
8 changes: 6 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0803270

Please sign in to comment.