Skip to content

Commit f9be10f

Browse files
committed
UnderlineNav no longer accepts styled system props (#1579)
1 parent 0c5538d commit f9be10f

File tree

4 files changed

+43
-27
lines changed

4 files changed

+43
-27
lines changed

.changeset/lucky-hounds-lie.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+
UnderlineNav 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/UnderlineNav.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,23 @@ This ensures that the NavLink gets `activeClassName='selected'`
2323
</UnderlineNav>
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-
UnderlineNav and UnderlineNav.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
### UnderlineNav
3929

40-
| Prop name | Type | Description |
41-
| :--------- | :------ | :------------------------------------------------------------------------------------- |
42-
| actions | Node | Place another element, such as a button, to the opposite side of the navigation items. |
43-
| align | String | Use `right` to have navigation items aligned right. |
44-
| full | Boolean | Used to make navigation fill the width of the container. |
45-
| aria-label | String | Used to set the `aria-label` on the top level `<nav>` element. |
30+
| Name | Type | Default | Description |
31+
| :--------- | :---------------- | :-----: | :------------------------------------------------------------------------------------- |
32+
| actions | Node | | Place another element, such as a button, to the opposite side of the navigation items. |
33+
| align | String | | Use `right` to have navigation items aligned right. |
34+
| full | Boolean | | Used to make navigation fill the width of the container. |
35+
| aria-label | String | | Used to set the `aria-label` on the top level `<nav>` element. |
36+
| sx | SystemStyleObject | {} | Style to be applied to the component |
4637

4738
### UnderlineNav.Link
4839

49-
| Prop name | Type | Description |
50-
| :-------- | :------ | :----------------------------------------------- |
51-
| as | String | sets the HTML tag for the component |
52-
| href | String | URL to be used for the Link |
53-
| selected | Boolean | Used to style the link as selected or unselected |
40+
| Name | Type | Default | Description |
41+
| :------- | :---------------- | :-----: | :----------------------------------------------- |
42+
| as | String | | sets the HTML tag for the component |
43+
| href | String | | URL to be used for the Link |
44+
| selected | Boolean | | Used to style the link as selected or unselected |
45+
| sx | SystemStyleObject | {} | Style to be applied to the component |

src/UnderlineNav.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ 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} from './constants'
6+
import {get} from './constants'
77
import sx, {SxProp} from './sx'
88
import {ComponentProps} from './utils/types'
99

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

13-
const UnderlineNavBase = styled.nav`
13+
const UnderlineNavBase = styled.nav<SxProp>`
1414
display: flex;
1515
justify-content: space-between;
1616
border-bottom: 1px solid ${get('colors.border.muted')};
@@ -39,7 +39,6 @@ const UnderlineNavBase = styled.nav`
3939
align-self: center;
4040
}
4141
42-
${COMMON};
4342
${sx};
4443
`
4544

@@ -63,8 +62,7 @@ function UnderlineNav({actions, className, align, children, full, label, theme,
6362
type StyledUnderlineNavLinkProps = {
6463
to?: History.LocationDescriptor
6564
selected?: boolean
66-
} & SystemCommonProps &
67-
SxProp
65+
} & SxProp
6866

6967
const UnderlineNavLink = styled.a.attrs<StyledUnderlineNavLinkProps>(props => ({
7068
activeClassName: typeof props.to === 'string' ? 'selected' : '',
@@ -100,7 +98,6 @@ const UnderlineNavLink = styled.a.attrs<StyledUnderlineNavLinkProps>(props => ({
10098
}
10199
}
102100
103-
${COMMON};
104101
${sx};
105102
`
106103

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 UnderlineNav from '../UnderlineNav'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return (
6+
<>
7+
<UnderlineNav />
8+
<UnderlineNav.Link />
9+
</>
10+
)
11+
}
12+
13+
export function shouldNotAcceptSystemProps() {
14+
return (
15+
<>
16+
{/* @ts-expect-error system props should not be accepted */}
17+
<UnderlineNav backgroundColor="snow" />
18+
{/* @ts-expect-error system props should not be accepted */}
19+
<UnderlineNav.Link backgroundColor="springgreen" />
20+
</>
21+
)
22+
}

0 commit comments

Comments
 (0)