diff --git a/.changeset/tame-eggs-taste.md b/.changeset/tame-eggs-taste.md new file mode 100644 index 00000000000..a88de510a63 --- /dev/null +++ b/.changeset/tame-eggs-taste.md @@ -0,0 +1,6 @@ +--- +"@primer/react": major +"@primer/styled-react": patch +--- + +chore(Octicon): remove sx diff --git a/.playwright/snapshots/components/IconButton.test.ts-snapshots/IconButton-Keybinding-Hint-light-linux.png b/.playwright/snapshots/components/IconButton.test.ts-snapshots/IconButton-Keybinding-Hint-light-linux.png index d9daf3707d6..43e09aa2cb9 100644 Binary files a/.playwright/snapshots/components/IconButton.test.ts-snapshots/IconButton-Keybinding-Hint-light-linux.png and b/.playwright/snapshots/components/IconButton.test.ts-snapshots/IconButton-Keybinding-Hint-light-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-colorblind-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-colorblind-linux.png index b8f8b4d3d69..08f9783397a 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-colorblind-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-dimmed-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-dimmed-linux.png index 26a45d5aed9..9d435eef02a 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-dimmed-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-high-contrast-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-high-contrast-linux.png index 9d96119bde4..bbdc1538a83 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-high-contrast-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-linux.png index 434bace6863..b474579ffc6 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-tritanopia-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-tritanopia-linux.png index 59ade5e753a..bef6cc2df5e 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-tritanopia-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-colorblind-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-colorblind-linux.png index f5904882203..6a3a36460f5 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-colorblind-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-high-contrast-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-high-contrast-linux.png index ac6d7ff1322..1fa1d1eec30 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-high-contrast-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-linux.png index f4b489b8ab8..3df8252d576 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-linux.png differ diff --git a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-tritanopia-linux.png b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-tritanopia-linux.png index 2b628f5c3c2..c4dd5261047 100644 Binary files a/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-tritanopia-linux.png and b/.playwright/snapshots/components/StateLabel.test.ts-snapshots/StateLabel-Small-light-tritanopia-linux.png differ diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.module.css b/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.module.css index 7b07f7dc17d..8f1eb2584c2 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.module.css +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.module.css @@ -58,3 +58,7 @@ color: var(--fgColor-muted); margin-left: var(--base-size-4); } + +.Icon { + color: var(--fgColor-muted); +} diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsx b/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsx index e8d710f2975..cfd6f9dc042 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsx +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsx @@ -35,11 +35,11 @@ const hoverCard = ( Former beach cat and champion swimmer. Now your friendly octopus with a normal face. - + Interwebs - + Owns this repository diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.module.css b/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.module.css index d2aee9d9598..e227dc685b9 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.module.css +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.module.css @@ -8,3 +8,7 @@ color: var(--fgColor-muted); margin-left: var(--base-size-4); } + +.Icon { + color: var(--fgColor-muted); +} diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.tsx b/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.tsx index 0c11a0d85ec..78c914c4ab4 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.tsx +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.tsx @@ -31,11 +31,11 @@ const hoverCard = ( Former beach cat and champion swimmer. Now your friendly octapus with a normal face. - + Interwebs - + Owns this repository diff --git a/packages/react/src/Octicon/Octicon.docs.json b/packages/react/src/Octicon/Octicon.docs.json index bf36d48e88b..aba5e119e09 100644 --- a/packages/react/src/Octicon/Octicon.docs.json +++ b/packages/react/src/Octicon/Octicon.docs.json @@ -35,11 +35,6 @@ "type": "string", "defaultValue": "text-bottom", "description": "Sets the `vertical-align` CSS property" - }, - { - "name": "sx", - "type": "SystemStyleObject", - "deprecated": true } ], "subcomponents": [] diff --git a/packages/react/src/Octicon/Octicon.stories.tsx b/packages/react/src/Octicon/Octicon.stories.tsx index 537c1d935cc..ea024064a9d 100644 --- a/packages/react/src/Octicon/Octicon.stories.tsx +++ b/packages/react/src/Octicon/Octicon.stories.tsx @@ -10,9 +10,9 @@ export default meta export const Default = () => -export const Playground: StoryFn = ({'aria-label': ariaLabel, ...args}) => ( - -) +export const Playground: StoryFn = ({'aria-label': ariaLabel, icon: _icon, ...args}) => { + return +} Playground.args = { 'aria-label': 'Heart', @@ -36,28 +36,10 @@ Playground.argTypes = { disable: true, }, }, - sx: { - controls: false, - table: { - disable: true, - }, - }, as: { controls: false, table: { disable: true, }, }, - forwardedAs: { - controls: false, - table: { - disable: true, - }, - }, - theme: { - controls: false, - table: { - disable: true, - }, - }, } diff --git a/packages/react/src/Octicon/Octicon.test.tsx b/packages/react/src/Octicon/Octicon.test.tsx index e3e9c1a3955..950f3adaed4 100644 --- a/packages/react/src/Octicon/Octicon.test.tsx +++ b/packages/react/src/Octicon/Octicon.test.tsx @@ -9,11 +9,6 @@ describe('Octicon', () => { expect(container.firstChild).toHaveClass('test-class') }) - it('should support `sx`', () => { - const {container} = render() - expect(container.firstChild).toHaveStyle('color: rgb(255, 0, 0)') - }) - it('should pass along props to the outermost element', () => { const {container} = render() expect(container.firstChild).toHaveAttribute('data-testid', 'test-id') diff --git a/packages/react/src/Octicon/Octicon.tsx b/packages/react/src/Octicon/Octicon.tsx index a0c52454789..83f3dc61441 100644 --- a/packages/react/src/Octicon/Octicon.tsx +++ b/packages/react/src/Octicon/Octicon.tsx @@ -1,30 +1,17 @@ import type {IconProps} from '@primer/octicons-react' import React from 'react' -import styled from 'styled-components' -import type {SxProp} from '../sx' -import sx from '../sx' -import type {ComponentProps} from '../utils/types' - -type StyledOcticonProps = {icon: React.ElementType; color?: string} & IconProps & SxProp - -const Icon = React.forwardRef((props: StyledOcticonProps, ref: React.Ref) => { - const {icon: IconComponent, ...rest} = props - return -}) /** * @deprecated Use the icon component directly from `@primer/octicons-react` instead */ -const Octicon = styled(Icon).withConfig({ - shouldForwardProp(prop) { - return prop !== 'sx' - }, -})` - ${({color, sx: sxProp}) => sx({sx: {color, ...sxProp}})} -` +export type OcticonProps = {icon: React.ElementType; as?: React.ElementType} & IconProps /** * @deprecated Use the icon component directly from `@primer/octicons-react` instead */ -export type OcticonProps = ComponentProps +const Octicon = React.forwardRef((props: OcticonProps, ref: React.Ref) => { + const {icon: IconComponent, ...rest} = props + return +}) + export default Octicon diff --git a/packages/react/src/StateLabel/StateLabel.module.css b/packages/react/src/StateLabel/StateLabel.module.css index 19f3ae958de..df77767a72b 100644 --- a/packages/react/src/StateLabel/StateLabel.module.css +++ b/packages/react/src/StateLabel/StateLabel.module.css @@ -100,3 +100,7 @@ .Icon { margin-right: var(--base-size-4); } + +.Icon:where([data-variant-small]) { + width: 1em; +} diff --git a/packages/react/src/StateLabel/StateLabel.tsx b/packages/react/src/StateLabel/StateLabel.tsx index 2e7590f008c..6e9d753f165 100644 --- a/packages/react/src/StateLabel/StateLabel.tsx +++ b/packages/react/src/StateLabel/StateLabel.tsx @@ -53,7 +53,6 @@ export type StateLabelProps = React.HTMLAttributes & { const StateLabel = forwardRef( ({children, status, variant: variantProp = 'normal', className, ...rest}, ref) => { - const octiconProps = variantProp === 'small' ? {width: '1em'} : {} // Open and closed statuses, we don't want to show an icon const noIconStatus = status === 'open' || status === 'closed' @@ -66,7 +65,12 @@ const StateLabel = forwardRef( data-status={status} > {!noIconStatus && ( - + )} {children} diff --git a/packages/react/src/StateLabel/__tests__/__snapshots__/StateLabel.test.tsx.snap b/packages/react/src/StateLabel/__tests__/__snapshots__/StateLabel.test.tsx.snap index 2e1730ccb59..118388c281c 100644 --- a/packages/react/src/StateLabel/__tests__/__snapshots__/StateLabel.test.tsx.snap +++ b/packages/react/src/StateLabel/__tests__/__snapshots__/StateLabel.test.tsx.snap @@ -9,7 +9,7 @@ exports[`StateLabel > renders children 1`] = ` > respects the status prop 1`] = ` > respects the status prop 2`] = ` > respects the status prop 3`] = ` > respects the status prop 4`] = ` > respects the status prop 5`] = ` > respects the variant prop 1`] = ` > respects the variant prop 2`] = ` > ( - + This is a message diff --git a/packages/react/src/TreeView/TreeView.features.stories.module.css b/packages/react/src/TreeView/TreeView.features.stories.module.css index 7253a474364..4c4763355bd 100644 --- a/packages/react/src/TreeView/TreeView.features.stories.module.css +++ b/packages/react/src/TreeView/TreeView.features.stories.module.css @@ -16,3 +16,15 @@ max-height: 50vh; overflow: auto; } + +.SuccessIcon { + color: var(--fgColor-success); +} + +.AttentionIcon { + color: var(--fgColor-attention); +} + +.DangerIcon { + color: var(--fgColor-danger); +} diff --git a/packages/react/src/TreeView/TreeView.features.stories.tsx b/packages/react/src/TreeView/TreeView.features.stories.tsx index 684d8eebcf7..ff027a604a0 100644 --- a/packages/react/src/TreeView/TreeView.features.stories.tsx +++ b/packages/react/src/TreeView/TreeView.features.stories.tsx @@ -122,7 +122,7 @@ export const FilesChanged: StoryFn = () => { Avatar.tsx - + @@ -137,7 +137,7 @@ export const FilesChanged: StoryFn = () => { Button.tsx - + @@ -146,7 +146,7 @@ export const FilesChanged: StoryFn = () => { Button.test.tsx - + @@ -157,7 +157,7 @@ export const FilesChanged: StoryFn = () => { ReallyLongFileNameThatShouldBeTruncated.tsx - + @@ -183,7 +183,7 @@ export const FilesChanged: StoryFn = () => { favicon.ico - + @@ -967,7 +967,7 @@ export const WithoutIndentation: StoryFn = () => ( Avatar.tsx - + @@ -976,7 +976,7 @@ export const WithoutIndentation: StoryFn = () => ( Button.tsx - + @@ -987,7 +987,7 @@ export const WithoutIndentation: StoryFn = () => ( package.json - + @@ -1010,7 +1010,7 @@ export const MultilineItems: StoryFn = () => ( Avatar.tsx - + @@ -1021,7 +1021,7 @@ export const MultilineItems: StoryFn = () => ( this is a medium directory name that we wrap over 2 lines to demonstrate alignment - + @@ -1030,7 +1030,7 @@ export const MultilineItems: StoryFn = () => ( Avatar.tsx - + @@ -1048,7 +1048,7 @@ export const MultilineItems: StoryFn = () => ( Avatar.tsx - + @@ -1065,7 +1065,7 @@ export const MultilineItems: StoryFn = () => ( Avatar.tsx - + diff --git a/packages/react/src/TreeView/TreeView.stories.tsx b/packages/react/src/TreeView/TreeView.stories.tsx index c4822e02bc1..6ea15b26b20 100644 --- a/packages/react/src/TreeView/TreeView.stories.tsx +++ b/packages/react/src/TreeView/TreeView.stories.tsx @@ -33,7 +33,7 @@ export const Default: StoryFn = () => ( Avatar.tsx - + @@ -42,7 +42,7 @@ export const Default: StoryFn = () => ( Button.tsx - + @@ -53,7 +53,7 @@ export const Default: StoryFn = () => ( package.json - + diff --git a/packages/react/src/TreeView/TreeView.stress.dev.stories.tsx b/packages/react/src/TreeView/TreeView.stress.dev.stories.tsx index aed5ba6396f..aa2fa11718c 100644 --- a/packages/react/src/TreeView/TreeView.stress.dev.stories.tsx +++ b/packages/react/src/TreeView/TreeView.stress.dev.stories.tsx @@ -5,6 +5,8 @@ import {TreeView} from './TreeView' import {FileIcon, DiffAddedIcon} from '@primer/octicons-react' import Octicon from '../Octicon' +import classes from './Treeview.stress.dev.stories.module.css' + export default { title: 'StressTests/Components/TreeView', component: TreeView, @@ -38,7 +40,7 @@ export const CurrentUpdate = () => { {file.name} - + ))} diff --git a/packages/react/src/TreeView/TreeViewStories.module.css b/packages/react/src/TreeView/TreeViewStories.module.css index 2530ce3190c..6672d4ab1c2 100644 --- a/packages/react/src/TreeView/TreeViewStories.module.css +++ b/packages/react/src/TreeView/TreeViewStories.module.css @@ -10,3 +10,19 @@ .DraggableItemContainer .TreeViewItem:focus .TreeViewLeadingAction { visibility: visible; } + +.SuccessIcon { + color: var(--fgColor-success); +} + +.AttentionIcon { + color: var(--fgColor-attention); +} + +.DoneIcon { + color: var(--fgColor-done); +} + +.OpenIcon { + color: var(--fgColor-open); +} diff --git a/packages/react/src/TreeView/TreeViewWithLeadingAction.stories.tsx b/packages/react/src/TreeView/TreeViewWithLeadingAction.stories.tsx index d833c2251cb..c32ff82d035 100644 --- a/packages/react/src/TreeView/TreeViewWithLeadingAction.stories.tsx +++ b/packages/react/src/TreeView/TreeViewWithLeadingAction.stories.tsx @@ -43,7 +43,7 @@ export const LeadingAction: StoryFn = () => { - + Item 1 @@ -52,19 +52,19 @@ export const LeadingAction: StoryFn = () => { - + Item 2 - + sub task 1 - + sub task 2 @@ -75,7 +75,7 @@ export const LeadingAction: StoryFn = () => { - + Item 3 diff --git a/packages/react/src/TreeView/Treeview.stress.dev.stories.module.css b/packages/react/src/TreeView/Treeview.stress.dev.stories.module.css new file mode 100644 index 00000000000..b3f6d8290c4 --- /dev/null +++ b/packages/react/src/TreeView/Treeview.stress.dev.stories.module.css @@ -0,0 +1,3 @@ +.SuccessIcon { + color: var(--fgColor-success); +} diff --git a/packages/react/src/stories/deprecated/SideNav.dev.stories.module.css b/packages/react/src/stories/deprecated/SideNav.dev.stories.module.css new file mode 100644 index 00000000000..b3f6d8290c4 --- /dev/null +++ b/packages/react/src/stories/deprecated/SideNav.dev.stories.module.css @@ -0,0 +1,3 @@ +.SuccessIcon { + color: var(--fgColor-success); +} diff --git a/packages/react/src/stories/deprecated/SideNav.dev.stories.tsx b/packages/react/src/stories/deprecated/SideNav.dev.stories.tsx index 0c6b92b9fb3..bb7cd478b6a 100644 --- a/packages/react/src/stories/deprecated/SideNav.dev.stories.tsx +++ b/packages/react/src/stories/deprecated/SideNav.dev.stories.tsx @@ -4,6 +4,8 @@ import type {ComponentProps} from '../../utils/types' import Octicon from '../../Octicon' import {DotIcon, MailIcon, PersonIcon, SmileyIcon, ZapIcon} from '@primer/octicons-react' +import classes from './SideNav.dev.stories.module.css' + export default { title: 'Deprecated/Components/SideNav/Dev', component: SideNav, @@ -41,7 +43,7 @@ export const FullVariant = () => ( With a status icon - + With a label diff --git a/packages/styled-react/src/__tests__/primer-react-deprecated.browser.test.tsx b/packages/styled-react/src/__tests__/primer-react-deprecated.browser.test.tsx index 4e7c24af6ab..dceb28f4228 100644 --- a/packages/styled-react/src/__tests__/primer-react-deprecated.browser.test.tsx +++ b/packages/styled-react/src/__tests__/primer-react-deprecated.browser.test.tsx @@ -17,7 +17,7 @@ describe('@primer/react/deprecated', () => { }) test('Octicon supports `sx` prop', () => { - render( } sx={{background: 'red'}} />) + render( } sx={{background: 'red'}} />) expect(window.getComputedStyle(screen.getByTestId('component')).backgroundColor).toBe('rgb(255, 0, 0)') }) diff --git a/packages/styled-react/src/components/Octicon.tsx b/packages/styled-react/src/components/Octicon.tsx new file mode 100644 index 00000000000..3a7422824cd --- /dev/null +++ b/packages/styled-react/src/components/Octicon.tsx @@ -0,0 +1,27 @@ +import {Octicon as PrimerOcticon, type OcticonProps as PrimerOcticonProps} from '@primer/react/deprecated' +import styled from 'styled-components' +import {type SxProp, sx} from '../sx' +import {forwardRef} from 'react' + +/** + * @deprecated Use the icon component directly from `@primer/octicons-react` instead + */ +export type OcticonProps = PrimerOcticonProps & SxProp & {color?: string} + +/** + * @deprecated Use the icon component directly from `@primer/octicons-react` instead + */ +const StyledOcticon = styled(PrimerOcticon).withConfig({ + shouldForwardProp(prop) { + return prop !== 'sx' + }, +})` + ${({color, sx: sxProp}) => sx({sx: {color, ...sxProp}})} +` + +const Octicon = forwardRef(({as, ...props}: OcticonProps, ref) => { + return +}) + +export default Octicon +export {Octicon} diff --git a/packages/styled-react/src/deprecated.tsx b/packages/styled-react/src/deprecated.tsx index 2c91cbbd61f..9c2b14703fa 100644 --- a/packages/styled-react/src/deprecated.tsx +++ b/packages/styled-react/src/deprecated.tsx @@ -1,4 +1,4 @@ export {TabNav, type TabNavProps, type TabNavLinkProps} from './components/TabNav' export {Dialog, type DialogProps, type DialogHeaderProps} from './components/DialogV1' -export {Octicon} from '@primer/react/deprecated' +export {Octicon, type OcticonProps} from './components/Octicon' export {DeprecatedTooltip as Tooltip, type DeprecatedTooltipProps as TooltipProps} from './components/Tooltip'