-
Notifications
You must be signed in to change notification settings - Fork 85
fix(ui): make mermaid diagrams readable in dark mode #770
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
Closed
Anshumancanrock
wants to merge
1
commit into
Project-HAMi:master
from
Anshumancanrock:fix/mermaid-dark-mode
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Project-HAMi/website
Length of output: 16990
🌐 Web query:
Mermaid flowchart styles edgeLabel labelBkg edgeLabel rect SVG HTML label backgrounds current source💡 Result:
In Mermaid flowcharts, customizing the background of edge labels is primarily managed through global theme configuration rather than individual link styling. Theme Configuration The standard way to change the edge label background color is by setting the edgeLabelBackground variable within the themeVariables configuration [1][2][3]. This affects all edge labels in the diagram: { "themeVariables": { "edgeLabelBackground": "
#ffcc00" } } Custom CSS For more granular or advanced control, you can inject custom CSS using the themeCSS option during mermaid.initialize. This allows you to target the.edgeLabel class directly [1]: mermaid.initialize({ theme: 'base', themeCSS:.edgeLabel { background-color:#ffe; }}); Current Technical Limitations There is currently no direct, native support for overriding the background color of a single, specific edge label using the linkStyle syntax [4][5]. 1. LinkStyle Limitations: The linkStyle command is intended for attributes like stroke, stroke-width, and color [4]. Attempts to use background-color within a linkStyle definition are often ineffective because the property is incorrectly applied to the path element (which does not support it) rather than the edge label's container [4][5]. 2. Class Targeting: While you can define custom CSS classes for specific edges (by attaching IDs to edges and applying CSS), the internal structure of Mermaid's edge labels—which often use foreignObject and div elements—makes consistent background styling via CSS sometimes complex or dependent on specific renderer versions [6][4]. For most use cases, developers use the global theme variable or broad CSS overrides as the standard approach [5][1].Citations:
🏁 Script executed:
Repository: Project-HAMi/website
Length of output: 4911
🌐 Web query:
site:github.com/mermaid-js/mermaid/blob/mermaid%4011.15.0 packages/mermaid/src/diagrams/flowchart/styles.ts edgeLabel labelBkg💡 Result:
In the Mermaid.js codebase, specifically within packages/mermaid/src/diagrams/flowchart/styles.ts, edgeLabel and labelBkg are CSS classes used to style edge labels and their backgrounds in flowcharts [1]. The edgeLabel class defines the styling for the container of an edge label, setting its background color using the options.edgeLabelBackground property [1]. It includes specific rules for internal elements:.edgeLabel { background-color: ${options.edgeLabelBackground}; p { background-color: ${options.edgeLabelBackground}; } rect { opacity: 0.5; background-color: ${options.edgeLabelBackground}; fill: ${options.edgeLabelBackground}; } text-align: center; } The labelBkg class is specifically intended for HTML labels [1]. It applies a semi-transparent background color, calculated using a fade function on the edge label background option [1]:.labelBkg { background-color: ${fade(options.edgeLabelBackground, 0.5)}; } In the rendering logic (found in packages/mermaid/src/rendering-util/createText.ts), the addHtmlLabel function applies the labelBkg class to the label div when background rendering is enabled (addBackground = true) [2][3]. The code distinguishes between node labels and edge labels by assigning either nodeLabel or edgeLabel as the primary class, and further applies the labelBkg class if a background is required for that label element [2][3].
Citations:
Style all Mermaid edge-label backgrounds.
Set
background-coloron.edgeLabel pand.labelBkg. Set bothbackground-colorandfillon.edgeLabel rectso HTML and SVG labels usevar(--ifm-background-color).🤖 Prompt for AI Agents