Skip to content

In a Sequence Diagram the primaryColor config is ignored for participants' background color  #5034

Closed
@ebouchut

Description

@ebouchut
Contributor

Context

I configured a primaryColor in a sequence diagram on a page of a site using mkdocs-material version 9.0.12.
I expect the background color of the participant box to be the same as primaryColor, whereas it is not.

%%{
  init: {
    'theme': 'base',
      'themeVariables': {
        'primaryColor': 'lightgreen'
    }
  }
}%%
sequenceDiagram
    actor       user as User
    participant p    as Button

    user   ->>  p: click

Bug description

The diagram is not rendered as expected:

  • ✅ The background color of the actor box (User) is the same as primaryColor which is expected.
  • ❌ The background color of the participant box (Button) is white, which is not expected, I 🤔 .

Both Mermaid Live Editor and Github Previewer, use the primaryColor for the participant's background color. This is what I expected mkdocs-material to do.

My understanding of mermaid.js documentation is the following:

  • actorBkg mentions that primaryColor is the default background color for an actor.
  • MainBkg computed from primaryColor "should be" used in this case.

🤔 This is my understanding of this gray part of the documentation.
Let me know what you think about this.

Loading
%%{
  init: {
    'theme': 'base',
      'themeVariables': {
        'primaryColor': 'lightgreen'
    }
  }
}%%
sequenceDiagram
    actor       user as User
    participant p    as Button

    user   ->>  p: click

Related links

Reproduction

example.zip

Steps to reproduce

  1. Open http://127.0.0.1:8000/diagram/
  2. In the sequence diagram, the background color of both the actor (User) and the participant (Button) boxes should be green.

Browser

No response

Before submitting

Activity

changed the title [-]In a Sequence Diagram the primaryColor config is ignored for participants background color [/-] [+]In a Sequence Diagram the primaryColor config is ignored for participants' background color [/+] on Feb 12, 2023
squidfunk

squidfunk commented on Feb 18, 2023

@squidfunk
Owner

Thanks for reporting. Material for MkDocs Mermaid integration is a bit different – it automatically sets the colors to the accent color you choose when configuring the theme. We use CSS variables to override specific parts of Mermaid graphs.

This has several upsides, as mentioned in our documentation:

  • Works with instant loading without any additional effort
  • Diagrams automatically use fonts and colors defined in mkdocs.yml
  • Fonts and colors can be customized with additional style sheets
  • Support for both, light and dark color schemes

Fixed in 5065bf9. The sequence actors, which were rendered green in your example, are now also rendered using the defined accent color. This is consistent with the rendering of the rest of our Mermaid integration:

Bildschirmfoto 2023-02-18 um 10 40 32

Additionally, this commit introduces a way to override accent colors on a per-diagram basis. When md_in_html is enabled, You can now wrap a Mermaid diagram with an accent color directive (possible values defined here):

<div data-md-color-accent="green" markdown>

``` mermaid
sequenceDiagram
    actor       user     as User
    participant p   as Button

    user     ->>  p: click
```

</div>

If you wish to override colors for all Mermaid diagrams, use additional CSS and override the variables defined here:

// All definitions
.mermaid {
--md-mermaid-font-family: var(--md-text-font-family), sans-serif;
// Colors
--md-mermaid-edge-color: var(--md-code-fg-color);
--md-mermaid-node-bg-color: var(--md-accent-fg-color--transparent);
--md-mermaid-node-fg-color: var(--md-accent-fg-color);
--md-mermaid-label-bg-color: var(--md-default-bg-color);
--md-mermaid-label-fg-color: var(--md-code-fg-color);
// Mermaid container
margin: 1em 0;
line-height: normal;
}

added
bugIssue reports a bug
resolvedIssue is resolved, yet unreleased if open
and removed
needs investigationIssue must be investigated by the maintainers
on Feb 18, 2023
squidfunk

squidfunk commented on Feb 18, 2023

@squidfunk
Owner

Released as part of 9.0.13.

ebouchut

ebouchut commented on Feb 19, 2023

@ebouchut
ContributorAuthor

👍 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ebouchut@squidfunk

        Issue actions

          In a Sequence Diagram the primaryColor config is ignored for participants' background color · Issue #5034 · squidfunk/mkdocs-material