fix group label position

This commit is contained in:
Alexander Wang 2022-12-23 13:16:33 -08:00
parent 17f4e05cce
commit 745900b137
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
19 changed files with 306 additions and 50 deletions

View file

@ -8,6 +8,7 @@ import (
"cdr.dev/slog"
tassert "github.com/stretchr/testify/assert"
"oss.terrastruct.com/util-go/assert"
"oss.terrastruct.com/util-go/diff"
@ -80,6 +81,23 @@ y: {shape: square}
}
},
},
{
name: "sequence_group_position",
dsl: `hey {
shape: sequence_diagram
a
b
group: {
a -> b
}
}
`,
assertions: func(t *testing.T, d *d2target.Diagram) {
tassert.Equal(t, "hey.group", d.Shapes[3].ID)
tassert.Equal(t, "INSIDE_TOP_LEFT", d.Shapes[3].LabelPosition)
},
},
}
runa(t, tcs)

View file

@ -74,6 +74,7 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se
// Groups may have more nested groups
for len(queue) > 0 {
curr := queue[0]
curr.LabelPosition = go2.Pointer(string(label.InsideTopLeft))
groups = append(groups, curr)
queue = queue[1:]
queue = append(queue, curr.ChildrenArray...)

View file

@ -198,6 +198,7 @@
"underline": false,
"labelWidth": 30,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -237,6 +238,7 @@
"underline": false,
"labelWidth": 57,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -276,6 +278,7 @@
"underline": false,
"labelWidth": 78,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -315,6 +318,7 @@
"underline": false,
"labelWidth": 58,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -394,6 +398,7 @@
"underline": false,
"labelWidth": 38,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 477 KiB

After

Width:  |  Height:  |  Size: 477 KiB

View file

@ -198,6 +198,7 @@
"underline": false,
"labelWidth": 30,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -237,6 +238,7 @@
"underline": false,
"labelWidth": 57,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -276,6 +278,7 @@
"underline": false,
"labelWidth": 78,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -315,6 +318,7 @@
"underline": false,
"labelWidth": 58,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -394,6 +398,7 @@
"underline": false,
"labelWidth": 38,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 477 KiB

After

Width:  |  Height:  |  Size: 477 KiB

View file

@ -158,6 +158,7 @@
"underline": false,
"labelWidth": 160,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -197,6 +198,7 @@
"underline": false,
"labelWidth": 238,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -236,6 +238,7 @@
"underline": false,
"labelWidth": 173,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 3
},
@ -275,6 +278,7 @@
"underline": false,
"labelWidth": 77,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 4
},
@ -354,6 +358,7 @@
"underline": false,
"labelWidth": 41,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 5
},
@ -393,6 +398,7 @@
"underline": false,
"labelWidth": 24,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -432,6 +438,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -471,6 +478,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -510,6 +518,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -549,6 +558,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 335 KiB

After

Width:  |  Height:  |  Size: 335 KiB

View file

@ -158,6 +158,7 @@
"underline": false,
"labelWidth": 160,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -197,6 +198,7 @@
"underline": false,
"labelWidth": 238,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -236,6 +238,7 @@
"underline": false,
"labelWidth": 173,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 3
},
@ -275,6 +278,7 @@
"underline": false,
"labelWidth": 77,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 4
},
@ -354,6 +358,7 @@
"underline": false,
"labelWidth": 41,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 5
},
@ -393,6 +398,7 @@
"underline": false,
"labelWidth": 24,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -432,6 +438,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -471,6 +478,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -510,6 +518,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -549,6 +558,7 @@
"underline": false,
"labelWidth": 47,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 335 KiB

After

Width:  |  Height:  |  Size: 335 KiB

View file

@ -478,6 +478,7 @@
"underline": false,
"labelWidth": 185,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 481 KiB

After

Width:  |  Height:  |  Size: 481 KiB

View file

@ -478,6 +478,7 @@
"underline": false,
"labelWidth": 185,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 481 KiB

After

Width:  |  Height:  |  Size: 481 KiB

View file

@ -158,6 +158,7 @@
"underline": false,
"labelWidth": 160,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -197,6 +198,7 @@
"underline": false,
"labelWidth": 238,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -236,6 +238,7 @@
"underline": false,
"labelWidth": 173,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 3
},
@ -275,6 +278,7 @@
"underline": false,
"labelWidth": 21,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 4
},
@ -314,6 +318,7 @@
"underline": false,
"labelWidth": 21,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 5
}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 330 KiB

After

Width:  |  Height:  |  Size: 330 KiB

View file

@ -158,6 +158,7 @@
"underline": false,
"labelWidth": 160,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 1
},
@ -197,6 +198,7 @@
"underline": false,
"labelWidth": 238,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 2
},
@ -236,6 +238,7 @@
"underline": false,
"labelWidth": 173,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 3
},
@ -275,6 +278,7 @@
"underline": false,
"labelWidth": 21,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 4
},
@ -314,6 +318,7 @@
"underline": false,
"labelWidth": 21,
"labelHeight": 26,
"labelPosition": "INSIDE_TOP_LEFT",
"zIndex": 3,
"level": 5
}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 330 KiB

After

Width:  |  Height:  |  Size: 330 KiB

View file

@ -0,0 +1,195 @@
{
"name": "",
"fontFamily": "SourceSansPro",
"shapes": [
{
"id": "hey",
"type": "sequence_diagram",
"pos": {
"x": 0,
"y": 0
},
"width": 0,
"height": 0,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 0,
"borderRadius": 0,
"fill": "#FFFFFF",
"stroke": "#0D32B2",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": false,
"fields": null,
"methods": null,
"columns": null,
"label": "hey",
"fontSize": 28,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"zIndex": 0,
"level": 1
},
{
"id": "hey.a",
"type": "",
"pos": {
"x": 0,
"y": 0
},
"width": 0,
"height": 0,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"stroke": "#0D32B2",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": false,
"fields": null,
"methods": null,
"columns": null,
"label": "a",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"zIndex": 0,
"level": 2
},
{
"id": "hey.b",
"type": "",
"pos": {
"x": 0,
"y": 0
},
"width": 0,
"height": 0,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"stroke": "#0D32B2",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": false,
"fields": null,
"methods": null,
"columns": null,
"label": "b",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"zIndex": 0,
"level": 2
},
{
"id": "hey.group",
"type": "",
"pos": {
"x": 0,
"y": 0
},
"width": 0,
"height": 0,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 0,
"borderRadius": 0,
"fill": "#DEE1EB",
"stroke": "#0D32B2",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"blend": true,
"fields": null,
"methods": null,
"columns": null,
"label": "group",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"zIndex": 0,
"level": 2
}
],
"connections": [
{
"id": "hey.(a -> b)[0]",
"src": "hey.a",
"srcArrow": "none",
"srcLabel": "",
"dst": "hey.b",
"dstArrow": "triangle",
"dstLabel": "",
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"stroke": "#0D32B2",
"label": "",
"fontSize": 16,
"fontFamily": "DEFAULT",
"language": "",
"color": "#676C7E",
"italic": true,
"bold": false,
"underline": false,
"labelWidth": 0,
"labelHeight": 0,
"labelPosition": "",
"labelPercentage": 0,
"route": [],
"isCurve": true,
"animated": false,
"tooltip": "",
"icon": null,
"zIndex": 0
}
]
}