Lifeline should inherit the stroke style from the actor

Fixes #1137
This commit is contained in:
Stoica Alex 2023-04-06 21:36:06 +01:00
parent d1c980ddc0
commit 2a93d21420
No known key found for this signature in database
GPG key ID: 221CE76471A10868
15 changed files with 510 additions and 498 deletions

View file

@ -5,6 +5,7 @@
#### Improvements 🧹 #### Improvements 🧹
- Labels on parallel `dagre` connections include a gap between them [#1134](https://github.com/terrastruct/d2/pull/1134) - Labels on parallel `dagre` connections include a gap between them [#1134](https://github.com/terrastruct/d2/pull/1134)
- Sequence Diagram `Lifelines` now inherit the Actor `stroke` and `stroke-dash` [#1140](https://github.com/terrastruct/d2/pull/1140)
#### Bugfixes ⛑️ #### Bugfixes ⛑️

View file

@ -386,13 +386,19 @@ func (sd *sequenceDiagram) addLifelineEdges() {
} }
actorLifelineEnd := actor.Center() actorLifelineEnd := actor.Center()
actorLifelineEnd.Y = endY actorLifelineEnd.Y = endY
sd.lifelines = append(sd.lifelines, &d2graph.Edge{ style := d2graph.Style{
Attributes: &d2graph.Attributes{
Style: d2graph.Style{
StrokeDash: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_DASH)}, StrokeDash: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_DASH)},
StrokeWidth: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_WIDTH)}, StrokeWidth: &d2graph.Scalar{Value: fmt.Sprintf("%d", LIFELINE_STROKE_WIDTH)},
}, }
}, if actor.Attributes.Style.StrokeDash != nil {
style.StrokeDash = &d2graph.Scalar{Value: actor.Attributes.Style.StrokeDash.Value}
}
if actor.Attributes.Style.Stroke != nil {
style.Stroke = &d2graph.Scalar{Value: actor.Attributes.Style.Stroke.Value}
}
sd.lifelines = append(sd.lifelines, &d2graph.Edge{
Attributes: &d2graph.Attributes{Style: style},
Src: actor, Src: actor,
SrcArrow: false, SrcArrow: false,
Dst: &d2graph.Object{ Dst: &d2graph.Object{

View file

@ -1487,8 +1487,13 @@ finally: {
sequence: { sequence: {
shape: sequence_diagram shape: sequence_diagram
# items appear in this order # items appear in this order
scorer scorer {
concept style.stroke: red
style.stroke-dash: 2
}
concept {
style.stroke-width: 6
}
essayRubric essayRubric
item item
itemOutcome itemOutcome

View file

@ -1302,7 +1302,7 @@
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 6,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -1302,7 +1302,7 @@
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 6,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -621,7 +621,7 @@
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 6,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -621,7 +621,7 @@
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 6,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

@ -1672,11 +1672,11 @@
"width": 100, "width": 100,
"height": 66, "height": 66,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 2,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "B5", "fill": "B5",
"stroke": "B1", "stroke": "red",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
"multiple": false, "multiple": false,
@ -1714,7 +1714,7 @@
"height": 66, "height": 66,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 6,
"borderRadius": 0, "borderRadius": 0,
"fill": "B5", "fill": "B5",
"stroke": "B1", "stroke": "B1",
@ -4744,9 +4744,9 @@
"dstArrow": "none", "dstArrow": "none",
"dstLabel": "", "dstLabel": "",
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 2,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View file

@ -1672,11 +1672,11 @@
"width": 100, "width": 100,
"height": 66, "height": 66,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 2,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "B5", "fill": "B5",
"stroke": "B1", "stroke": "red",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
"multiple": false, "multiple": false,
@ -1714,7 +1714,7 @@
"height": 66, "height": 66,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 6,
"borderRadius": 0, "borderRadius": 0,
"fill": "B5", "fill": "B5",
"stroke": "B1", "stroke": "B1",
@ -4655,9 +4655,9 @@
"dstArrow": "none", "dstArrow": "none",
"dstLabel": "", "dstLabel": "",
"opacity": 1, "opacity": 1,
"strokeDash": 6, "strokeDash": 2,
"strokeWidth": 2, "strokeWidth": 2,
"stroke": "B2", "stroke": "red",
"borderRadius": 10, "borderRadius": 10,
"label": "", "label": "",
"fontSize": 16, "fontSize": 16,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB