You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: website/docs/layouts/flex/partials/code/how-to-use.md
+24-24
Original file line number
Diff line number
Diff line change
@@ -58,13 +58,13 @@ To specify which HTML tag to use to render the flex container and/or item(s), us
58
58
59
59
!!! Insight
60
60
61
-
While by default the component renders a `<div>`, we invite consumers to consider which semantic HTML tag is the correct one for the context in which the text is used to meet WCAG Success Criterion [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html) as the visual experience should match what is presented to the user with assistive technology.
61
+
While, by default, the component renders a `<div>`, we invite consumers to consider which semantic HTML tag is the correct one for the context in which the text is used to meet WCAG Success Criterion [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html) as the visual experience should match what is presented to the user with assistive technology.
62
62
63
63
!!!
64
64
65
65
### Direction
66
66
67
-
To specify which in which [direction](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) the flex items are laid out, use the `@direction` argument:
67
+
To specify in which [direction](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) the flex items are laid out, use the `@direction` argument:
68
68
69
69
```handlebars{data-execute=false}
70
70
<Hds::Layout::Flex @direction="column" as |LF|>
@@ -88,7 +88,7 @@ To specify how the flex items are spaced and aligned, use the `@justify` and `al
88
88
89
89
These arguments correspond to the [`justify-content`](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) and [`align-items`](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) flexbox properties in CSS.
90
90
91
-
_Note: we don't expose all the possible values for `justify-content`/`align-items`, only to the most commonly used ones. Refer to the [Component API](#component-api) section for details on which values are accepted._
91
+
_Note: we don't expose all the possible values for `justify-content`/`align-items`, only the most commonly used ones. Refer to the [Component API](#component-api) section for details on which values are accepted._
92
92
93
93
📚 Refer to the ["Recipes"](#flexbox-layout-recipes) and [Patterns](#common-layout-patterns) sections below for practical examples of how the Flexbox `justify-content`/`align-items` properties can be used to implement specific layouts.
94
94
@@ -122,7 +122,7 @@ To differentiate the vertical and horizontal spacing between items when they wra
with a vertical gap of 16px and an horizontal one of 48px
125
+
with a vertical gap of 16px and a horizontal one of 48px
126
126
}}
127
127
</Hds::Layout::Flex>
128
128
```
@@ -159,7 +159,7 @@ If you absolutely have to use non-standard spacing value(s) for the flex `gap`,
159
159
160
160
In this case we're overwriting only the "column" gap value via the custom CSS class.
161
161
162
-
If the flex items are wrapping on multiple lines, you have to overwrite both the "row" and "column" gap values:
162
+
If the flex items are wrapping to multiple lines, you have to overwrite both the "row" and "column" gap values:
163
163
164
164
```handlebars{data-execute=false}
165
165
<Hds::Layout::Flex
@@ -197,19 +197,19 @@ To control the relative sizing of the flex items, use the `@basis`, `@grow`, and
197
197
</Hds::Layout::Flex>
198
198
```
199
199
200
-
How these three properties impact on the (relative) size of a flex item is not trivial, we suggest to look at the introduction to flexbox guide linked at the top of this page.
200
+
How these three properties impact the (relative) size of a flex item is not trivial, we suggest consulting the MDN flexbox guide linked at the top of this page.
201
201
202
202
📚 Refer to the ["Recipes"](#flexbox-layout-recipes) and [Patterns](#common-layout-patterns) sections below for practical examples of how the Flexbox `flex-basis`/`flex-grow`/`flex-shrink` properties can be used to implement specific layouts.
203
203
204
204
---
205
205
206
206
## Flexbox layout "recipes"
207
207
208
-
Below some examples of common generic layouts that can be achieved using CSS `flexbox`, and therefore the `Layout::Flex` component.
208
+
Below are some examples of common generic layouts that can be achieved using CSS `flexbox`, and therefore the `Layout::Flex` component.
209
209
210
210
### Alignment
211
211
212
-
Using `flexbox`/`Layout::Flex` is one of the simplest way to control the alignment of lists of items.
212
+
Using `flexbox`/`Layout::Flex` is one of the simplest ways to control the alignment of lists of items.
213
213
214
214
#### Evenly spaced items
215
215
@@ -244,7 +244,7 @@ In this case:
244
244
245
245
- by applying a `margin-left: auto` to the last flex item, the flexbox layout engine pushes it completely to the right (because implicitly it has `margin-right: 0`)
246
246
247
-
The same technique can also be applied when there are multiple elements that need to be aligned on the right:
247
+
The same technique can also be applied when there are multiple elements that need to be aligned to the right:
@@ -257,11 +257,11 @@ The same technique can also be applied when there are multiple elements that nee
257
257
258
258
In this case:
259
259
260
-
- the `margin-left: auto` is applied only to the first item that is flushed to the right; all the other items are automatically pushed to the right by the first flushed item
260
+
- the `margin-left: auto` is applied only to the first item that is flushed to the right; all the other items are automatically pushed to the right by the first flushed right item
261
261
262
262
#### Vertical centering
263
263
264
-
For a long time, this has been one classic problem in CSS: how to vertically center two or more items? The more reliable solution is to use flexbox's alignment:
264
+
A classic CSS problem: how to vertically center two or more items? A reliable solution is to use flexbox alignment:
265
265
266
266
```handlebars
267
267
<Hds::Layout::Flex @align="center" @gap="8">
@@ -273,11 +273,11 @@ For a long time, this has been one classic problem in CSS: how to vertically cen
273
273
274
274
In this case:
275
275
276
-
- the `@align="center"` applied to the flex container forces the flex items to vertically align their centers along what is called the "cross axis"
276
+
- the `@align="center"` applied to the flex container forces the flex items to vertically align their centers along the "cross axis"
277
277
278
278
#### Both horizontal and vertical centering
279
279
280
-
This has also been another classic CSS problem: how to center _both_ horizontally and vertically some content, inside a larger container? Again, the solution relies in using flexbox's alignment:
280
+
Another classic CSS problem: how to center content _both_ horizontally and vertically inside a larger container? Again, the solution is to use flexbox alignment:
@@ -287,7 +287,7 @@ This has also been another classic CSS problem: how to center _both_ horizontall
287
287
288
288
In this case:
289
289
290
-
- the `@justify="center"` and `@align="stretch"` applied to the flex container force the flex item to be centered both horizontally and vertically (_note: we have applied an outline and a fixed height to the flex container to demonstrate the behavior_)
290
+
- the `@justify="center"` and `@align="stretch"`arguments applied to the flex container force the flex item to be centered both horizontally and vertically (_note: we have applied an outline and a fixed height to the flex container to demonstrate the behavior_)
291
291
292
292
### Sizing
293
293
@@ -321,7 +321,7 @@ If we want an item to to grow and occupy the available space, we have to use its
321
321
322
322
In this case:
323
323
324
-
- we have applied `@grow=\{{true}}` to the wrapping `Flex::Item`, forcing it to use all the available extra space inside the flexbox container
324
+
- we have applied `@grow=\{{true}}` to the wrapping `Flex::Item`, forcing it to use all the available space inside the flexbox container
325
325
326
326
#### Prevent collapsing of content
327
327
@@ -388,7 +388,7 @@ An alternative solution is to wrap the element that shouldn't stretch with a fle
388
388
389
389
### Wrapping
390
390
391
-
One of the useful functionalities of the flexbox layout model is that it allows the items to wrap along multiple rows when there is not enough space in the container to fit them all in a single line:
391
+
One useful function of the flexbox layout model is that it allows items to wrap along multiple rows when there is not enough space in the container to fit them all in a single line:
@@ -424,31 +424,31 @@ It's possible to nest flexbox containers to achieve more complex layouts:
424
424
In this case:
425
425
426
426
- the outer container is a column-based flexbox layout, with three child items
427
-
- the second item is a row-based flexbox layout, used to create two side-byside content blocks; of these two the first has a fixed width, while the second fills the remaining area thanks to the `@grow=\{{true}}` attribute
427
+
- the second item is a row-based flexbox layout, used to create two side-by-side content blocks; of these two the first has a fixed width, while the second fills the remaining area thanks to the `@grow=\{{true}}` attribute
428
428
429
429
!!! Insight
430
430
431
-
Depending on the complexity of the design you need to implement, you may want to consider using a CSS `grid` layout, instead of a `flex` layout.
431
+
Depending on the complexity and type of design you need to implement, you may want to consider using a CSS `grid` layout, instead of a `flex` layout.
432
432
433
433
!!!
434
434
435
435
---
436
436
437
437
## Common layout patterns
438
438
439
-
Below some more realistic examples of common layouts that can be achieved using the `Layout::Flex` component, in composition with other HDS components.
439
+
Below are some more realistic examples of common layouts that can be achieved using the `Layout::Flex` component, in composition with other HDS components.
440
440
441
441
!!! Warning
442
442
443
443
**Important**
444
444
445
-
The examples below are meant to show how one _could_ use the `Layout::Flex` component to implement certain common/standard UI patterns. They're **not** meant to be taken literally as they are and be used in production code. Also, some of these patterns are already implemented directly in HDS components that are ready to use.
445
+
The examples below are meant to show how one _could_ use the `Layout::Flex` component to implement certain common/standard UI patterns. They're **not** meant to be taken literally as they are and be used in production code. Also, some of these patterns may already implemented directly in HDS components that are ready to use.
446
446
447
447
!!!
448
448
449
449
### Media + Text/Content
450
450
451
-
This is a classic layout, where a "media" element (it could be an image, an icon, an avatar, etc) is laid out next to a block of text (but could be more complex content). The two elements are visually centered along their horizontal axis.
451
+
This is a classic layout, where a "media" element (it could be an image, an icon, an avatar, etc) is laid out next to a block of text (but could be more complex content). The two elements are either visually centered along their horizontal axis, or aligned to their top.
452
452
453
453
454
454
```handlebars
@@ -502,7 +502,7 @@ Using the automatic layout offered by flexbox, it's extremely easy to create a g
502
502
503
503
!!! Warning
504
504
505
-
A responsive implementation of this UI pattern is a bit more complex, and requires to use`min-max/max-width` values for the cards, and allow wrapping of the flex item elements. It may also require changing direction of the flex container at a certain breakpoint.
505
+
A responsive implementation of this UI pattern is a bit more complex and requires usage of`min-max/max-width` values for the cards and allowing wrapping of the flex item elements. It may also require changing the direction of the flex container at a certain breakpoint.
506
506
507
507
!!!
508
508
@@ -541,7 +541,7 @@ as |LF|>
541
541
542
542
### Right aligned actions
543
543
544
-
Using the `margin-left: auto` trick described above, one can achieve the following layout, where one of the flex items is flushed on the right:
544
+
Using the `margin-left: auto` trick described above, one can achieve the following layout, where one of the flex items is flushed to the right:
0 commit comments