Skip to content

Commit 4811084

Browse files
committed
StyledOcticon no longer accepts styled system props
1 parent fd8a7fb commit 4811084

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
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/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)