Skip to content

Commit 08037c1

Browse files
committed
Breadcrumbs no longer accepts styled system props (#1469)
1 parent 46a5f07 commit 08037c1

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

.changeset/spicy-seas-mate.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+
Breadcrumbs 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/Breadcrumbs.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,21 @@ This ensures that the NavLink gets `activeClassName='selected'`
2727
</Breadcrumbs>
2828
```
2929

30-
## System props
31-
32-
<Note variant="warning">
33-
34-
System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.
35-
36-
</Note>
37-
38-
Breadcrumbs and Breadcrumbs.Item components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props.
39-
4030
## Component props
4131

4232
### Breadcrumbs
4333

44-
The `Breadcrumbs` component does not receive any additional props besides `COMMON` system props.
34+
| Prop name | Type | Default | Description |
35+
| :-------- | :---------------- | :-----: | :----------------------------------- |
36+
| children | ReactNode | | The `Breadcrumbs.Item`s |
37+
| className | string | | |
38+
| sx | SystemStyleObject | `{}` | Style to be applied to the component |
4539

4640
### Breadcrumbs.Item
4741

48-
| Prop name | Type | Default | Description |
49-
| :-------- | :------ | :-----: | :----------------------------------------------- |
50-
| as | String | `a` | Sets the HTML tag for the component |
51-
| href | String | | URL to be used for the Link |
52-
| selected | Boolean | false | Used to style the link as selected or unselected |
42+
| Prop name | Type | Default | Description |
43+
| :-------- | :---------------- | :-----: | :----------------------------------------------- |
44+
| as | string | `a` | Sets the HTML tag for the component |
45+
| href | string | | URL to be used for the Link |
46+
| selected | boolean | `false` | Used to style the link as selected or unselected |
47+
| sx | SystemStyleObject | `{}` | Style to be applied to the component |

src/Breadcrumbs.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as History from 'history'
44
import React from 'react'
55
import styled from 'styled-components'
66
import Box from './Box'
7-
import {COMMON, FLEX, get, SystemCommonProps, SystemFlexProps} from './constants'
7+
import {get} from './constants'
88
import sx, {SxProp} from './sx'
99
import {ComponentProps} from './utils/types'
1010

@@ -31,20 +31,22 @@ const Wrapper = styled.li`
3131
}
3232
`
3333

34-
const BreadcrumbsBase = styled.nav<SystemFlexProps & SystemCommonProps & SxProp>`
34+
const BreadcrumbsBase = styled.nav<SxProp>`
3535
display: flex;
3636
justify-content: space-between;
37-
${COMMON};
38-
${FLEX};
3937
${sx};
4038
`
4139

42-
export type BreadcrumbsProps = ComponentProps<typeof BreadcrumbsBase>
40+
export type BreadcrumbsProps = React.PropsWithChildren<
41+
{
42+
className?: string
43+
} & SxProp
44+
>
4345

44-
function Breadcrumbs({className, children, theme, ...rest}: React.PropsWithChildren<BreadcrumbsProps>) {
45-
const wrappedChildren = React.Children.map(children, child => <Wrapper theme={theme}>{child}</Wrapper>)
46+
function Breadcrumbs({className, children, sx: sxProp}: React.PropsWithChildren<BreadcrumbsProps>) {
47+
const wrappedChildren = React.Children.map(children, child => <Wrapper>{child}</Wrapper>)
4648
return (
47-
<BreadcrumbsBase className={className} aria-label="Breadcrumbs" theme={theme} {...rest}>
49+
<BreadcrumbsBase className={className} aria-label="Breadcrumbs" sx={sxProp}>
4850
<Box as="ol" my={0} pl={0}>
4951
{wrappedChildren}
5052
</Box>
@@ -55,8 +57,7 @@ function Breadcrumbs({className, children, theme, ...rest}: React.PropsWithChild
5557
type StyledBreadcrumbsItemProps = {
5658
to?: History.LocationDescriptor
5759
selected?: boolean
58-
} & SystemCommonProps &
59-
SxProp
60+
} & SxProp
6061

6162
const BreadcrumbsItem = styled.a.attrs<StyledBreadcrumbsItemProps>(props => ({
6263
activeClassName: typeof props.to === 'string' ? 'selected' : '',
@@ -74,7 +75,6 @@ const BreadcrumbsItem = styled.a.attrs<StyledBreadcrumbsItemProps>(props => ({
7475
color: ${get('colors.fg.default')};
7576
pointer-events: none;
7677
}
77-
${COMMON}
7878
${sx};
7979
`
8080

src/__tests__/Breadcrumbs.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'babel-polyfill'
77
expect.extend(toHaveNoViolations)
88

99
describe('Breadcrumbs', () => {
10-
behavesAsComponent({Component: Breadcrumbs})
10+
behavesAsComponent({Component: Breadcrumbs, options: {skipAs: true}})
1111

1212
checkExports('Breadcrumbs', {
1313
default: Breadcrumbs,
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 Breadcrumbs from '../Breadcrumbs'
3+
4+
export function shouldAcceptCallWithNoProps() {
5+
return (
6+
<>
7+
<Breadcrumbs />
8+
<Breadcrumbs.Item />
9+
</>
10+
)
11+
}
12+
13+
export function shouldNotAcceptSystemProps() {
14+
return (
15+
<>
16+
{/* @ts-expect-error system props should not be accepted */}
17+
<Breadcrumbs backgroundColor="maroon" />
18+
{/* @ts-expect-error system props should not be accepted */}
19+
<Breadcrumbs.Item backgroundColor="fuchsia" />
20+
</>
21+
)
22+
}

0 commit comments

Comments
 (0)