-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
6256 - Allow themeVariables to have additional valid CSS colors #6261
base: develop
Are you sure you want to change the base?
6256 - Allow themeVariables to have additional valid CSS colors #6261
Conversation
|
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6261 +/- ##
=======================================
Coverage 4.47% 4.47%
=======================================
Files 385 384 -1
Lines 54191 54180 -11
Branches 598 623 +25
=======================================
Hits 2425 2425
+ Misses 51766 51755 -11
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hi @MikeSQ,Thank you for your work on this PR! I tested it locally, and here are my findings: What Works
Remaining IssuesThis PR aims to resolve Issue #6256, but I encountered the following problems during testing:
Next StepsWould love to hear your thoughts on this! Best, |
Oh thank you for taking a look @nour0205 ! I had only been testing with the sequence diagram, as that was the one I had been working with when I wanted to allow easier conversion between light mode and dark mode. It had worked fine there, I assumed that it would be similar in other diagrams if it worked there. I was pretty excited to see it working fine in the deployed netlify branch haha I haven't really worked with the Mermaid library source before, do you know if this somehow has another blocker that makes it a bad idea? I'd really like to get support for these things if we can, but I don't know if it somehow runs counter to original design intentions |
Interesting, I did a bit more testing, and it looks like it only cares a lot about mermaid.initialize({
startOnLoad: true,
logLevel: 0,
themeVariables: {
primaryColor: "blue", //Threw error with dashes
secondaryColor: "blue", //Threw error with dashes
tertiaryColor: "var(--sd-hotpink)", //Works fine
activationBkgColor: "light-dark(var(--sd-hotpink),green)", //Fine
activationBorderColor: "rebeccapurple", //Fine
activeTaskBkgColor: "#123abc" //Fine
}
}); edit: Further investigation shows that it really depends on what theme you have chosen and how much it relies on those base colors for calculating variable values in the theme's I don't know what the best way to solve this might be. Possibly just allowing dashes in the non-base-color variables? Those are the ones that seem most likely to have color math applied to them. It would be great if it was supported everywhere, but I don't know if there is a reliable way to resolve the css function stuff to colors prior to the math is attempted. |
Hi @MikeSQ, Thanks for your additional testing! The fact that tertiaryColor works in some themes but not others suggests that certain themes apply dynamic calculations ( Your idea of allowing dashes only in non-base colors seems like a practical approach, as those are less likely to be used in calculations. If a more complete fix is needed, ensuring that CSS variables pass through where possible but are skipped in places where math is applied could be worth exploring. Thanks again for your great work on this PR! Best, |
📑 Summary
This is to resolve the recent issue I submitted. Before this PR there are several color options that can't be used without the sanitization stripping them out. After the PR, you should be able to set a themeVariable to:
For me, this will enable easy theming of the diagrams based on user selection of light mode or dark mode, but in general it should open up a lot of theming possibilities for everybody I think.
This is my first PR on a major project, so apologies if I make any mistakes :)
Resolves #6256
📏 Design Decisions
The only change here was to the regular expression, I tried to do the bare minimum to allow the CSS. Dashes were added which covers most of the features above, I also added the ability to do
*
,+
,/
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.