Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Dynamically change mermaid theme based on selected appearance mode #9306

Closed
peter-csala opened this issue Oct 18, 2023 · 0 comments · Fixed by #9307
Closed
Labels
bug A bug to fix
Milestone

Comments

@peter-csala
Copy link

Is your feature request related to a problem?

Mermaid.js supports different built-in themes. Some are tailored for lighter background (like forest or neutral) while others are better suited for darker (like dark). On the mermaid.js documentation if you switch from light appearance mode to dark then a different theme is applied for the diagrams.

We would like to ask a similar solution from docfx.

Describe the solution you'd like

The optimal solution would be that the mermaid diagrams' theme are changing between default and dark automatically (if the diagram does not overwrite the site-wide settings). In other words, if you don't explicitly set the theme then it is appearance mode aware otherwise it is fixed to the chosen theme.

Describe alternatives you've considered

If we could do it by our own inside a preprocessor in somewhat similar way like mermaid docs did that would also great.

const renderChart = async () => {
  const hasDarkClass = document.documentElement.classList.contains('dark');
  const mermaidConfig = {
     ...   
    theme: hasDarkClass ? 'dark' : 'default',
  };
  ...
}

Additional context

We would like to add more and more mermaid diagrams to the pollydocs.org. We have temporarily chosen the dark theme because it is readable with dark appearance mode but it is not as legible with light mode.

We have tried to use the default theme for both appearance modes but in dark mode the diagram is terrible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants