Skip to content

Commit f909cf2

Browse files
authored
StyledOcticon no longer accepts styled system props (#1616)
1 parent 1012b77 commit f909cf2

File tree

6 files changed

+27
-21
lines changed

6 files changed

+27
-21
lines changed

.changeset/mean-bananas-explain.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+
StyledOcticon 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/StyledOcticon.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,14 @@ StyledOcticon renders an [Octicon](https://octicons.github.com) with common syst
1414
</>
1515
```
1616

17-
## System props
18-
19-
<Note variant="warning">
20-
21-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
22-
23-
</Note>
24-
25-
StyledOcticon components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
26-
2717
## Component props
2818

2919
StyledOcticon passes all of its props except the common system props down to the [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react#usage), including:
3020

31-
| Name | Type | Default | Description |
32-
| :------------ | :-------- | :-----------: | :----------------------------------------------------------------------------------------------------------- |
33-
| ariaLabel | String | | Specifies the `aria-label` attribute, which is read verbatim by screen readers |
34-
| icon | Component | | [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react) used in the component |
35-
| size | Number | 16 | Sets the uniform `width` and `height` of the SVG element |
36-
| verticalAlign | String | `text-bottom` | Sets the `vertical-align` CSS property |
21+
| Name | Type | Default | Description |
22+
| :------------ | :---------------- | :-----------: | :----------------------------------------------------------------------------------------------------------- |
23+
| ariaLabel | String | | Specifies the `aria-label` attribute, which is read verbatim by screen readers |
24+
| icon | Component | | [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react) used in the component |
25+
| size | Number | 16 | Sets the uniform `width` and `height` of the SVG element |
26+
| verticalAlign | String | `text-bottom` | Sets the `vertical-align` CSS property |
27+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/DropdownMenu/DropdownButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const DropdownButton = React.forwardRef<HTMLElement, React.PropsWithChild
99
({children, ...props}: React.PropsWithChildren<DropdownButtonProps>, ref): JSX.Element => (
1010
<Button ref={ref} type="button" {...props}>
1111
{children}
12-
<StyledOcticon icon={TriangleDownIcon} ml={1} />
12+
<StyledOcticon icon={TriangleDownIcon} sx={{ml: 1}} />
1313
</Button>
1414
)
1515
)

src/StateLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function StateLabel({children, status, variant: variantProp, ...rest}: StateLabe
9999
return (
100100
<StateLabelBase {...rest} variant={variantProp} status={status}>
101101
{/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */}
102-
{status && <StyledOcticon mr={1} {...octiconProps} icon={octiconMap[status] || QuestionIcon} />}
102+
{status && <StyledOcticon {...octiconProps} icon={octiconMap[status] || QuestionIcon} sx={{mr: 1}} />}
103103
{children}
104104
</StateLabelBase>
105105
)

src/StyledOcticon.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {IconProps} from '@primer/octicons-react'
22
import React from 'react'
33
import styled from 'styled-components'
4-
import {COMMON, SystemCommonProps} from './constants'
54
import sx, {SxProp} from './sx'
65
import {ComponentProps} from './utils/types'
76

@@ -11,8 +10,7 @@ function Octicon({icon: IconComponent, ...rest}: OcticonProps) {
1110
return <IconComponent {...rest} />
1211
}
1312

14-
const StyledOcticon = styled(Octicon)<SystemCommonProps & SxProp>`
15-
${COMMON}
13+
const StyledOcticon = styled(Octicon)<SxProp>`
1614
${sx}
1715
`
1816

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

0 commit comments

Comments
 (0)