Skip to content

Commit b170920

Browse files
committed
Popover no longer accepts styled system props (#1570)
1 parent 6806d53 commit b170920

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

.changeset/gentle-birds-cough.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+
Popover 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/Popover.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,25 @@ function CaretSelector(props) {
105105
render(<PopoverDemo />)
106106
```
107107

108-
## System props
109-
110-
<Note variant="warning">
111-
112-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
113-
114-
</Note>
115-
116-
ProgressBar components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
117-
118108
## Component props
119109

120110
### Popover
121111

122-
| Name | Type | Default | Description |
123-
| :------- | :------ | :-----: | :----------------------------------------------------------------------------- |
124-
| as | String | 'div' | Sets the HTML tag for the component. |
125-
| caret | String | 'top' | Controls the position of the caret. See below for the list of caret positions. |
126-
| open | Boolean | false | Controls the visibility of the popover. |
127-
| relative | Boolean | false | Set to true to render the popover using relative positioning. |
112+
| Name | Type | Default | Description |
113+
| :------- | :---------------- | :-----: | :----------------------------------------------------------------------------- |
114+
| as | String | 'div' | Sets the HTML tag for the component. |
115+
| caret | String | 'top' | Controls the position of the caret. See below for the list of caret positions. |
116+
| open | Boolean | false | Controls the visibility of the popover. |
117+
| relative | Boolean | false | Set to true to render the popover using relative positioning. |
118+
| sx | SystemStyleObject | {} | Style to be applied to the component |
128119

129120
#### Caret Positions
130121

131122
The `caret` prop can be one of the following values: `top`, `bottom`, `left`, `right`, `bottom-left`, `bottom-right`, `top-left`, `top-right`, `left-bottom`, `left-top`, `right-bottom`, or `right-top`.
132123

133124
### Popover.Content
134125

135-
| Name | Type | Default | Description |
136-
| :--- | :----- | :-----: | :----------------------------------- |
137-
| as | String | 'div' | Sets the HTML tag for the component. |
126+
| Name | Type | Default | Description |
127+
| :--- | :---------------- | :-----: | :----------------------------------- |
128+
| as | String | 'div' | Sets the HTML tag for the component. |
129+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/Popover.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import classnames from 'classnames'
22
import styled from 'styled-components'
3-
import Box from './Box'
4-
import {COMMON, get, LAYOUT, POSITION, SystemCommonProps, SystemLayoutProps, SystemPositionProps} from './constants'
3+
import {get} from './constants'
54
import sx, {SxProp} from './sx'
65
import {ComponentProps} from './utils/types'
76

@@ -23,10 +22,7 @@ type StyledPopoverProps = {
2322
caret?: CaretPosition
2423
relative?: boolean
2524
open?: boolean
26-
} & SystemCommonProps &
27-
SystemLayoutProps &
28-
SystemPositionProps &
29-
SxProp
25+
} & SxProp
3026

3127
const Popover = styled.div.attrs<StyledPopoverProps>(({className, caret}) => {
3228
return {
@@ -36,14 +32,10 @@ const Popover = styled.div.attrs<StyledPopoverProps>(({className, caret}) => {
3632
position: ${props => (props.relative ? 'relative' : 'absolute')};
3733
z-index: 100;
3834
display: ${props => (props.open ? 'block' : 'none')};
39-
40-
${COMMON};
41-
${LAYOUT};
42-
${POSITION};
4335
${sx};
4436
`
4537

46-
const PopoverContent = styled(Box)`
38+
const PopoverContent = styled.div<SxProp>`
4739
border: 1px solid ${get('colors.border.default')};
4840
border-radius: ${get('radii.2')};
4941
position: relative;
@@ -53,9 +45,6 @@ const PopoverContent = styled(Box)`
5345
padding: ${get('space.4')};
5446
background-color: ${get('colors.canvas.overlay')};
5547
56-
${COMMON};
57-
${LAYOUT};
58-
5948
// Carets
6049
&::before,
6150
&::after {

src/__tests__/Popover.types.test.tsx

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

0 commit comments

Comments
 (0)