@@ -79,6 +79,46 @@ func applyTheme(shape *d2target.Shape, obj *d2graph.Object, theme *d2themes.Them
79
79
if theme .SpecialRules .Mono {
80
80
shape .FontFamily = "mono"
81
81
}
82
+ if theme .SpecialRules .C4 && len (obj .ChildrenArray ) > 0 {
83
+ if obj .Style .Fill == nil {
84
+ shape .Fill = "transparent"
85
+ }
86
+ if obj .Style .Stroke == nil {
87
+ shape .Stroke = color .AA2
88
+ }
89
+ if obj .Style .StrokeDash == nil {
90
+ shape .StrokeDash = 5
91
+ }
92
+ if obj .Style .FontColor == nil {
93
+ shape .Color = color .N1
94
+ }
95
+ }
96
+ }
97
+ if theme .SpecialRules .C4 && obj .Level () == 1 && len (obj .ChildrenArray ) == 0 &&
98
+ obj .Shape .Value != d2target .ShapePerson && obj .Shape .Value != d2target .ShapeC4Person {
99
+ if obj .Style .Fill == nil {
100
+ shape .Fill = color .B6
101
+ }
102
+ if obj .Style .Stroke == nil {
103
+ shape .Stroke = color .B5
104
+ }
105
+ }
106
+ if theme .SpecialRules .C4 && (obj .Shape .Value == d2target .ShapePerson || obj .Shape .Value == d2target .ShapeC4Person ) {
107
+ if obj .Style .Fill == nil {
108
+ shape .Fill = color .B2
109
+ }
110
+ if obj .Style .Stroke == nil {
111
+ shape .Stroke = color .B1
112
+ }
113
+ }
114
+ if theme .SpecialRules .C4 && obj .Level () > 1 && len (obj .ChildrenArray ) == 0 &&
115
+ obj .Shape .Value != d2target .ShapePerson && obj .Shape .Value != d2target .ShapeC4Person {
116
+ if obj .Style .Fill == nil {
117
+ shape .Fill = color .B4
118
+ }
119
+ if obj .Style .Stroke == nil {
120
+ shape .Stroke = color .B3
121
+ }
82
122
}
83
123
}
84
124
@@ -165,6 +205,15 @@ func toShape(obj *d2graph.Object, g *d2graph.Graph) d2target.Shape {
165
205
applyStyles (shape , obj )
166
206
applyTheme (shape , obj , g .Theme )
167
207
shape .Color = text .GetColor (shape .Italic )
208
+ if g .Theme .SpecialRules .C4 {
209
+ if obj .Style .FontColor == nil {
210
+ if len (obj .ChildrenArray ) > 0 {
211
+ shape .Color = color .N1
212
+ } else {
213
+ shape .Color = color .N7
214
+ }
215
+ }
216
+ }
168
217
applyStyles (shape , obj )
169
218
170
219
switch strings .ToLower (obj .Shape .Value ) {
@@ -393,5 +442,17 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
393
442
connection .Src = edge .Src .AbsID ()
394
443
connection .Dst = edge .Dst .AbsID ()
395
444
445
+ if theme != nil && theme .SpecialRules .C4 {
446
+ if edge .Style .StrokeDash == nil {
447
+ connection .StrokeDash = 5
448
+ }
449
+ if edge .Style .Stroke == nil {
450
+ connection .Stroke = color .AA4
451
+ }
452
+ if edge .Style .FontColor == nil {
453
+ connection .Color = color .N2
454
+ }
455
+ }
456
+
396
457
return * connection
397
458
}
0 commit comments