diff --git a/.changeset/mean-bananas-explain.md b/.changeset/mean-bananas-explain.md new file mode 100644 index 00000000000..e1d71ed5590 --- /dev/null +++ b/.changeset/mean-bananas-explain.md @@ -0,0 +1,5 @@ +--- +'@primer/components': major +--- + +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. diff --git a/docs/content/StyledOcticon.md b/docs/content/StyledOcticon.md index 7369fda72d5..a61e54858b8 100644 --- a/docs/content/StyledOcticon.md +++ b/docs/content/StyledOcticon.md @@ -14,23 +14,14 @@ StyledOcticon renders an [Octicon](https://octicons.github.com) with common syst ``` -## System props - - - -System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead. - - - -StyledOcticon components get `COMMON` system props. Read our [System Props](/system-props) doc page for a full list of available props. - ## Component props 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: -| Name | Type | Default | Description | -| :------------ | :-------- | :-----------: | :----------------------------------------------------------------------------------------------------------- | -| ariaLabel | String | | Specifies the `aria-label` attribute, which is read verbatim by screen readers | -| icon | Component | | [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react) used in the component | -| size | Number | 16 | Sets the uniform `width` and `height` of the SVG element | -| verticalAlign | String | `text-bottom` | Sets the `vertical-align` CSS property | +| Name | Type | Default | Description | +| :------------ | :---------------- | :-----------: | :----------------------------------------------------------------------------------------------------------- | +| ariaLabel | String | | Specifies the `aria-label` attribute, which is read verbatim by screen readers | +| icon | Component | | [Octicon component](https://github.com/primer/octicons/tree/master/lib/octicons_react) used in the component | +| size | Number | 16 | Sets the uniform `width` and `height` of the SVG element | +| verticalAlign | String | `text-bottom` | Sets the `vertical-align` CSS property | +| sx | SystemStyleObject | {} | Style to be applied to the component | diff --git a/src/DropdownMenu/DropdownButton.tsx b/src/DropdownMenu/DropdownButton.tsx index 450e6133429..9c5fd216857 100644 --- a/src/DropdownMenu/DropdownButton.tsx +++ b/src/DropdownMenu/DropdownButton.tsx @@ -9,7 +9,7 @@ export const DropdownButton = React.forwardRef, ref): JSX.Element => ( ) ) diff --git a/src/StateLabel.tsx b/src/StateLabel.tsx index 928331881b6..14b88ee1480 100644 --- a/src/StateLabel.tsx +++ b/src/StateLabel.tsx @@ -101,7 +101,7 @@ function StateLabel({children, status, variant: variantProp, ...rest}: StateLabe return ( {/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */} - {status && } + {status && } {children} ) diff --git a/src/StyledOcticon.tsx b/src/StyledOcticon.tsx index b543e7a73c8..ecc7f5c6079 100644 --- a/src/StyledOcticon.tsx +++ b/src/StyledOcticon.tsx @@ -1,7 +1,6 @@ import {IconProps} from '@primer/octicons-react' import React from 'react' import styled from 'styled-components' -import {COMMON, SystemCommonProps} from './constants' import sx, {SxProp} from './sx' import {ComponentProps} from './utils/types' @@ -11,8 +10,7 @@ function Octicon({icon: IconComponent, ...rest}: OcticonProps) { return } -const StyledOcticon = styled(Octicon)` - ${COMMON} +const StyledOcticon = styled(Octicon)` ${sx} ` diff --git a/src/__tests__/StyledOcticon.types.test.tsx b/src/__tests__/StyledOcticon.types.test.tsx new file mode 100644 index 00000000000..3429f62b7cb --- /dev/null +++ b/src/__tests__/StyledOcticon.types.test.tsx @@ -0,0 +1,12 @@ +import {MoonIcon} from '@primer/octicons-react' +import React from 'react' +import StyledOcticon from '../StyledOcticon' + +export function shouldAcceptCallWithNoProps() { + return +} + +export function shouldNotAcceptSystemProps() { + // @ts-expect-error system props should not be accepted + return +}