Skip to content

Commit fc9f9dc

Browse files
committed
Dialog no longer accepts styled system props
1 parent 22483b9 commit fc9f9dc

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

.changeset/moody-buttons-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/components': major
3+
---
4+
5+
Dialog no longer accepts styled-system props. Please use the `sx` prop to extend Primer component styling instead. See also https://primer.style/react/overriding-styles for information about `sx` and https://primer.style/react/system-props for context on the removal.

docs/content/Dialog.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,22 @@ You can also pass any non-text content into the header:
8484
</State>
8585
```
8686
87-
## System props
88-
89-
<Note variant="warning">
90-
91-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
92-
93-
</Note>
87+
## Component props
9488
95-
`Dialog` components get the `COMMON` and `LAYOUT` categories of system props. `Dialog.Header` components get `COMMON`, `LAYOUT`, and `FLEX` system props. Read our [System Props](/system-props) doc page for a full list of available props.
89+
### Dialog
9690
97-
## Component props
91+
| Prop name | Type | Default | Description |
92+
| :-------------- | :---------------- | :------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
93+
| isOpen | Boolean | | Set whether or not the dialog is shown |
94+
| onDismiss | Function | | A user-provided function that should close the dialog |
95+
| returnFocusRef | React ref | | The element to restore focus back to after the `Dialog` is closed |
96+
| initialFocusRef | React ref | | Element inside of the `Dialog` you'd like to be focused when the Dialog is opened. If nothing is passed to `initialFocusRef` the close button is focused. |
97+
| aria-labelledby | string | | Pass an id to use for the aria-label. Use either a `aria-label` or an `aria-labelledby` but not both. |
98+
| aria-label | string | | Pass a label to be used to describe the Dialog. Use either a `aria-label` or an `aria-labelledby` but not both. |
99+
| sx | SystemStyleObject | {} | Style to be applied to the component |
98100

99-
| Prop name | Type | Description |
100-
| :-------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
101-
| isOpen | Boolean | Set whether or not the dialog is shown |
102-
| onDismiss | Function | A user-provided function that should close the dialog |
103-
| returnFocusRef | React ref | The element to restore focus back to after the `Dialog` is closed |
104-
| initialFocusRef | React ref | Element inside of the `Dialog` you'd like to be focused when the Dialog is opened. If nothing is passed to `initialFocusRef` the close button is focused. |
105-
| aria-labelledby | string | Pass an id to use for the aria-label. Use either a `aria-label` or an `aria-labelledby` but not both. |
106-
| aria-label | string | Pass a label to be used to describe the Dialog. Use either a `aria-label` or an `aria-labelledby` but not both. |
101+
### Dialog.Header
107102

108-
`Dialog.Header` does not take any non-system props.
103+
| Prop name | Type | Default | Description |
104+
| :-------- | :---------------- | :------ | :----------------------------------- |
105+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/Dialog.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {forwardRef, useRef} from 'react'
22
import styled from 'styled-components'
33
import ButtonClose from './Button/ButtonClose'
4-
import {COMMON, get, LAYOUT, SystemCommonProps, SystemLayoutProps} from './constants'
4+
import {get} from './constants'
55
import Box from './Box'
66
import useDialog from './hooks/useDialog'
77
import sx, {SxProp} from './sx'
@@ -14,9 +14,7 @@ const noop = () => null
1414
type StyledDialogBaseProps = {
1515
narrow?: boolean
1616
wide?: boolean
17-
} & SystemLayoutProps &
18-
SystemCommonProps &
19-
SxProp
17+
} & SxProp
2018

2119
const DialogBase = styled.div<StyledDialogBaseProps>`
2220
box-shadow: ${get('shadows.shadow.large')};
@@ -39,8 +37,6 @@ const DialogBase = styled.div<StyledDialogBaseProps>`
3937
height: 100vh;
4038
}
4139
42-
${LAYOUT};
43-
${COMMON};
4440
${sx};
4541
`
4642

src/__tests__/Dialog.types.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import Dialog from '../Dialog'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return <Dialog />
6+
}
7+
8+
export function shouldNotAcceptSystemProps() {
9+
// @ts-expect-error system props should not be accepted
10+
return <Dialog backgroundColor="thistle" />
11+
}

0 commit comments

Comments
 (0)