diff --git a/.changeset/spicy-seas-mate.md b/.changeset/spicy-seas-mate.md new file mode 100644 index 00000000000..35a1a2b819f --- /dev/null +++ b/.changeset/spicy-seas-mate.md @@ -0,0 +1,5 @@ +--- +'@primer/components': major +--- + +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. diff --git a/docs/content/Breadcrumbs.md b/docs/content/Breadcrumbs.md index 82cb55e1e24..2d870eaed7d 100644 --- a/docs/content/Breadcrumbs.md +++ b/docs/content/Breadcrumbs.md @@ -27,26 +27,21 @@ This ensures that the NavLink gets `activeClassName='selected'` ``` -## System props - - - -System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead. - - - -Breadcrumbs and Breadcrumbs.Item components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. - ## Component props ### Breadcrumbs -The `Breadcrumbs` component does not receive any additional props besides `COMMON` system props. +| Prop name | Type | Default | Description | +| :-------- | :---------------- | :-----: | :----------------------------------- | +| children | ReactNode | | The `Breadcrumbs.Item`s | +| className | string | | | +| sx | SystemStyleObject | `{}` | Style to be applied to the component | ### Breadcrumbs.Item -| Prop name | Type | Default | Description | -| :-------- | :------ | :-----: | :----------------------------------------------- | -| as | String | `a` | Sets the HTML tag for the component | -| href | String | | URL to be used for the Link | -| selected | Boolean | false | Used to style the link as selected or unselected | +| Prop name | Type | Default | Description | +| :-------- | :---------------- | :-----: | :----------------------------------------------- | +| as | string | `a` | Sets the HTML tag for the component | +| href | string | | URL to be used for the Link | +| selected | boolean | `false` | Used to style the link as selected or unselected | +| sx | SystemStyleObject | `{}` | Style to be applied to the component | diff --git a/src/Breadcrumbs.tsx b/src/Breadcrumbs.tsx index 1a2640aa8fc..7e2818867b1 100644 --- a/src/Breadcrumbs.tsx +++ b/src/Breadcrumbs.tsx @@ -4,7 +4,7 @@ import * as History from 'history' import React from 'react' import styled from 'styled-components' import Box from './Box' -import {COMMON, FLEX, get, SystemCommonProps, SystemFlexProps} from './constants' +import {get} from './constants' import sx, {SxProp} from './sx' import {ComponentProps} from './utils/types' @@ -31,20 +31,22 @@ const Wrapper = styled.li` } ` -const BreadcrumbsBase = styled.nav` +const BreadcrumbsBase = styled.nav` display: flex; justify-content: space-between; - ${COMMON}; - ${FLEX}; ${sx}; ` -export type BreadcrumbsProps = ComponentProps +export type BreadcrumbsProps = React.PropsWithChildren< + { + className?: string + } & SxProp +> -function Breadcrumbs({className, children, theme, ...rest}: React.PropsWithChildren) { - const wrappedChildren = React.Children.map(children, child => {child}) +function Breadcrumbs({className, children, sx: sxProp}: React.PropsWithChildren) { + const wrappedChildren = React.Children.map(children, child => {child}) return ( - + {wrappedChildren} @@ -55,8 +57,7 @@ function Breadcrumbs({className, children, theme, ...rest}: React.PropsWithChild type StyledBreadcrumbsItemProps = { to?: History.LocationDescriptor selected?: boolean -} & SystemCommonProps & - SxProp +} & SxProp const BreadcrumbsItem = styled.a.attrs(props => ({ activeClassName: typeof props.to === 'string' ? 'selected' : '', @@ -74,7 +75,6 @@ const BreadcrumbsItem = styled.a.attrs(props => ({ color: ${get('colors.fg.default')}; pointer-events: none; } - ${COMMON} ${sx}; ` diff --git a/src/__tests__/Breadcrumbs.test.tsx b/src/__tests__/Breadcrumbs.test.tsx index 3f040940ecd..02cb3e685c5 100644 --- a/src/__tests__/Breadcrumbs.test.tsx +++ b/src/__tests__/Breadcrumbs.test.tsx @@ -7,7 +7,7 @@ import 'babel-polyfill' expect.extend(toHaveNoViolations) describe('Breadcrumbs', () => { - behavesAsComponent({Component: Breadcrumbs}) + behavesAsComponent({Component: Breadcrumbs, options: {skipAs: true}}) checkExports('Breadcrumbs', { default: Breadcrumbs, diff --git a/src/__tests__/Breadcrumbs.types.test.tsx b/src/__tests__/Breadcrumbs.types.test.tsx new file mode 100644 index 00000000000..82c5c234bf7 --- /dev/null +++ b/src/__tests__/Breadcrumbs.types.test.tsx @@ -0,0 +1,22 @@ +import React from 'react' +import Breadcrumbs from '../Breadcrumbs' + +export function shouldAcceptCallWithNoProps() { + return ( + <> + + + + ) +} + +export function shouldNotAcceptSystemProps() { + return ( + <> + {/* @ts-expect-error system props should not be accepted */} + + {/* @ts-expect-error system props should not be accepted */} + + + ) +}