Skip to content

Commit 6040949

Browse files
committed
chore!: refactor ModalLayout to Modal and use radix-ui primitives
1 parent ed221c0 commit 6040949

34 files changed

+905
-850
lines changed

.changeset/brown-lamps-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: refactor ModalLayout to Modal and use radix-ui primitives

.changeset/nine-years-shake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: refactor Grid to be composite component

.changeset/two-feet-promise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': patch
3+
---
4+
5+
fix(design-system): time-picker icon was too small

docs/components/ColorCards.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ const ColorCards = () => {
3434
return (
3535
<Box key={colorName} tag="section">
3636
<H2>{`${colorName} colors`}</H2>
37-
<Grid tag="ol" gap={6} gridCols={3}>
37+
<Grid.Root tag="ol" gap={6} gridCols={3}>
3838
{colorKeys
3939
.toSorted((a, b) => compare(a, b))
4040
.map((key) => (
4141
<li key={key}>
4242
<Card colorKey={key} colorName={colorName} colorShade={key.split(colorName.toLowerCase())[1]} />
4343
</li>
4444
))}
45-
</Grid>
45+
</Grid.Root>
4646
</Box>
4747
);
4848
})}
@@ -90,7 +90,7 @@ const Card = ({ colorKey, colorName, colorShade }: CardProps) => {
9090
<ContrastInfo backgroundColor={colorHex} isLighter />
9191
<ContrastInfo backgroundColor={colorHex} isLighter isSmall />
9292
</Flex>
93-
<Grid
93+
<Grid.Root
9494
tag="dl"
9595
aria-label={`Table properties for ${colorName} ${colorShade}`}
9696
gap={2}
@@ -125,7 +125,7 @@ const Card = ({ colorKey, colorName, colorShade }: CardProps) => {
125125
</Typography>
126126
</Box>
127127
))}
128-
</Grid>
128+
</Grid.Root>
129129
</Box>
130130
);
131131
};

docs/stories/00-getting started/migration guides/migration-v1-v2.mdx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { Meta } from '@storybook/blocks';
1616
- [Upgraded styled-components to V6](#upgraded-styled-components-to-v6)
1717
- [Removed CMS specific components](#removed-cms-specific-components)
1818
- [Radix-UI](#radix-ui)
19+
- [Removed ThemeProvider](#removed-themeprovider)
20+
- [IconButton API changes](#iconbutton-api-changes)
21+
- [Grid is now a composite component](#grid-is-now-a-composite-component)
1922
- [Icons](#icons)
2023

2124
## Design System
@@ -202,13 +205,14 @@ made the decision to migrate to Radix-UI primitives for many of our components,
202205
of our APIs will change, but functionality should still remain the same. We recommend you check out the documentation
203206
for any of these components to understand better how to migrate your code.
204207

205-
- `Accordion`
206-
- `Avatar`
207-
- `Checkbox`
208-
- `Popover`
209-
- `Radio`
210-
- `Tabs`
211-
- `Tooltip`
208+
- [`Accordion`](../?path=/docs/components-accordion--base)
209+
- [`Avatar`](../?path=/docs/components-avatar--base)
210+
- [`Checkbox`](../?path=/docs/components-checkbox--base)
211+
- [`Modal`](../?path=/docs/components-modal--base)
212+
- [`Popover`](../?path=/docs/components-popover--base)
213+
- [`Radio`](../?path=/docs/components-radio--base)
214+
- [`Tabs`](../?path=/docs/components-tabs--base)
215+
- [`Tooltip`](../?path=/docs/components-tooltip--base)
212216

213217
### Removed `ThemeProvider`
214218

@@ -230,6 +234,24 @@ future release. If you don't want a tooltip you should set `withTooltip` to `fal
230234
+ <IconButton withTooltip={false} label="Add"><Plus /></IconButton>
231235
```
232236

237+
### Grid is now a composite component
238+
239+
`Grid` is now a composite Component. Therefore, `GridItem` has also been removed. To upgrade:
240+
241+
```diff
242+
- import { Grid, GridItem } from '@strapi/design-system';
243+
+ import { Grid } from '@strapi/design-system';
244+
245+
- <Grid gridCols={4}>
246+
- <GridItem col={2}>1</GridItem>
247+
- <GridItem col={2}>2</GridItem>
248+
- </Grid>
249+
+ <Grid.Root gridCols={4}>
250+
+ <Grid.Item>1</Grid.Item>
251+
+ <Grid.Item>2</Grid.Item>
252+
+ </Grid.Root>
253+
```
254+
233255
---
234256

235257
## Icons

docs/stories/04-components/Modal.mdx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { Meta, Canvas } from '@storybook/blocks';
2+
import { Modal } from '@strapi/design-system';
3+
4+
import * as ModalStories from './Modal.stories';
5+
6+
<Meta of={ModalStories} />
7+
8+
# ModalLayout
9+
10+
- [Overview](#overview)
11+
- [Usage](#usage)
12+
- [Props](#props)
13+
- [Variants](#variants)
14+
- [Accessibility](#accessibility)
15+
- [Patterns](#patterns)
16+
17+
## Usage
18+
19+
```js
20+
import { Modal } from '@strapi/design-system';
21+
```
22+
23+
<Canvas of={ModalStories.Base} />
24+
25+
## Props
26+
27+
### Root
28+
29+
<TypeTable of={Modal.Props} />
30+
31+
### Trigger
32+
33+
The `Trigger` component permanently has the `asChild` prop meaning it will always render the child merging the props &
34+
behaviour of the component.
35+
36+
<TypeTable of={Modal.TriggerProps} />
37+
38+
### Content
39+
40+
<TypeTable of={Modal.ContentProps} />
41+
42+
### Close
43+
44+
The `Close` component permanently has the `asChild` prop meaning it will always render the child merging the props &
45+
behaviour of the component.
46+
47+
<TypeTable of={Modal.CloseProps} />
48+
49+
### Header
50+
51+
<TypeTable of={Modal.HeaderProps} />
52+
53+
### Body
54+
55+
This component is not mandatory to use, but does have inbuilt styles for the recommended padding around the content of
56+
the modal as well as a scrollable container.
57+
58+
<TypeTable of={Modal.BodyProps} />
59+
60+
### Footer
61+
62+
<TypeTable of={Modal.FooterProps} />
63+
64+
## Variants
65+
66+
### Scrolling
67+
68+
The `Modal` has a maximum height, when that is hit the content inside will scroll.
69+
70+
<Canvas of={ModalStories.Scrolling} />
71+
72+
## Accessibility
73+
74+
Adheres to the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal).
75+
76+
## Patterns
77+
78+
### Closing after async action
79+
80+
A typical use of a modal in Strapi is to show a small form to the user, as such, the form should be submitted before the
81+
modal is closed and likewise, assuming success, you'd expect the modal to close. If you wrap the `confirm` button in
82+
`Modal.Close` it will automatically close the modal on click, not awaiting the async action.
83+
84+
Therefore, to manage this you should control the modal programatically to close only on success of the async action.
85+
86+
<Canvas of={ModalStories.CloseOnSuccess} />

0 commit comments

Comments
 (0)