nested group styling

This commit is contained in:
Alexander Wang 2022-12-04 21:57:59 -08:00
parent 823c788307
commit c765298e39
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
8 changed files with 24 additions and 12 deletions

View file

@ -330,13 +330,21 @@ func (l ContainerLevel) LabelSize() int {
}
func (obj *Object) GetFill(theme *d2themes.Theme) string {
level := int(obj.Level())
if obj.Parent.IsSequenceDiagram() {
return theme.Colors.B5
} else if obj.IsSequenceDiagramNote() {
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
if shape == "" || strings.EqualFold(shape, d2target.ShapeSquare) || strings.EqualFold(shape, d2target.ShapeCircle) || strings.EqualFold(shape, d2target.ShapeOval) || strings.EqualFold(shape, d2target.ShapeRectangle) {

View file

@ -18,15 +18,18 @@ func (obj *Object) outerSequenceDiagram() *Object {
// 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)
func (obj *Object) IsSequenceDiagramGroup(edges []*Edge) bool {
for _, e := range edges {
func (obj *Object) IsSequenceDiagramGroup() bool {
if obj.outerSequenceDiagram() == nil {
return false
}
for _, e := range obj.Graph.Edges {
if e.Src == obj || e.Dst == obj {
return false
}
}
for _, ch := range obj.ChildrenArray {
// 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
}
}
@ -35,8 +38,7 @@ func (obj *Object) IsSequenceDiagramGroup(edges []*Edge) bool {
// notes are descendant of actors with no edges and no children
func (obj *Object) IsSequenceDiagramNote() bool {
sd := obj.outerSequenceDiagram()
if sd == nil {
if obj.outerSequenceDiagram() == nil {
return false
}
return !obj.hasEdgeRef() && !obj.ContainsAnyEdge(obj.Graph.Edges) && len(obj.ChildrenArray) == 0

View file

@ -65,7 +65,7 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se
var groups []*d2graph.Object
for _, obj := range objects {
if obj.IsSequenceDiagramGroup(messages) {
if obj.IsSequenceDiagramGroup() {
queue := []*d2graph.Object{obj}
// Groups may have more nested groups
for len(queue) > 0 {
@ -175,7 +175,6 @@ func (sd *sequenceDiagram) layout() error {
func (sd *sequenceDiagram) placeGroups() {
for _, group := range sd.groups {
group.ZIndex = GROUP_Z_INDEX
// group.Attributes.Style.Opacity = &d2graph.Scalar{Value: "0.5"}
sd.placeGroup(group)
}
}

View file

@ -14,6 +14,7 @@ type Neutral struct {
N3 string `json:"n3"`
N4 string `json:"n4"`
N5 string `json:"n5"`
N6 string `json:"n6"`
N7 string `json:"n7"`
}
@ -44,6 +45,7 @@ var CoolNeutral = Neutral{
N3: "#9499AB",
N4: "#CFD2DD",
N5: "#F0F3F9",
N6: "#EEF1F8",
N7: "#FFFFFF",
}
@ -53,5 +55,6 @@ var WarmNeutral = Neutral{
N3: "#787777",
N4: "#CCCACA",
N5: "#DFDCDC",
N6: "#ECEBEB",
N7: "#FFFFFF",
}

View file

@ -246,7 +246,7 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"fill": "#FFFFFF",
"stroke": "#0D32B2",
"shadow": 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

View file

@ -246,7 +246,7 @@
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#EDF0FD",
"fill": "#FFFFFF",
"stroke": "#0D32B2",
"shadow": 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