nested group styling
This commit is contained in:
parent
823c788307
commit
c765298e39
8 changed files with 24 additions and 12 deletions
|
|
@ -330,13 +330,21 @@ func (l ContainerLevel) LabelSize() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *Object) GetFill(theme *d2themes.Theme) string {
|
func (obj *Object) GetFill(theme *d2themes.Theme) string {
|
||||||
|
level := int(obj.Level())
|
||||||
if obj.Parent.IsSequenceDiagram() {
|
if obj.Parent.IsSequenceDiagram() {
|
||||||
return theme.Colors.B5
|
return theme.Colors.B5
|
||||||
} else if obj.IsSequenceDiagramNote() {
|
} else if obj.IsSequenceDiagramNote() {
|
||||||
return theme.Colors.Neutrals.N7
|
return theme.Colors.Neutrals.N7
|
||||||
|
} else if obj.IsSequenceDiagramGroup() {
|
||||||
|
sd := obj.outerSequenceDiagram()
|
||||||
|
// Alternate
|
||||||
|
if (level-int(sd.Level()))%2 == 0 {
|
||||||
|
return theme.Colors.Neutrals.N7
|
||||||
|
} else {
|
||||||
|
return theme.Colors.Neutrals.N6
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
level := int(obj.Level())
|
|
||||||
shape := obj.Attributes.Shape.Value
|
shape := obj.Attributes.Shape.Value
|
||||||
|
|
||||||
if shape == "" || strings.EqualFold(shape, d2target.ShapeSquare) || strings.EqualFold(shape, d2target.ShapeCircle) || strings.EqualFold(shape, d2target.ShapeOval) || strings.EqualFold(shape, d2target.ShapeRectangle) {
|
if shape == "" || strings.EqualFold(shape, d2target.ShapeSquare) || strings.EqualFold(shape, d2target.ShapeCircle) || strings.EqualFold(shape, d2target.ShapeOval) || strings.EqualFold(shape, d2target.ShapeRectangle) {
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,18 @@ func (obj *Object) outerSequenceDiagram() *Object {
|
||||||
|
|
||||||
// groups are objects in sequence diagrams that have no messages connected
|
// groups are objects in sequence diagrams that have no messages connected
|
||||||
// and does not have a note as a child (a note can appear within a group, but it's a child of an actor)
|
// and does not have a note as a child (a note can appear within a group, but it's a child of an actor)
|
||||||
func (obj *Object) IsSequenceDiagramGroup(edges []*Edge) bool {
|
func (obj *Object) IsSequenceDiagramGroup() bool {
|
||||||
for _, e := range edges {
|
if obj.outerSequenceDiagram() == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, e := range obj.Graph.Edges {
|
||||||
if e.Src == obj || e.Dst == obj {
|
if e.Src == obj || e.Dst == obj {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, ch := range obj.ChildrenArray {
|
for _, ch := range obj.ChildrenArray {
|
||||||
// if the child contains a message, it's a span, not a note
|
// if the child contains a message, it's a span, not a note
|
||||||
if !ch.ContainsAnyEdge(edges) {
|
if !ch.ContainsAnyEdge(obj.Graph.Edges) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,8 +38,7 @@ func (obj *Object) IsSequenceDiagramGroup(edges []*Edge) bool {
|
||||||
|
|
||||||
// notes are descendant of actors with no edges and no children
|
// notes are descendant of actors with no edges and no children
|
||||||
func (obj *Object) IsSequenceDiagramNote() bool {
|
func (obj *Object) IsSequenceDiagramNote() bool {
|
||||||
sd := obj.outerSequenceDiagram()
|
if obj.outerSequenceDiagram() == nil {
|
||||||
if sd == nil {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !obj.hasEdgeRef() && !obj.ContainsAnyEdge(obj.Graph.Edges) && len(obj.ChildrenArray) == 0
|
return !obj.hasEdgeRef() && !obj.ContainsAnyEdge(obj.Graph.Edges) && len(obj.ChildrenArray) == 0
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se
|
||||||
var groups []*d2graph.Object
|
var groups []*d2graph.Object
|
||||||
|
|
||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
if obj.IsSequenceDiagramGroup(messages) {
|
if obj.IsSequenceDiagramGroup() {
|
||||||
queue := []*d2graph.Object{obj}
|
queue := []*d2graph.Object{obj}
|
||||||
// Groups may have more nested groups
|
// Groups may have more nested groups
|
||||||
for len(queue) > 0 {
|
for len(queue) > 0 {
|
||||||
|
|
@ -175,7 +175,6 @@ func (sd *sequenceDiagram) layout() error {
|
||||||
func (sd *sequenceDiagram) placeGroups() {
|
func (sd *sequenceDiagram) placeGroups() {
|
||||||
for _, group := range sd.groups {
|
for _, group := range sd.groups {
|
||||||
group.ZIndex = GROUP_Z_INDEX
|
group.ZIndex = GROUP_Z_INDEX
|
||||||
// group.Attributes.Style.Opacity = &d2graph.Scalar{Value: "0.5"}
|
|
||||||
sd.placeGroup(group)
|
sd.placeGroup(group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ type Neutral struct {
|
||||||
N3 string `json:"n3"`
|
N3 string `json:"n3"`
|
||||||
N4 string `json:"n4"`
|
N4 string `json:"n4"`
|
||||||
N5 string `json:"n5"`
|
N5 string `json:"n5"`
|
||||||
|
N6 string `json:"n6"`
|
||||||
N7 string `json:"n7"`
|
N7 string `json:"n7"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,6 +45,7 @@ var CoolNeutral = Neutral{
|
||||||
N3: "#9499AB",
|
N3: "#9499AB",
|
||||||
N4: "#CFD2DD",
|
N4: "#CFD2DD",
|
||||||
N5: "#F0F3F9",
|
N5: "#F0F3F9",
|
||||||
|
N6: "#EEF1F8",
|
||||||
N7: "#FFFFFF",
|
N7: "#FFFFFF",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,5 +55,6 @@ var WarmNeutral = Neutral{
|
||||||
N3: "#787777",
|
N3: "#787777",
|
||||||
N4: "#CCCACA",
|
N4: "#CCCACA",
|
||||||
N5: "#DFDCDC",
|
N5: "#DFDCDC",
|
||||||
|
N6: "#ECEBEB",
|
||||||
N7: "#FFFFFF",
|
N7: "#FFFFFF",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json
generated
vendored
2
e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json
generated
vendored
|
|
@ -246,7 +246,7 @@
|
||||||
"strokeDash": 0,
|
"strokeDash": 0,
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
"borderRadius": 0,
|
"borderRadius": 0,
|
||||||
"fill": "#EDF0FD",
|
"fill": "#FFFFFF",
|
||||||
"stroke": "#0D32B2",
|
"stroke": "#0D32B2",
|
||||||
"shadow": false,
|
"shadow": false,
|
||||||
"3d": false,
|
"3d": false,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
2
e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json
generated
vendored
2
e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json
generated
vendored
|
|
@ -246,7 +246,7 @@
|
||||||
"strokeDash": 0,
|
"strokeDash": 0,
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
"borderRadius": 0,
|
"borderRadius": 0,
|
||||||
"fill": "#EDF0FD",
|
"fill": "#FFFFFF",
|
||||||
"stroke": "#0D32B2",
|
"stroke": "#0D32B2",
|
||||||
"shadow": false,
|
"shadow": false,
|
||||||
"3d": false,
|
"3d": false,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
Loading…
Reference in a new issue