-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Feature/523 Add Style option to sequence diagram actors #6234
base: develop
Are you sure you want to change the base?
Feature/523 Add Style option to sequence diagram actors #6234
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 #6234 +/- ##
==========================================
- Coverage 4.47% 4.47% -0.01%
==========================================
Files 384 385 +1
Lines 54179 54207 +28
Branches 623 598 -25
==========================================
Hits 2425 2425
- Misses 51754 51782 +28
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -84,7 +85,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili | |||
\-\-[x] return 'DOTTED_CROSS'; | |||
\-[\)] return 'SOLID_POINT'; | |||
\-\-[\)] return 'DOTTED_POINT'; | |||
":"(?:(?:no)?wrap:)?[^#\n;]+ return 'TXT'; |
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.
Removing #
here so that CSS colors (e.g. #FFC0CB) can be passed.
Unsure why the #
was here in the first place. Please double check if it's safe to remove it.
📑 Summary
As described in #523, it would be nice if we could style the actors of the sequence diagram. Basic styling makes larger sequence diagrams easier to read, and is for many users (including me) a reason to use other tools instead of mermaid.
This PR introduces the
style
keyword, allowing users to add style to specific actors of the sequence diagram.Example:
Output:
Resolves #523
📏 Design Decisions
First time contributing to the mermaid codebase, so not very familiar yet. Let me know if you think this solution makes sense.
This PR makes the following changes:
style
keyword to sequence diagram JISON definition.style_statement
this keyword takes in the actor, and the text after the:
and passes it to thesetCssStyle
function.setCssStyle
function tosequenceDb.ts
. This function retrieves the actor based on its ID and then sets itsstyle
attribute to the defined style (e.g.fill:pink, stroke:red
). We replace,
by;
so that the defined style becomes valid CSS.actor.style
attribute is then accessed insequenceRender.ts
andsvgDraw.ts
and passed to therect
objects by settingrect.attr
to{ style }
.Haven't added any tests / docs yet. First wanted to get some feedback 😄
📋 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:
.