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

Invalid mermaid colors when switching to dark/light mode, need to refresh page #999

Open
angristan opened this issue Jan 25, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@angristan
Copy link

Issue description

👋

Easy to see on https://jpanther.github.io/congo/samples/diagrams-flowcharts/

Switching from light to dark:

Image

After page refresh:

Image

Theme version

v2.10

Hugo version

v0.141

Which browser rendering engines are you seeing the problem on?

Chromium (Google Chrome, Microsoft Edge, Brave, Vivaldi, Opera, etc.)

URL to sample repository or website

No response

Hugo output or build error messages

@angristan angristan added the bug Something isn't working label Jan 25, 2025
@wolfspyre
Copy link
Contributor

as far as I know, this isn't REALLY something that congo/hugo controls...

The colors in the generated diagram are selected by mermaid at generation time.... it's possible that a solution would be to generate the diagram twice at site rendering time, with both polarities, and use the resulting image as css... but that feels.... like the wrong way forward?

color polarity is controlled entirely clientside.... so solutions have to be clientside based..
might wanna look at the mermaid.js site n see how they're solving it elsewhere.... may provide some ideas on a way forward.

@AvinashReddy3108
Copy link

AvinashReddy3108 commented Feb 7, 2025

but that feels.... like the wrong way forward?

Maybe not? 👀

This exact approach is implemented for the Site Logo partial.

<img
src="{{ $logo.RelPermalink }}"
width="{{ div $logo.Width 2 }}"
height="{{ div $logo.Height 2 }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left
{{ if $logo_dark }}hidden dark:flex{{ end }}"
alt="{{ .Site.Title }}"
/>
{{- if $logo_dark }}
<img
src="{{ $logo_dark.RelPermalink }}"
width="{{ div $logo_dark.Width 2 }}"
height="{{ div $logo_dark.Height 2 }}"
class="max-h-[10rem] max-w-[10rem] object-scale-down object-left dark:hidden"
alt="{{ .Site.Title }}"
/>

@AvinashReddy3108
Copy link

@jpanther
Copy link
Owner

This is indeed an upstream issue and I'm not sure that forcing a page reload whenever the user changes dark mode is an ideal workaround. It seems to be a highly requested feature in Mermaid but is still yet to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants