mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-15 02:04:08 +01:00
#2088 Add the possibility to theme forks and joins using theme variables
This commit is contained in:
@@ -66,22 +66,13 @@ stateDiagram-v2
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||||
%%{init:{"theme":"base", "themeVariables": {"primaryColor":"#411d4e", "titleColor":"white", "darkMode":true}}}%%
|
%%{init:{"theme":"neutral", "themeVariables": {"stateBkg ":"red", "innerEndBackground":"red"}}}%%
|
||||||
flowchart LR
|
stateDiagram-v2
|
||||||
|
state fork [[fork]]
|
||||||
subgraph TOP
|
state join [[join]]
|
||||||
direction TB
|
[*] --> fork
|
||||||
subgraph B1
|
fork --> join
|
||||||
direction RL
|
join --> [*]
|
||||||
i1 -->f1
|
|
||||||
end
|
|
||||||
subgraph B2
|
|
||||||
direction BT
|
|
||||||
i2 -->f2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
A --> TOP --> B
|
|
||||||
B1 --> B2
|
|
||||||
</div>
|
</div>
|
||||||
<script src="./mermaid.js"></script>
|
<script src="./mermaid.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -567,8 +567,6 @@ const forkJoin = (parent, node, dir) => {
|
|||||||
|
|
||||||
const shape = shapeSvg
|
const shape = shapeSvg
|
||||||
.append('rect')
|
.append('rect')
|
||||||
.style('stroke', 'black')
|
|
||||||
.style('fill', 'black')
|
|
||||||
.attr('x', (-1 * width) / 2)
|
.attr('x', (-1 * width) / 2)
|
||||||
.attr('y', (-1 * height) / 2)
|
.attr('y', (-1 * height) / 2)
|
||||||
.attr('width', width)
|
.attr('width', width)
|
||||||
|
|||||||
@@ -82,11 +82,17 @@ g.stateGroup line {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.node circle.state-start {
|
.node circle.state-start {
|
||||||
fill: ${options.lineColor};
|
fill: ${options.stateBorder || options.lineColor};
|
||||||
stroke: black;
|
stroke: ${options.stateBorder || options.lineColor};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.node .fork-join {
|
||||||
|
fill: ${options.stateBorder};
|
||||||
|
stroke: ${options.stateBorder};
|
||||||
|
}
|
||||||
|
|
||||||
.node circle.state-end {
|
.node circle.state-end {
|
||||||
fill: ${options.primaryBorderColor};
|
fill: ${options.innerEndBackground || options.primaryBorderColor};
|
||||||
stroke: ${options.background};
|
stroke: ${options.background};
|
||||||
stroke-width: 1.5
|
stroke-width: 1.5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class Theme {
|
|||||||
this.altBackground = this.altBackground || this.tertiaryColor;
|
this.altBackground = this.altBackground || this.tertiaryColor;
|
||||||
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
||||||
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
||||||
|
this.innerEndBackground = this.primaryBorderColor;
|
||||||
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
||||||
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
||||||
this.transitionColor = this.transitionColor || this.lineColor;
|
this.transitionColor = this.transitionColor || this.lineColor;
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class Theme {
|
|||||||
this.altBackground = this.altBackground || '#555';
|
this.altBackground = this.altBackground || '#555';
|
||||||
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
||||||
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
||||||
|
this.innerEndBackground = this.primaryBorderColor;
|
||||||
|
|
||||||
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
||||||
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ class Theme {
|
|||||||
this.altBackground = this.altBackground || '#f0f0f0';
|
this.altBackground = this.altBackground || '#f0f0f0';
|
||||||
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
||||||
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
||||||
|
this.innerEndBackground = this.primaryBorderColor;
|
||||||
|
|
||||||
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
||||||
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class Theme {
|
|||||||
this.altBackground = this.altBackground || '#f0f0f0';
|
this.altBackground = this.altBackground || '#f0f0f0';
|
||||||
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
||||||
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
this.compositeBorder = this.compositeBorder || this.nodeBorder;
|
||||||
|
this.innerEndBackground = this.primaryBorderColor;
|
||||||
|
|
||||||
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
||||||
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ class Theme {
|
|||||||
this.altBackground = this.altBackground || '#f4f4f4';
|
this.altBackground = this.altBackground || '#f4f4f4';
|
||||||
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg;
|
||||||
this.stateBorder = this.stateBorder || '#000';
|
this.stateBorder = this.stateBorder || '#000';
|
||||||
|
this.innerEndBackground = this.primaryBorderColor;
|
||||||
|
|
||||||
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
this.errorBkgColor = this.errorBkgColor || this.tertiaryColor;
|
||||||
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
this.errorTextColor = this.errorTextColor || this.tertiaryTextColor;
|
||||||
|
|||||||
Reference in New Issue
Block a user