File tree 5 files changed +428
-0
lines changed
5 files changed +428
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import GridDimensions from '@site/static/d2/grid-dimensions.d2';
7
7
import GridFill from '@site/static /d2/grid-fill.d2';
8
8
import GridNestedGrid from '@site/static /d2/grid-nested-grid.d2';
9
9
import Table from '@site/static /d2/table.d2';
10
+ import GridUnaligned from '@site/static /d2/grid-unaligned.d2';
11
+ import GridAligned from '@site/static /d2/grid-aligned.d2';
10
12
11
13
# Grid Diagrams
12
14
@@ -168,6 +170,27 @@ soon.
168
170
169
171
<div className =" embedSVG " dangerouslySetInnerHTML ={{__html: require('@site /static /img /generated /grid-nested-grid.svg2')}} ></div >
170
172
173
+ ## Aligning with invisible elements
174
+
175
+ A common technique to align grid elements to your liking is to pad the grid with invisible
176
+ elements.
177
+
178
+ Consider the following diagram.
179
+
180
+ <CodeBlock className =" language-d2 " >
181
+ {GridUnaligned}
182
+ </CodeBlock >
183
+
184
+ <div className =" embedSVG " dangerouslySetInnerHTML ={{__html: require('@site /static /img /generated /grid-unaligned.svg2')}} ></div >
185
+
186
+ It'd be nicer if it were centered. This can be achieved by adding 2 invisible elements.
187
+
188
+ <CodeBlock className =" language-d2 " >
189
+ {GridAligned}
190
+ </CodeBlock >
191
+
192
+ <div className =" embedSVG " dangerouslySetInnerHTML ={{__html: require('@site /static /img /generated /grid-aligned.svg2')}} ></div >
193
+
171
194
## Source code
172
195
173
196
This is the script for the image at the top of this page.
Original file line number Diff line number Diff line change
1
+ classes : {
2
+ invisible : {
3
+ style .opacity : 0
4
+ label : a
5
+ }
6
+ }
7
+
8
+ grid-columns : 1
9
+ us-east-1 : {
10
+ grid-rows : 1
11
+ a
12
+ b
13
+ c
14
+ d
15
+ e
16
+ }
17
+
18
+ us-west-1 : {
19
+ grid-rows : 1
20
+ pad1 .class : invisible
21
+ pad2 .class : invisible
22
+ a
23
+ # Move the label so it doesn't go through the connection
24
+ label .near : bottom-center
25
+ }
26
+
27
+ us-east-1 .c -> us-west-1 .a
Original file line number Diff line number Diff line change
1
+ grid-columns : 1
2
+ us-east-1 : {
3
+ grid-rows : 1
4
+ a
5
+ b
6
+ c
7
+ d
8
+ e
9
+ }
10
+
11
+ us-west-1 : {
12
+ grid-rows : 1
13
+ a
14
+ }
15
+
16
+ us-east-1 .c -> us-west-1 .a
You can’t perform that action at this time.
0 commit comments