-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Idea: dark mode support #6
Comments
This is a great idea! Dark mode is really important for accessibility. Default behaviour should stay the same. I imagine a new option A couple of notes:
|
Yes I think all a11y related attributes should go to
Goes to
Easiest option, which would be backward compatible is to leave it on
Ideally (but not possible with mermaid, I think) if all colors would be specified using CSS-variables (or CSS classes), then Inline SVG could be styled with CSS, just as any other element. Then it would be enough to render one inline SVG and dark theme would be implemented witth the help of CSS. |
A bit of context: I'm looking for "ideal" diagram solution for Astro. See my post |
I have some insights for your research:
Backwards compatibility isn’t an issue if we add a new option. The HTML output is going to be different anyway. I’m leaning towards either: <picture>
<source id="mermaid-dark-0" … />
<img id="mermaid-0" … />
</picture> Or: <picture id="mermaid-0">
<source … />
<img … />
</picture>
Hence the idea that maybe support could be added by Mermaid instead. Anyway, we could support dark mode for the |
Thank you for adding details. I will update article. RE |
The mermaid CSS targets the id, which is relevant only for the I’m not entirely sure why I added it for the other strategies. I suppose because the information is available. 🤷 It allows you to link the diagram using a URL hash, or target it using CSS. I’m not sure if that’s useful. Maybe I should remove it in the next major version. |
It seems they (Astro team) had the similar problem with Shiki highlighter, which doesn't support const ASTRO_COLOR_REPLACEMENTS: Record<string, string> = {
'#000001': 'var(--astro-code-color-text)',
'#000002': 'var(--astro-code-color-background)',
'#000004': 'var(--astro-code-token-constant)',
'#000005': 'var(--astro-code-token-string)',
'#000006': 'var(--astro-code-token-comment)',
'#000007': 'var(--astro-code-token-keyword)',
'#000008': 'var(--astro-code-token-parameter)',
'#000009': 'var(--astro-code-token-function)',
'#000010': 'var(--astro-code-token-string-expression)',
'#000011': 'var(--astro-code-token-punctuation)',
'#000012': 'var(--astro-code-token-link)',
}; |
This is only supported for the `img-png` and `img-svg` strategies. Dark mode is supported using a responsive `<picture>` element. Closes #6
This is only supported for the `img-png` and `img-svg` strategies. Dark mode is supported using a responsive `<picture>` element. The meta tag `color-scheme` is used to determine whether the light or dark diagram should be used by default when using a responsive picture element. Closes #6
I was wondering if this is a good idea, for
img-png
,img-svg
generateinstead of
for this it needs to prernder diagram 2 times:
{ theme: 'dark' }
)The text was updated successfully, but these errors were encountered: