Skip to content

Commit 2535906

Browse files
HDS-4650 Refactor Grid::Item section of docs to follow Flex docs more closely and fix heading levels
1 parent c903f68 commit 2535906

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

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

+27-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `Layout::Grid` and optional `Layout::Grid::Item` components provide a way to
1212

1313
### Basic usage
1414

15-
The parent `Grid` component creates a layout of equal width “columns” by default. Other components and HTML elements can be passed in directly.
15+
The simplest way to implement a grid layout is by using the `Layout::Grid` component to wrap content directly. A grid layout of equal width “columns” is created by default.
1616

1717
```handlebars
1818
<Hds::Layout::Grid class="doc-grid-outline-children">
@@ -23,6 +23,28 @@ The parent `Grid` component creates a layout of equal width “columns” by def
2323
</Hds::Layout::Grid>
2424
```
2525

26+
Every child of the **grid container** will be stretched to fit evenly within the underlying grid column tracks behaving as a **grid item** (for details on what this means, refer to the guide linked at the top of the page).
27+
28+
In some cases, it may be necessary to wrap one or more content items within the optional `Layout::Grid::Item` component. i.e., to group content together within a column or row, prevent content from being stretched to fit the underlying grid column width, or to make use of `rowspan` and `colspan` options in order to create more complex layouts. (See below for more details and examples on these features.)
29+
30+
### Preventing content stretch
31+
32+
```handlebars
33+
<Hds::Layout::Grid @columnMinWidth="100%" @gap="16" as |LG|>
34+
<Hds::Badge @text="Stretched badge" @color="critical" />
35+
36+
<LG.Item>
37+
<Hds::Badge @text="Non-stretched badge" @color="success" />
38+
</LG.Item>
39+
</Hds::Layout::Grid>
40+
```
41+
42+
!!! Info
43+
44+
Note: there is no strict need to use the `Layout::Grid::Item` subcomponent as a direct child of `Layout::Grid`; use it only when necessary to tweak grid styles of individual child item such as via the `@colspan/@rowspan` arguments (to avoid rendering an extra Ember component).
45+
46+
!!!
47+
2648
### Tag
2749

2850
To specify the HTML tag used to render the grid container and/or item(s), use the `@tag` argument:
@@ -185,7 +207,7 @@ Text before the inline grid.
185207
Text after the inline grid.
186208
```
187209

188-
### Grid::Item
210+
<!-- ### Grid::Item
189211
190212
Use the `Grid::Item` to wrap content to prevent it from stretching or if more control is needed over the grid layout.
191213
@@ -199,11 +221,11 @@ Use the `Grid::Item` to wrap content to prevent it from stretching or if more co
199221
<Hds::Badge @text="Non-stretched badge" @color="success" />
200222
</LG.Item>
201223
</Hds::Layout::Grid>
202-
```
224+
``` -->
203225

204-
### colspan & rowspan
226+
### Colspan & rowspan
205227

206-
Use the `colspan` and `rowspan` options of `Grid::Item` components to set the number of columns or rows an item should occupy.
228+
Use the `colspan` and `rowspan` options of the `Grid::Item` component to set the number of columns or rows an item should occupy.
207229

208230
Note: By default, if a height is set on the `Grid` parent, grid row heights will stretch proportionally to fill the `Grid`. To instead make a row conform to the minimum height of its content, you can pass an inline style as shown in the example.
209231

0 commit comments

Comments
 (0)