Skip to content

Commit aae36ea

Browse files
committed
TabNav no longer accepts styled system props
1 parent 94c6122 commit aae36ea

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

.changeset/neat-masks-grab.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+
TabNav 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/TabNav.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,20 @@ This ensures that the NavLink gets `activeClassName='selected'`
2323
</TabNav>
2424
```
2525

26-
## System props
27-
28-
<Note variant="warning">
29-
30-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
31-
32-
</Note>
33-
34-
TabNav and TabNav.Link components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
35-
3626
## Component props
3727

3828
### TabNav
3929

40-
| Prop name | Type | Description |
41-
| :--------- | :----- | :------------------------------------------------------------- |
42-
| aria-label | String | Used to set the `aria-label` on the top level `<nav>` element. |
30+
| Name | Type | Default | Description |
31+
| :--------- | :---------------- | :-----: | :------------------------------------------------------------- |
32+
| aria-label | String | | Used to set the `aria-label` on the top level `<nav>` element. |
33+
| sx | SystemStyleObject | {} | Style to be applied to the component |
4334

4435
### TabNav.Link
4536

46-
| Prop name | Type | Description |
47-
| :-------- | :------ | :----------------------------------------------- |
48-
| as | String | sets the HTML tag for the component |
49-
| href | String | URL to be used for the Link |
50-
| selected | Boolean | Used to style the link as selected or unselected |
37+
| Name | Type | Default | Description |
38+
| :------- | :---------------- | :-----: | :----------------------------------------------- |
39+
| as | String | | sets the HTML tag for the component |
40+
| href | String | | URL to be used for the Link |
41+
| selected | Boolean | | Used to style the link as selected or unselected |
42+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/TabNav.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import classnames from 'classnames'
33
import * as History from 'history'
44
import React from 'react'
55
import styled from 'styled-components'
6-
import {COMMON, get, SystemCommonProps, SystemTypographyProps} from './constants'
6+
import {get} from './constants'
77
import sx, {SxProp} from './sx'
88
import {ComponentProps} from './utils/types'
99

1010
const ITEM_CLASS = 'TabNav-item'
1111
const SELECTED_CLASS = 'selected'
1212

13-
const TabNavBase = styled.div<SystemCommonProps & SxProp>`
13+
const TabNavBase = styled.div<SxProp>`
1414
margin-top: 0;
1515
border-bottom: 1px solid ${get('colors.border.default')};
16-
${COMMON}
1716
${sx}
1817
`
1918

@@ -36,9 +35,7 @@ function TabNav({children, 'aria-label': ariaLabel, ...rest}: TabNavProps) {
3635
type StyledTabNavLinkProps = {
3736
to?: History.LocationDescriptor
3837
selected?: boolean
39-
} & SystemCommonProps &
40-
SxProp &
41-
SystemTypographyProps
38+
} & SxProp
4239

4340
const TabNavLink = styled.a.attrs<StyledTabNavLinkProps>(props => ({
4441
activeClassName: typeof props.to === 'string' ? 'selected' : '',
@@ -67,7 +64,6 @@ const TabNavLink = styled.a.attrs<StyledTabNavLinkProps>(props => ({
6764
background-color: ${get('colors.canvas.default')};
6865
}
6966
70-
${COMMON};
7167
${sx};
7268
`
7369

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

0 commit comments

Comments
 (0)