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

Mermaid subgraph background too dark #9178

Open
catanzaromj opened this issue Mar 24, 2024 · 4 comments
Open

Mermaid subgraph background too dark #9178

catanzaromj opened this issue Mar 24, 2024 · 4 comments
Labels
bug Something isn't working diagrams-mermaid Mermaid diagrams themes Related to HTML theming or any other style related issue (like highlight-style)
Milestone

Comments

@catanzaromj
Copy link

Bug description

As described in Issue #5416, the background of a mermaid subgraph is too dark when creating a revealjs presentation. It may extend to other formats, but that is my use case.

I think I found a temporary fix and a possible solution. As mentioned here, the variable mermaid-fg-color--lightest in your CSS/SCSS controls the subgraph background. For example, to set it to white:

/*-- scss:defaults --*/
//other stuff
$mermaid-fg-color--lightest:#FFFFFF;

In case it helps anyone debug this, this line sets the subgraph background color to mermaid-fg-color--lightest, since subgraphs are cluster elements. This defaults to $mermaid-fg-color--lightest: lighten($body-color, 20%); according to the docs. Should it default to a background color instead of a foreground color?

Steps to reproduce

The code from this post reproduces it for me:

---
title: "test"
format: revealjs
---

```{mermaid}
flowchart LR
  subgraph A [Layer 1]
    direction LR
    id1[Affine Function] --> id2[ReLU]
  end

  subgraph B [Layer 2]
    direction LR
    id2 --> id3[Affine Function]
  end
  
  subgraph C [Loss Function]
    direction LR
    id3 --> id4[MSE]
  end
```

Then run quarto preview test.qmd.

Expected behavior

I expect it to be light:

flowchart LR
  subgraph A [Layer 1]
    direction LR
    id1[Affine Function] --> id2[ReLU]
  end

  subgraph B [Layer 2]
    direction LR
    id2 --> id3[Affine Function]
  end
  
  subgraph C [Loss Function]
    direction LR
    id3 --> id4[MSE]
  end
Loading

Again, taken from this post.

Actual behavior

It is very dark. When I run quarto preview test.qmd, I get
image

Your environment

  • IDE: nvim 0.10.0 (but I'm running preview from the command line)
  • OS: Ubuntu 22.04
  • quarto v1.4.550, installed from conda forge

Quarto check output

$ quarto check
Quarto 1.4.550
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.58.3: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.550
      Path: 

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path:
      Version: 2023

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.2 (Conda)
      Path: 
      Jupyter: 5.5.0
      Kernels: 

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)
@catanzaromj catanzaromj added the bug Something isn't working label Mar 24, 2024
@mcanouil mcanouil added diagrams-mermaid Mermaid diagrams themes Related to HTML theming or any other style related issue (like highlight-style) labels Mar 24, 2024
@mcanouil
Copy link
Collaborator

mcanouil commented Mar 31, 2024

Reveal.js does not use Bootstrap contrary to other Quarto HTML based formats and since Mermaid.js does make a lot of releases with many changes, it's no surprise that Quarto is bit behind in terms of theming compatibility.
This will be improved as much as possible, meantime the more reliable (in regards to Mermaid.js updates) would be to using Mermaid internal themes such as the neutral theme, see https://quarto.org/docs/authoring/diagrams.html#using-mermaids-built-in-themes.:

image

@cderv
Copy link
Collaborator

cderv commented Apr 3, 2024

Some current workaround in the meantime share at

@rcannood
Copy link
Contributor

rcannood commented Jul 16, 2024

I'm closing #5416 in favour of creating separate, more specific issues. This issue seems like a good place to start!

I just updated the Mermaid demos in quarto to Quarto 1.5.54 using the Mermaid demos for Mermaid 10.2.4, and I can confirm that the described issue still persists in Quarto 1.5.54.

If it's ever necessary, I can update this demo page to verify whether the problem has been solved!


Mermaid docs on subgraphs: https://mermaid.js.org/syntax/flowchart.html#subgraphs

Screenshot from 2024-07-16 22-15-25


Output of the same example in Quarto 1.5.54: https://mermaid-demos-in-quarto.netlify.app/syntax/flowchart#subgraphs

Screenshot from 2024-07-16 22-16-12

@rcannood
Copy link
Contributor

It should be noted that the subgraph colours simply seem to be swapped between dark and light mode, because when I view the same diagram in dark mode, it is suddenly very bright.

Mermaid docs in dark mode:

Screenshot from 2024-07-16 22-29-29

Quarto render in dark mode:

Screenshot from 2024-07-16 22-29-34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working diagrams-mermaid Mermaid diagrams themes Related to HTML theming or any other style related issue (like highlight-style)
Projects
None yet
Development

No branches or pull requests

5 participants