feat: re-render mermaid when theme changed

This commit is contained in:
st1020 2024-03-18 20:51:37 +08:00
parent 44acba4041
commit be0ec891a0
4 changed files with 39 additions and 6 deletions

View file

@ -34,7 +34,13 @@
// dark theme
const setDark = (isDark) => {
htmlClass[isDark ? "add" : "remove"]("dark");
if (isDark) {
document.body.dispatchEvent(new CustomEvent("set-theme", { detail: "dark" }));
htmlClass.add("dark");
} else {
document.body.dispatchEvent(new CustomEvent("set-theme", { detail: "light" }));
htmlClass.remove("dark");
}
localStorage.setItem("dark", isDark);
};