Skip to content

Commit

Permalink
Docs(web-react): Add more info about GridItem attributes #DS-1032
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelklibani committed Dec 16, 2024
1 parent 44eb2e1 commit b1e6a5e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/web-react/src/components/Grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ component itself using the [`cols` prop](#api) and might not need to set columns
listing with 3 columns is easier to set using `cols="3"` on the `Grid` component than setting
`columnStart` and `columnEnd` on each `GridItem`.

### Grid Placement Props: `columnStart`, `columnEnd`, `rowStart`, `rowEnd`

These props control the placement of grid items within a CSS Grid layout by specifying where the item starts and ends in rows and columns:

- `columnStart`: Specifies the vertical grid line where the item begins.
- `columnEnd`: Specifies the vertical grid line where the item ends. The item spans up to, but does not include, this grid line. For example, if columnEnd is "3", the item ends at the line before the third column.
- `rowStart`: Specifies the horizontal grid line where the item begins.
- `rowEnd`: Specifies the horizontal grid line where the item ends. The item spans up to, but does not include, this grid line. For example, if rowEnd is "4", the item ends at the line before the fourth row.

#### Grid Placement Example

```jsx
<GridItem
columnStart={2}
columnEnd={5} // or columnEnd="span 3"
rowStart={1}
rowEnd={3} // or rowEnd="span 2"
>
</GridItem>
```

<img src="https://raw.githubusercontent.com/lmc-eu/spirit-design-system/refs/heads/main/packages/web-react/src/components/Grid/static/GridExample.svg" alt="Grid example" width="400" />

_The image is taken from the [CSS Grid Layout Guide][css-tricks-grid]._

These props align with their respective CSS Grid properties, providing precise control over grid item placement. Learn more in the [MDN CSS Grid][grid-mdn] documentation.

Basic example usage:

```jsx
Expand Down Expand Up @@ -179,8 +207,10 @@ If you need more control over the styling of a component, you can use [style pro
and [escape hatches][readme-escape-hatches].

[alignment-dictionary]: https://github.com/lmc-eu/spirit-design-system/blob/main/docs/DICTIONARIES.md#alignment
[grid]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web/src/scss/components/Grid/README.md
[css-tricks-grid]: https://css-tricks.com/snippets/css/complete-guide-grid/
[digitalocean-span]: https://www.digitalocean.com/community/tutorials/css-css-grid-layout-span-keyword
[grid]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web/src/scss/components/Grid/README.md
[grid-mdn]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout
[readme-additional-attributes]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#additional-attributes
[readme-escape-hatches]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#escape-hatches
[readme-style-props]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-react/README.md#style-props
34 changes: 34 additions & 0 deletions packages/web-react/src/components/Grid/static/GridExample.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b1e6a5e

Please sign in to comment.