This commit is contained in:
Alexander Wang 2023-02-13 10:48:55 -08:00
parent e37fc89bb1
commit f14326c334
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
7 changed files with 30 additions and 26 deletions

View file

@ -118,7 +118,8 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
if obj.Attributes.Icon != nil { if obj.Attributes.Icon != nil {
iconSize := d2target.GetIconSize(obj.Box, string(label.InsideTopLeft)) 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)
} }
} }

View file

@ -209,7 +209,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
} }
if obj.Attributes.Icon != nil { if obj.Attributes.Icon != nil {
iconSize := d2target.GetIconSize(obj.Box, string(label.InsideTopLeft)) 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]", n.LayoutOptions.Padding = fmt.Sprintf("[top=%d,left=50,bottom=50,right=50]",
paddingTop, paddingTop,

View file

@ -900,22 +900,25 @@ a -> b
{ {
name: "icon-containers", name: "icon-containers",
script: `vpc: VPC 1 10.1.0.0./16 { 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: { style: {
stroke: green stroke: green
font-color: green font-color: green
fill: white
} }
az: Availability Zone A { az: Availability Zone A {
style: { style: {
stroke: blue stroke: blue
font-color: blue font-color: blue
stroke-dash: 3 stroke-dash: 3
fill: white
} }
firewall: Firewall Subnet A { firewall: Firewall Subnet A {
icon: https://icons.terrastruct.com/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg icon: https://icons.terrastruct.com/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg
style: { style: {
stroke: purple stroke: purple
font-color: purple font-color: purple
fill: "#e1d5e7"
} }
} }
} }

View file

@ -10,12 +10,12 @@
"y": 41 "y": 41
}, },
"width": 315, "width": 315,
"height": 277, "height": 503,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#E3E9FD", "fill": "white",
"stroke": "green", "stroke": "green",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
@ -28,8 +28,8 @@
"Opaque": "", "Opaque": "",
"User": null, "User": null,
"Host": "icons.terrastruct.com", "Host": "icons.terrastruct.com",
"Path": "/aws/Networking & Content Delivery/Amazon-VPC.svg", "Path": "/aws/_Group Icons/Virtual-private-cloud-VPC_light-bg.svg",
"RawPath": "/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-VPC.svg", "RawPath": "/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg",
"ForceQuery": false, "ForceQuery": false,
"RawQuery": "", "RawQuery": "",
"Fragment": "", "Fragment": "",
@ -59,15 +59,15 @@
"type": "rectangle", "type": "rectangle",
"pos": { "pos": {
"x": 20, "x": 20,
"y": 106 "y": 163
}, },
"width": 275, "width": 275,
"height": 182, "height": 295,
"opacity": 1, "opacity": 1,
"strokeDash": 3, "strokeDash": 3,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#EDF0FD", "fill": "white",
"stroke": "blue", "stroke": "blue",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
@ -100,7 +100,7 @@
"type": "rectangle", "type": "rectangle",
"pos": { "pos": {
"x": 60, "x": 60,
"y": 138 "y": 251
}, },
"width": 195, "width": 195,
"height": 118, "height": 118,
@ -108,7 +108,7 @@
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#F7F8FE", "fill": "#e1d5e7",
"stroke": "purple", "stroke": "purple",
"shadow": false, "shadow": false,
"3d": false, "3d": false,

View file

@ -3,7 +3,7 @@
id="d2-svg" id="d2-svg"
style="background: white;" style="background: white;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="519" height="520" viewBox="-102 -100 519 520"><style type="text/css"> width="519" height="746" viewBox="-102 -100 519 746"><style type="text/css">
<![CDATA[ <![CDATA[
.shape { .shape {
shape-rendering: geometricPrecision; shape-rendering: geometricPrecision;
@ -39,8 +39,8 @@ width="519" height="520" viewBox="-102 -100 519 520"><style type="text/css">
svgEl.setAttribute("height", height * ratio - 16); svgEl.setAttribute("height", height * ratio - 16);
} }
}); });
]]></script><g id="vpc"><g class="shape" ><rect x="0" y="41" width="315" height="277" style="fill:#E3E9FD;stroke:green;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-VPC.svg" x="5.000000" y="46.000000" width="64" height="64" /><text class="text" x="157.500000" y="28.000000" style="text-anchor:middle;font-size:28px;fill:green">VPC 1 10.1.0.0./16</text></g><g id="vpc.az"><g class="shape" ><rect x="20" y="106" width="275" height="182" style="fill:#EDF0FD;stroke:blue;stroke-width:2;stroke-dasharray:6.000000,5.919384;" /></g><text class="text" x="157.500000" y="94.000000" style="text-anchor:middle;font-size:24px;fill:blue">Availability Zone A</text></g><g id="vpc.az.firewall"><g class="shape" ><rect x="60" y="138" width="195" height="118" style="fill:#F7F8FE;stroke:purple;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg" x="128.000000" y="167.500000" width="59" height="59" /><text class="text-bold" x="157.500000" y="159.000000" style="text-anchor:middle;font-size:16px;fill:purple">Firewall Subnet A</text></g><mask id="4143810402" maskUnits="userSpaceOnUse" x="-100" y="-100" width="519" height="520"> ]]></script><g id="vpc"><g class="shape" ><rect x="0" y="41" width="315" height="503" style="fill:white;stroke:green;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg" x="5.000000" y="46.000000" width="64" height="64" /><text class="text" x="157.500000" y="28.000000" style="text-anchor:middle;font-size:28px;fill:green">VPC 1 10.1.0.0./16</text></g><g id="vpc.az"><g class="shape" ><rect x="20" y="163" width="275" height="295" style="fill:white;stroke:blue;stroke-width:2;stroke-dasharray:6.000000,5.919384;" /></g><text class="text" x="157.500000" y="151.000000" style="text-anchor:middle;font-size:24px;fill:blue">Availability Zone A</text></g><g id="vpc.az.firewall"><g class="shape" ><rect x="60" y="251" width="195" height="118" style="fill:#e1d5e7;stroke:purple;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg" x="128.000000" y="280.500000" width="59" height="59" /><text class="text-bold" x="157.500000" y="272.000000" style="text-anchor:middle;font-size:16px;fill:purple">Firewall Subnet A</text></g><mask id="2058375010" maskUnits="userSpaceOnUse" x="-100" y="-100" width="519" height="746">
<rect x="-100" y="-100" width="519" height="520" fill="white"></rect> <rect x="-100" y="-100" width="519" height="746" fill="white"></rect>
</mask><style type="text/css"><![CDATA[ </mask><style type="text/css"><![CDATA[
.text { .text {

Before

Width:  |  Height:  |  Size: 649 KiB

After

Width:  |  Height:  |  Size: 649 KiB

View file

@ -10,12 +10,12 @@
"y": 12 "y": 12
}, },
"width": 395, "width": 395,
"height": 334, "height": 339,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#E3E9FD", "fill": "white",
"stroke": "green", "stroke": "green",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
@ -28,8 +28,8 @@
"Opaque": "", "Opaque": "",
"User": null, "User": null,
"Host": "icons.terrastruct.com", "Host": "icons.terrastruct.com",
"Path": "/aws/Networking & Content Delivery/Amazon-VPC.svg", "Path": "/aws/_Group Icons/Virtual-private-cloud-VPC_light-bg.svg",
"RawPath": "/aws%2FNetworking%20&%20Content%20Delivery%2FAmazon-VPC.svg", "RawPath": "/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg",
"ForceQuery": false, "ForceQuery": false,
"RawQuery": "", "RawQuery": "",
"Fragment": "", "Fragment": "",
@ -59,7 +59,7 @@
"type": "rectangle", "type": "rectangle",
"pos": { "pos": {
"x": 62, "x": 62,
"y": 78 "y": 83
}, },
"width": 295, "width": 295,
"height": 218, "height": 218,
@ -67,7 +67,7 @@
"strokeDash": 3, "strokeDash": 3,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#EDF0FD", "fill": "white",
"stroke": "blue", "stroke": "blue",
"shadow": false, "shadow": false,
"3d": false, "3d": false,
@ -100,7 +100,7 @@
"type": "rectangle", "type": "rectangle",
"pos": { "pos": {
"x": 112, "x": 112,
"y": 128 "y": 133
}, },
"width": 195, "width": 195,
"height": 118, "height": 118,
@ -108,7 +108,7 @@
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 2,
"borderRadius": 0, "borderRadius": 0,
"fill": "#F7F8FE", "fill": "#e1d5e7",
"stroke": "purple", "stroke": "purple",
"shadow": false, "shadow": false,
"3d": false, "3d": false,

View file

@ -3,7 +3,7 @@
id="d2-svg" id="d2-svg"
style="background: white;" style="background: white;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="599" height="538" viewBox="-90 -90 599 538"><style type="text/css"> width="599" height="543" viewBox="-90 -90 599 543"><style type="text/css">
<![CDATA[ <![CDATA[
.shape { .shape {
shape-rendering: geometricPrecision; shape-rendering: geometricPrecision;
@ -39,8 +39,8 @@ width="599" height="538" viewBox="-90 -90 599 538"><style type="text/css">
svgEl.setAttribute("height", height * ratio - 16); svgEl.setAttribute("height", height * ratio - 16);
} }
}); });
]]></script><g id="vpc"><g class="shape" ><rect x="12" y="12" width="395" height="334" style="fill:#E3E9FD;stroke:green;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-VPC.svg" x="17.000000" y="17.000000" width="64" height="64" /><text class="text" x="209.500000" y="45.000000" style="text-anchor:middle;font-size:28px;fill:green">VPC 1 10.1.0.0./16</text></g><g id="vpc.az"><g class="shape" ><rect x="62" y="78" width="295" height="218" style="fill:#EDF0FD;stroke:blue;stroke-width:2;stroke-dasharray:6.000000,5.919384;" /></g><text class="text" x="209.500000" y="107.000000" style="text-anchor:middle;font-size:24px;fill:blue">Availability Zone A</text></g><g id="vpc.az.firewall"><g class="shape" ><rect x="112" y="128" width="195" height="118" style="fill:#F7F8FE;stroke:purple;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg" x="180.000000" y="157.500000" width="59" height="59" /><text class="text-bold" x="209.500000" y="149.000000" style="text-anchor:middle;font-size:16px;fill:purple">Firewall Subnet A</text></g><mask id="3701608006" maskUnits="userSpaceOnUse" x="-100" y="-100" width="599" height="538"> ]]></script><g id="vpc"><g class="shape" ><rect x="12" y="12" width="395" height="339" style="fill:white;stroke:green;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2F_Group%20Icons%2FVirtual-private-cloud-VPC_light-bg.svg" x="17.000000" y="17.000000" width="64" height="64" /><text class="text" x="209.500000" y="45.000000" style="text-anchor:middle;font-size:28px;fill:green">VPC 1 10.1.0.0./16</text></g><g id="vpc.az"><g class="shape" ><rect x="62" y="83" width="295" height="218" style="fill:white;stroke:blue;stroke-width:2;stroke-dasharray:6.000000,5.919384;" /></g><text class="text" x="209.500000" y="112.000000" style="text-anchor:middle;font-size:24px;fill:blue">Availability Zone A</text></g><g id="vpc.az.firewall"><g class="shape" ><rect x="112" y="133" width="195" height="118" style="fill:#e1d5e7;stroke:purple;stroke-width:2;" /></g><image href="https://icons.terrastruct.com/aws%2FNetworking%20&amp;%20Content%20Delivery%2FAmazon-Route-53_Hosted-Zone_light-bg.svg" x="180.000000" y="162.500000" width="59" height="59" /><text class="text-bold" x="209.500000" y="154.000000" style="text-anchor:middle;font-size:16px;fill:purple">Firewall Subnet A</text></g><mask id="3563657041" maskUnits="userSpaceOnUse" x="-100" y="-100" width="599" height="543">
<rect x="-100" y="-100" width="599" height="538" fill="white"></rect> <rect x="-100" y="-100" width="599" height="543" fill="white"></rect>
</mask><style type="text/css"><![CDATA[ </mask><style type="text/css"><![CDATA[
.text { .text {

Before

Width:  |  Height:  |  Size: 649 KiB

After

Width:  |  Height:  |  Size: 649 KiB