Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout::Grid - documentation (HDS-4650) #2772

Open
wants to merge 16 commits into
base: hds-4532-grid-component
Choose a base branch
from

Conversation

KristinLBradley
Copy link
Contributor

@KristinLBradley KristinLBradley commented Mar 15, 2025

📌 Summary

If merged, this PR adds web documentation for the Grid component.

👉 Preview: https://hds-website-git-hds-4650-grid-documentation-hashicorp.vercel.app/layouts/grid

Component implementation PR: #2756

🔗 External links


👀 Component checklist

  • Percy was checked for any visual regression
  • [ ] A changelog entry was added via Changesets if needed (see templates here)

💬 Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Mar 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Mar 18, 2025 10:54pm
hds-website ✅ Ready (Inspect) Visit Preview Mar 18, 2025 10:54pm

Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KristinLBradley left a few minor comments, nothing major that I can see

@KristinLBradley KristinLBradley force-pushed the hds-4532-grid-component branch from 0586955 to 7f5c4b8 Compare March 18, 2025 16:15
@KristinLBradley KristinLBradley force-pushed the hds-4650-grid-documentation branch from 5d40954 to ac7b7d7 Compare March 18, 2025 16:16
</Hds::Layout::Grid>
```

### colspan & rowspan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] Adding some of the basic examples from the showcase for colspan and rowspan could help show how these arguments work in a simpler manner than the one example provided right now. The min-height example seems like a more nuanced use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to make this section too long and to me these features seemed fairly straight forward to understand so I though one example could be sufficient. I could be wrong though. @didoo what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @KristinLBradley here, I think a single example with both rowspan/colspan is clear. What I maybe would do it to justify why there are three columns in the grid when in reality visually only two are needed
screenshot_4810


**Important**

The examples below are meant to show how one _could_ use the `Layout::Grid` 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Are there HDS components that implement the two patterns shown in the docs? If so, we should link to those components in the sections below where applicable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just sort of disclaimer language that I followed from what @didoo had also included in the Flex component docs. I'll update it to say some of the patterns "may" already be implemented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only pattern that is similar is the RadioCard group, but it's implemented using flex, not grid.

KristinLBradley and others added 2 commits March 18, 2025 15:36
Co-authored-by: Dylan Hyun <dylan.hyun@hashicorp.com>
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did another pass an left a few comments/suggestions

// COMPONENTS > GRID

#show-content-layouts-grid {
.doc-grid-outline-children > * {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment below about the possibility of removing this outlining

Comment on lines +19 to +22
<Doc::Placeholder @height="40px" @text="Item 1" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 2" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 3" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 4" @background="#e4e4e4" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] Since we are already declaring the background color inline in the snippet, what about using different colors to differentiate the items (with the benefit of making outlining them not necessary anymore? you may want to leave the outline only on the grid container, in case)

Suggested change
<Doc::Placeholder @height="40px" @text="Item 1" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 2" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 3" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 4" @background="#e4e4e4" />
<Doc::Placeholder @height="40px" @text="Item 1" @background="#e4c5f3" />
<Doc::Placeholder @height="40px" @text="Item 2" @background="#e5ffd2" />
<Doc::Placeholder @height="40px" @text="Item 3" @background="#d2f4ff" />
<Doc::Placeholder @height="40px" @text="Item 4" @background="#fff8d2" />

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for the other examples


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).

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.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Flex documentation I've added a note about not using the item unless necessary, see if you want to port it over here too.

</Hds::Layout::Grid>
```

!!! Info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see you've moved it here. Mmm, I think it's a bit lost here, no?


### Preventing content stretch

```handlebars
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[praise] Nice example! 🙌

(I copied it to Flex too 😀)

Comment on lines +1 to +3
## 4.19.0

TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this to the automation

Suggested change
## 4.19.0
TODO


Use the `@align` argument to align grid items to the "start", "end", "center" or "stretch" them within the grid parent.

Note: The `Grid` parent will need a height set for the affect to be visible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note: The `Grid` parent will need a height set for the affect to be visible.
Note: The `Grid` parent will need a height set for the effect to be visible.

<Doc::Placeholder @height="1.2em" @text="Item 1" @background="#e4e4e4" />
<Doc::Placeholder @height="1.2em" @text="Item 2" @background="#e4e4e4" />
<Doc::Placeholder @height="1.2em" @text="Item 3" @background="#e4e4e4" />
<Doc::Placeholder @height="1.2sem" @text="Item 4" @background="#e4e4e4" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Doc::Placeholder @height="1.2sem" @text="Item 4" @background="#e4e4e4" />
<Doc::Placeholder @height="1.2em" @text="Item 4" @background="#e4e4e4" />


Note: The following example makes use of nested `Grid` and [Flex](/layouts/flex) components to achieve its layout. This may be overkill in actual practice but demonstrates the possibilities for achieving layouts with just these layout components alone.

#### Basic 3 column layout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe?

Suggested change
#### Basic 3 column layout
#### Basic 3 columns layout

Comment on lines +328 to +332
<Hds::Layout::Grid @columnMinWidth="100%" @gap="16">
<div>
<Hds::Badge @text="In Preview" @type="outlined" @color="highlight" />
<Hds::Text::Display @tag="h2" @size="300" @weight="bold">Better together</Hds::Text::Display>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Hds::Layout::Grid @columnMinWidth="100%" @gap="16">
<div>
<Hds::Badge @text="In Preview" @type="outlined" @color="highlight" />
<Hds::Text::Display @tag="h2" @size="300" @weight="bold">Better together</Hds::Text::Display>
</div>
<Hds::Layout::Grid @columnMinWidth="100%" @gap="16" as |LG|>
<LG.Item>
<Hds::Badge @text="In Preview" @type="outlined" @color="highlight" />
</LG.Item>
<Hds::Text::Display @tag="h2" @size="300" @weight="bold">Better together</Hds::Text::Display>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants