Skip to content

Commit c903f68

Browse files
HDS-4650 Reduce size of simulated mobile layout, update docs on gap feature to match Flex docs
1 parent 0f1d026 commit c903f68

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

website/app/styles/pages/layouts/grid.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.doc-grid-mobile-view {
1414
position: relative;
15-
max-width: 320px;
15+
max-width: 280px;
1616
padding: 16px 16px 65px;
1717
background: var(--token-color-palette-neutral-100);
1818
border: 1px solid;

website/docs/layouts/grid/partials/code/how-to-use.md

+58-6
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,66 @@ To specify the HTML tag used to render the grid container and/or item(s), use th
3939

4040
### Gap
4141

42-
Specify either a single gap size or an array of 2 row and column gap size values to space apart items.
42+
To control the spacing between grid items, use the `@gap` argument:
4343

44-
```handlebars
44+
```handlebars{data-execute=false}
4545
<Hds::Layout::Grid @gap="16">
46-
<Doc::Placeholder @height="40px" @text="Item 1" @background="#e4e4e4" />
47-
<Doc::Placeholder @height="40px" @text="Item 2" @background="#e4e4e4" />
48-
<Doc::Placeholder @height="40px" @text="Item 3" @background="#e4e4e4" />
49-
<Doc::Placeholder @height="40px" @text="Item 4" @background="#e4e4e4" />
46+
{{! multiple grid items here, with a gap of 16px between them }}
47+
</Hds::Layout::Grid>
48+
```
49+
50+
To differentiate the vertical and horizontal spacing between items when they wrap on multiple rows, provide an array of two values to the `@gap` argument:
51+
52+
```handlebars{data-execute=false}
53+
<Hds::Layout::Grid @wrap={{true}} @gap={{array "16" "48"}}>
54+
{{!
55+
multiple grid items appearing on multiple rows
56+
with a vertical gap of 16px and an horizontal one of 48px
57+
}}
58+
</Hds::Layout::Grid>
59+
```
60+
61+
The first value in the array refers to the vertical gap between “rows” of items (`row-gap` in CSS), the second one to the horizontal spacing between “columns” of items (`column-gap` in CSS).
62+
63+
The `@gap` argument accepts only **pre-defined values**, it can’t be used to provide custom spacing values. Refer to the [Component API](#component-api) section for details on which values are accepted.
64+
65+
If you need to provide custom spacing values, see below how you can use a special escape hatch for this.
66+
67+
!!! Warning
68+
69+
**Important**
70+
71+
The **pre-defined value(s)** passed to the `@gap` argument **must be string(s)**, not numbers!
72+
73+
!!!
74+
75+
#### Non-standard gap values
76+
77+
If you absolutely have to use non-standard spacing value(s) for the grid `gap`, you can use the internal `--hds-layout-grid-row-gap` and `--hds-layout-grid-column-gap` CSS variables and pass custom values to them (e.g., via a local CSS variable or an inline style):
78+
79+
```handlebars{data-execute=false}
80+
<Hds::Layout::Grid class="doc-grid-demo-custom-grid-column-gap">
81+
{{!
82+
multiple grid items here, with a non-standard gap between them
83+
by assigning a custom value for `--hds-layout-grid-column-gap`
84+
declared in the `.doc-grid-demo-custom-grid-column-gap` local class
85+
}}
86+
</Hds::Layout::Grid>
87+
```
88+
89+
In this case we’re overwriting only the “column” gap value via the custom CSS class.
90+
91+
If the grid items are wrapping on multiple lines, you have to overwrite both the “row” and “column” gap values:
92+
93+
```handlebars{data-execute=false}
94+
<Hds::Layout::Grid
95+
{{style --hds-layout-grid-row-gap="10px" --hds-layout-grid-column-gap="0.625rem"}}
96+
@wrap={{true}}
97+
>
98+
{{!
99+
multiple grid items appearing on multiple rows
100+
with a vertical gap of 10px and an horizontal one of 0.625rem
101+
}}
50102
</Hds::Layout::Grid>
51103
```
52104

0 commit comments

Comments
 (0)