Skip to content

Commit fa0013b

Browse files
authored
Dropdown no longer accepts styled system props (#1558)
1 parent 25cfe98 commit fa0013b

File tree

4 files changed

+39
-25
lines changed

4 files changed

+39
-25
lines changed

.changeset/bright-baboons-peel.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+
Dropdown 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/Dropdown.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,29 @@ Dropdown.Menu wraps your menu content. Be sure to pass a `direction` prop to thi
3737
</Dropdown>
3838
```
3939

40-
## System props
41-
42-
<Note variant="warning">
43-
44-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
45-
46-
</Note>
47-
48-
Dropdown, Dropdown.Menu, Dropdown.Button, Dropdown.Caret, and Dropdown.Item all get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
49-
5040
## Component props
5141

5242
The Dropdown component is extended from the [`Details`](/Details) component and gets all props that the [`Details`](/Details) component gets.
5343

5444
#### Dropdown.Menu
5545

56-
| Name | Type | Default | Description |
57-
| :-------- | :----- | :-----: | :------------------------------------------------------------------------------------ |
58-
| direction | String | 'sw' | Sets the direction of the dropdown menu. Pick from 'ne', 'e', 'se', 's', 'sw', or 'w' |
46+
| Name | Type | Default | Description |
47+
| :-------- | :---------------- | :-----: | :------------------------------------------------------------------------------------ |
48+
| direction | String | 'sw' | Sets the direction of the dropdown menu. Pick from 'ne', 'e', 'se', 's', 'sw', or 'w' |
49+
| sx | SystemStyleObject | {} | Style to be applied to the component |
5950

6051
#### Dropdown.Button
6152

62-
| Name | Type | Default | Description |
63-
| :------ | :------- | :-----: | :----------------------------------------------------------------------------------------------------------- |
64-
| onClick | Function | none | Use the `onClick` handler to add additional functionality when the button is clicked, such as fetching data. |
53+
See https://primer.style/react/Buttons#component-props
6554

6655
#### Dropdown.Caret
6756

68-
No additional props.
57+
| Name | Type | Default | Description |
58+
| :--- | :---------------- | :-----: | :----------------------------------- |
59+
| sx | SystemStyleObject | {} | Style to be applied to the component |
6960

7061
#### Dropdown.Item
7162

72-
No additional props.
63+
| Name | Type | Default | Description |
64+
| :--- | :---------------- | :-----: | :----------------------------------- |
65+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/Dropdown.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import styled from 'styled-components'
33
import Button, {ButtonProps} from './Button'
4-
import {COMMON, get, SystemCommonProps} from './constants'
4+
import {get} from './constants'
55
import Details, {DetailsProps} from './Details'
66
import getDirectionStyles from './DropdownStyles'
77
import useDetails from './hooks/useDetails'
@@ -35,7 +35,7 @@ const DropdownButton = ({children, ...rest}: DropdownButtonProps) => {
3535
)
3636
}
3737

38-
const DropdownCaret = styled.div<SystemCommonProps & SxProp>`
38+
const DropdownCaret = styled.div<SxProp>`
3939
border: 4px solid transparent;
4040
margin-left: 12px;
4141
border-top-color: currentcolor;
@@ -45,14 +45,12 @@ const DropdownCaret = styled.div<SystemCommonProps & SxProp>`
4545
height: 0;
4646
vertical-align: middle;
4747
width: 0;
48-
${COMMON};
4948
${sx};
5049
`
5150

5251
type StyledDropdownMenuProps = {
5352
direction?: 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
54-
} & SystemCommonProps &
55-
SxProp
53+
} & SxProp
5654

5755
const DropdownMenu = styled.ul<StyledDropdownMenuProps>`
5856
background-clip: padding-box;
@@ -96,7 +94,6 @@ const DropdownMenu = styled.ul<StyledDropdownMenuProps>`
9694
list-style: none;
9795
}
9896
${props => (props.direction ? getDirectionStyles(props.theme, props.direction) : '')};
99-
${COMMON};
10097
${sx};
10198
`
10299

@@ -131,7 +128,6 @@ const DropdownItem = styled.li`
131128
background-color: ${get('colors.accent.emphasis')};
132129
outline: none;
133130
}
134-
${COMMON};
135131
${sx};
136132
`
137133

src/__tests__/Dropdown.types.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react'
2+
import Dropdown from '../Dropdown'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return <Dropdown />
6+
}
7+
8+
export function shouldNotAcceptSystemProps() {
9+
return (
10+
<>
11+
{/* @ts-expect-error system props should not be accepted */}
12+
<Dropdown.Caret backgroundColor="thistle" />,{/* @ts-expect-error system props should not be accepted */}
13+
<Dropdown.Menu backgroundColor="thistle" />,{/* @ts-expect-error system props should not be accepted */}
14+
<Dropdown.Item backgroundColor="thistle" />,
15+
{/* this will not error for now, but once Button removes styled system props, this line should
16+
be updated with a @ts-expect-error */}
17+
<Dropdown.Button backgroundColor="thistle" />
18+
</>
19+
)
20+
}

0 commit comments

Comments
 (0)