-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix contrast for mermaid diagram elements in dark-mode #11108
Fix contrast for mermaid diagram elements in dark-mode #11108
Conversation
Noticed no recent open issues for Mermaid diagrams other than darkreader#7047 (which was just a listing of the mermaid websites) and a bunch of older issues https://github.com/darkreader/darkreader/issues?q=mermaid that didn't seem too relevant. Attempted to define generally applicable fixes for mermaid diagrams embedded in pages. Not sure if the place where I listed this is too general, but I've tested it on: - Mermaid Live Editor (https://mermaid-js.github.io/mermaid-live-editor) - mermaid in Markdown or Orgdown on GitHub - mermaid in Markdown or Orgdown on GitLab (see some docs at https://about.gitlab.com/handbook/tools-and-tips/mermaid/) Changes made to: - controls For the sake of completeness, I repeat some of the diagrams (from the live editor samples) that were causing issues for me in dark mode in Chromium. These show show up in GitHub with some elements having light backgrounds and light text, rendering the diagrams more-or-less unreadable (poor contrast between bg and text). ```mermaid flowchart TD A[Christmas] -->|Get money| B(Go shopping) B --> C{Let me think} C -->|One| D[Laptop] C -->|Two| E[iPhone] C -->|Three| F[fa:fa-car Car] ``` ```mermaid erDiagram CUSTOMER }|..|{ DELIVERY-ADDRESS : has CUSTOMER ||--o{ ORDER : places CUSTOMER ||--o{ INVOICE : "liable for" DELIVERY-ADDRESS ||--o{ ORDER : receives INVOICE ||--|{ ORDER : covers ORDER ||--|{ ORDER-ITEM : includes PRODUCT-CATEGORY ||--|{ PRODUCT : contains PRODUCT ||--o{ ORDER-ITEM : "ordered in" ``` ```mermaid gantt title A Gantt Diagram dateFormat YYYY-MM-DD section Section A task :a1, 2014-01-01, 30d Another task :after a1 , 20d section Another Task in sec :2014-01-12 , 12d another task : 24d ```
edc6190
to
027f5eb
Compare
In GitHub, the mermaid diagrams is classes with Sequence DiagramsequenceDiagram
Alice->>+John: Hello John, how are you?
Alice->>+John: John, can you hear me?
John-->>-Alice: Hi Alice, I can hear you!
John-->>-Alice: I feel great!
|
) * fix: Improve contrast for Mermaid diagrams elements and controls Noticed no recent open issues for Mermaid diagrams other than darkreader#7047 (which was just a listing of the mermaid websites) and a bunch of older issues https://github.com/darkreader/darkreader/issues?q=mermaid that didn't seem too relevant. Attempted to define generally applicable fixes for mermaid diagrams embedded in pages. Not sure if the place where I listed this is too general, but I've tested it on: - Mermaid Live Editor (https://mermaid-js.github.io/mermaid-live-editor) - mermaid in Markdown or Orgdown on GitHub - mermaid in Markdown or Orgdown on GitLab (see some docs at https://about.gitlab.com/handbook/tools-and-tips/mermaid/) Changes made to: - controls For the sake of completeness, I repeat some of the diagrams (from the live editor samples) that were causing issues for me in dark mode in Chromium. These show show up in GitHub with some elements having light backgrounds and light text, rendering the diagrams more-or-less unreadable (poor contrast between bg and text). ```mermaid flowchart TD A[Christmas] -->|Get money| B(Go shopping) B --> C{Let me think} C -->|One| D[Laptop] C -->|Two| E[iPhone] C -->|Three| F[fa:fa-car Car] ``` ```mermaid erDiagram CUSTOMER }|..|{ DELIVERY-ADDRESS : has CUSTOMER ||--o{ ORDER : places CUSTOMER ||--o{ INVOICE : "liable for" DELIVERY-ADDRESS ||--o{ ORDER : receives INVOICE ||--|{ ORDER : covers ORDER ||--|{ ORDER-ITEM : includes PRODUCT-CATEGORY ||--|{ PRODUCT : contains PRODUCT ||--o{ ORDER-ITEM : "ordered in" ``` ```mermaid gantt title A Gantt Diagram dateFormat YYYY-MM-DD section Section A task :a1, 2014-01-01, 30d Another task :after a1 , 20d section Another Task in sec :2014-01-12 , 12d another task : 24d ``` * chore: Use only variables outlined in CONTRIBUTING * feat: Set stroke for mermaid sequence diagram message lines * fix: Also cover returning messages in mermaid sequence diagram * feat: Set actor fill for mermaid diagrams on GitHub
Issue
When switching to dark mode on some diagram types, the backgrounds do not change to offer sufficient contrast to be able to read the text within some elements of those diagrams.
Relevant or related issues
Noticed no recent open issues for Mermaid diagrams other than #7047 (which was just a listing of the mermaid websites) and a bunch of older issues https://github.com/darkreader/darkreader/issues?q=mermaid that didn't seem too relevant.
Solution
Attempted to define generally applicable fixes for mermaid diagrams embedded in pages. Since mermaid diagrams can appear on a variety of pages, I reckoned that the top of the dynamic-theme-fixes.config file was a correct place for the changes. These fixes should be general enough but let me know if this design choice is not in line with the project design constraints/goals.
Changes
rect
s andpolygon
sTesting
Tested on:
Examples
For the sake of completeness, I repeat some of the diagrams (from the live editor samples) that were causing issues for me in dark mode in Chromium. These show show up in GitHub with some elements having light backgrounds and light text, rendering the diagrams more-or-less unreadable (poor contrast between bg and text).
Flowcharts
Problematic diagram
](url)
Fixed diagram
ER Diagrams
Problematic diagram
Fixed diagram
Gantt Diagrams
Problematic diagram
Fixed diagram
Sequence Diagram
Problematic diagram
Solved diagram