diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index f04d26a57..d4f26c187 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -118,7 +118,8 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err if obj.Attributes.Icon != nil { iconSize := d2target.GetIconSize(obj.Box, string(label.InsideTopLeft)) - maxContainerLabelHeight = go2.Max(maxContainerLabelHeight, iconSize+label.PADDING) + // Since dagre container labels are pushed up, we don't want a child container to collide + maxContainerLabelHeight = go2.Max(maxContainerLabelHeight, (iconSize+label.PADDING*2)*3) } } diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index d42f82d24..bd69f539e 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -209,7 +209,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err } if obj.Attributes.Icon != nil { iconSize := d2target.GetIconSize(obj.Box, string(label.InsideTopLeft)) - paddingTop = go2.Max(paddingTop, iconSize+label.PADDING) + paddingTop = go2.Max(paddingTop, iconSize+label.PADDING*2) } n.LayoutOptions.Padding = fmt.Sprintf("[top=%d,left=50,bottom=50,right=50]", paddingTop, diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index cf1b25ea6..1c82b78d8 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -900,22 +900,25 @@ a -> b { name: "icon-containers", script: `vpc: VPC 1 10.1.0.0./16 { - icon: https://icons.terrastruct.com/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-VPC.svg + icon: https://icons.terrastruct.com/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg style: { stroke: green font-color: green + fill: white } az: Availability Zone A { style: { stroke: blue font-color: blue stroke-dash: 3 + fill: white } firewall: Firewall Subnet A { icon: https://icons.terrastruct.com/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg style: { stroke: purple font-color: purple + fill: "#e1d5e7" } } } diff --git a/e2etests/testdata/stable/icon-containers/dagre/board.exp.json b/e2etests/testdata/stable/icon-containers/dagre/board.exp.json index 0753c695c..cc45a1022 100644 --- a/e2etests/testdata/stable/icon-containers/dagre/board.exp.json +++ b/e2etests/testdata/stable/icon-containers/dagre/board.exp.json @@ -10,12 +10,12 @@ "y": 41 }, "width": 315, - "height": 277, + "height": 503, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#E3E9FD", + "fill": "white", "stroke": "green", "shadow": false, "3d": false, @@ -28,8 +28,8 @@ "Opaque": "", "User": null, "Host": "icons.terrastruct.com", - "Path": "/aws/Networking & Content Delivery/Amazon-VPC.svg", - "RawPath": "/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-VPC.svg", + "Path": "/aws/_Group Icons/Virtual-private-cloud-VPC_light-bg.svg", + "RawPath": "/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg", "ForceQuery": false, "RawQuery": "", "Fragment": "", @@ -59,15 +59,15 @@ "type": "rectangle", "pos": { "x": 20, - "y": 106 + "y": 163 }, "width": 275, - "height": 182, + "height": 295, "opacity": 1, "strokeDash": 3, "strokeWidth": 2, "borderRadius": 0, - "fill": "#EDF0FD", + "fill": "white", "stroke": "blue", "shadow": false, "3d": false, @@ -100,7 +100,7 @@ "type": "rectangle", "pos": { "x": 60, - "y": 138 + "y": 251 }, "width": 195, "height": 118, @@ -108,7 +108,7 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#F7F8FE", + "fill": "#e1d5e7", "stroke": "purple", "shadow": false, "3d": false, diff --git a/e2etests/testdata/stable/icon-containers/dagre/sketch.exp.svg b/e2etests/testdata/stable/icon-containers/dagre/sketch.exp.svg index 1c4f860b3..0316a8e98 100644 --- a/e2etests/testdata/stable/icon-containers/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/icon-containers/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="519" height="520" viewBox="-102 -100 519 520">