Skip to content

Commit

Permalink
Merge branch 'main' into bump-octicons-react
Browse files Browse the repository at this point in the history
  • Loading branch information
broccolinisoup committed May 16, 2023
2 parents a214608 + 8bf4c5a commit 2c7c09a
Show file tree
Hide file tree
Showing 54 changed files with 740 additions and 5,301 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-cows-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Rename component StyledOcticon to Octicon
5 changes: 5 additions & 0 deletions .changeset/two-cycles-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Address ToggleSwitch accessibility feedback
13 changes: 1 addition & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function replacementPlugin(env) {

const sharedPlugins = [
'macros',
'preval',
'dev-expression',
'add-react-displayname',
'babel-plugin-styled-components',
Expand All @@ -22,17 +21,7 @@ module.exports = {
env: {
development: {
presets: makePresets(process.env.BABEL_MODULE || false),
plugins: [
...(process.env.BABEL_MODULE === 'commonjs'
? ['@babel/plugin-transform-modules-commonjs']
: process.env.STORYBOOK
? []
: [
'transform-commonjs', // theme-preval is commonjs and needs to be transformed to esm
]),
...sharedPlugins,
replacementPlugin('development'),
],
plugins: [...sharedPlugins, replacementPlugin('development')],
},
production: {
presets: makePresets(false),
Expand Down
12 changes: 6 additions & 6 deletions codemods/__tests__/removeSystemProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ defineInlineTest(
removeSystemProps,
{},
`
import {Button, StyledOcticon} from '@primer/components'
import {Button, Octicon} from '@primer/components'
import {CheckIcon, ClippyIcon} from '@primer/octicons-react'
const ClipboardCopy = ({value}) => <Button px={2}>
{copied ? (
<StyledOcticon icon={CheckIcon} color="green.5" />
<Octicon icon={CheckIcon} color="green.5" />
) : (
<StyledOcticon icon={ClippyIcon} color="gray.5" />
<Octicon icon={ClippyIcon} color="gray.5" />
)}
</Button>
`.trim(),
`
import {Button, StyledOcticon} from '@primer/components'
import {Button, Octicon} from '@primer/components'
import {CheckIcon, ClippyIcon} from '@primer/octicons-react'
const ClipboardCopy = ({value}) => (
<Button sx={{px: 2}}>
{copied ? (
<StyledOcticon icon={CheckIcon} sx={{color: 'green.5'}} />
<Octicon icon={CheckIcon} sx={{color: 'green.5'}} />
) : (
<StyledOcticon icon={ClippyIcon} sx={{color: 'gray.5'}} />
<Octicon icon={ClippyIcon} sx={{color: 'gray.5'}} />
)}
</Button>
)`.trim(),
Expand Down
2 changes: 1 addition & 1 deletion codemods/removeSystemProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const stylePropsMap = {
SideNav: [...COMMON],
Spinner: [...COMMON],
StateLabel: [...COMMON],
StyledOcticon: [...COMMON],
Octicon: [...COMMON],
SubNav: [...COMMON, ...FLEX],
TabNav: [...COMMON],
TabNavLink: [...COMMON, ...TYPOGRAPHY],
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ActionMenu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ You can choose to have a different _anchor_ for the Menu depending on the applic
Information-dense table optimized for operations across teams
</ActionList.Description>
</ActionList.Item>
<ActionList.Item role="listitem">
<ActionList.Item>
<ActionList.LeadingVisual>
<ProjectIcon />
</ActionList.LeadingVisual>
Expand Down
2 changes: 1 addition & 1 deletion docs/content/Flash.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Flash components with icons inside of them will automatically set the correct co

```jsx live
<Flash variant="success">
<StyledOcticon icon={CheckIcon} />
<Octicon icon={CheckIcon} />
Success!
</Flash>
```
Expand Down
2 changes: 1 addition & 1 deletion docs/content/Header.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ All items directly under the Header component should be a `Header.Item` componen
<Header>
<Header.Item>
<Header.Link href="#" fontSize={2}>
<StyledOcticon icon={MarkGithubIcon} size={32} sx={{mr: 2}} />
<Octicon icon={MarkGithubIcon} size={32} sx={{mr: 2}} />
<span>GitHub</span>
</Header.Link>
</Header.Item>
Expand Down
14 changes: 7 additions & 7 deletions docs/content/StyledOcticon.mdx → docs/content/Octicon.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
description: Use StyledOcticon to render an Octicon as a component.
title: StyledOcticon
description: Use Octicon to render an Octicon as a component.
title: Octicon
status: Alpha
source: https://github.com/primer/react/blob/main/src/StyledOcticon/StyledOcticon.tsx
componentId: styled_octicon
source: https://github.com/primer/react/blob/main/src/Octicon/Octicon.tsx
componentId: octicon
---

import data from '../../src/StyledOcticon/StyledOcticon.docs.json'
import data from '../../src/Octicon/Octicon.docs.json'

## Example

```jsx live
<>
<StyledOcticon icon={CheckIcon} size={32} color="success.fg" sx={{mr: 2}} />
<StyledOcticon icon={XIcon} size={32} color="danger.fg" />
<Octicon icon={CheckIcon} size={32} color="success.fg" sx={{mr: 2}} />
<Octicon icon={XIcon} size={32} color="danger.fg" />
</>
```

Expand Down
20 changes: 10 additions & 10 deletions docs/content/Timeline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Timeline.Item component is used to display items on a vertical timeline, con
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={FlameIcon} />
<Octicon icon={FlameIcon} />
</Timeline.Badge>
<Timeline.Body>
<Link href="#" sx={{fontWeight: 'bold', color: 'fg.default', mr: 1}} muted>
Expand All @@ -41,7 +41,7 @@ The default Timeline.Badge color is dark text on a light grey background.
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={FlameIcon} />
<Octicon icon={FlameIcon} />
</Timeline.Badge>
<Timeline.Body>Default badge color</Timeline.Body>
</Timeline.Item>
Expand All @@ -51,25 +51,25 @@ The default Timeline.Badge color is dark text on a light grey background.
### Adding color to a Badge

To have color variants, use the `bg` prop on the `Timeline.Badge`. If an icon is being used, set the `color` prop
of the child `StyledOcticon` if necessary.
of the child `Octicon` if necessary.

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'danger.emphasis'}}>
<StyledOcticon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
<Octicon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
</Timeline.Badge>
<Timeline.Body>Background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'danger.emphasis'}}>
<StyledOcticon icon={FlameIcon} color="fg.onEmphasis" />
<Octicon icon={FlameIcon} color="fg.onEmphasis" />
</Timeline.Badge>
<Timeline.Body>Background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'danger.emphasis'}}>
<StyledOcticon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
<Octicon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
</Timeline.Badge>
<Timeline.Body>Background used when pull requests are merged</Timeline.Body>
</Timeline.Item>
Expand All @@ -84,13 +84,13 @@ Timeline has a condensed prop that will reduce the vertical padding and remove t
<Timeline>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommitIcon} />
<Octicon icon={GitCommitIcon} />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommitIcon} />
<Octicon icon={GitCommitIcon} />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
Expand All @@ -105,14 +105,14 @@ To create a visual break in the timeline, use Timeline.Break. This adds a horizo
<Timeline>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'danger.emphasis'}}>
<StyledOcticon icon={FlameIcon} color="fg.onEmphasis" />
<Octicon icon={FlameIcon} color="fg.onEmphasis" />
</Timeline.Badge>
<Timeline.Body>Background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Break />
<Timeline.Item>
<Timeline.Badge sx={{bg: 'success.emphasis'}}>
<StyledOcticon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
<Octicon icon={FlameIcon} sx={{color: 'fg.onEmphasis'}} />
</Timeline.Badge>
<Timeline.Body>Background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
Expand Down
6 changes: 3 additions & 3 deletions docs/content/TreeView.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {TreeView} from '@primer/react'
</TreeView.LeadingVisual>
Avatar.tsx
<TreeView.TrailingVisual>
<StyledOcticon icon={DiffAddedIcon} color="success.fg" aria-label="added" />
<Octicon icon={DiffAddedIcon} color="success.fg" aria-label="added" />
</TreeView.TrailingVisual>
</TreeView.Item>
<TreeView.Item id="src/Button.tsx" current>
Expand All @@ -43,7 +43,7 @@ import {TreeView} from '@primer/react'
</TreeView.LeadingVisual>
Button.tsx
<TreeView.TrailingVisual>
<StyledOcticon icon={DiffModifiedIcon} color="attention.fg" aria-label="modified" />
<Octicon icon={DiffModifiedIcon} color="attention.fg" aria-label="modified" />
</TreeView.TrailingVisual>
</TreeView.Item>
</TreeView.SubTree>
Expand All @@ -54,7 +54,7 @@ import {TreeView} from '@primer/react'
</TreeView.LeadingVisual>
package.json
<TreeView.TrailingVisual>
<StyledOcticon icon={DiffModifiedIcon} color="attention.fg" aria-label="modified" />
<Octicon icon={DiffModifiedIcon} color="attention.fg" aria-label="modified" />
</TreeView.TrailingVisual>
</TreeView.Item>
</TreeView>
Expand Down
10 changes: 5 additions & 5 deletions docs/content/deprecated/SideNav.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ Add the `variant='full'` prop to a `SideNav.Link` to spread child elements acros
<Text>With an avatar</Text>
</SideNav.Link>
<SideNav.Link href="#url">
<StyledOcticon sx={{mr: 2}} size={16} icon={ZapIcon} />
<Octicon sx={{mr: 2}} size={16} icon={ZapIcon} />
<Text>With an Octicon</Text>
</SideNav.Link>
<SideNav.Link href="#url" variant="full" selected>
<Text>With a status icon</Text>
<StyledOcticon sx={{mr: 2}} size={16} icon={DotIcon} color="success.fg" />
<Octicon sx={{mr: 2}} size={16} icon={DotIcon} color="success.fg" />
</SideNav.Link>
<SideNav.Link href="#url" variant="full">
<Text>With a label</Text>
Expand Down Expand Up @@ -142,11 +142,11 @@ It can also appear nested, as a sub navigation. Use margin/padding [System Props
```jsx live
<SideNav bordered maxWidth={360}>
<SideNav.Link href="#url">
<StyledOcticon size={16} icon={PersonIcon} />
<Octicon size={16} icon={PersonIcon} />
<Text>Account</Text>
</SideNav.Link>
<SideNav.Link href="#url" selected>
<StyledOcticon mr={2} size={16} icon={SmileyIcon} />
<Octicon mr={2} size={16} icon={SmileyIcon} />
<Text>Profile</Text>
</SideNav.Link>

Expand All @@ -163,7 +163,7 @@ It can also appear nested, as a sub navigation. Use margin/padding [System Props
</SideNav>

<SideNav.Link href="#url">
<StyledOcticon mr={2} size={16} icon={MailIcon} />
<Octicon mr={2} size={16} icon={MailIcon} />
<Text>Emails</Text>
</SideNav.Link>
</SideNav>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@
url: /SplitPageLayout
- title: StateLabel
url: /StateLabel
- title: StyledOcticon
url: /StyledOcticon
- title: Octicon
url: /Octicon
- title: SubNav
url: /SubNav
- title: ToggleSwitch
Expand Down
8 changes: 4 additions & 4 deletions docs/src/component-checklist.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Box, StyledOcticon, Link, Text} from '@primer/react'
import {Box, Octicon, Link, Text} from '@primer/react'
import {H3} from '@primer/gatsby-theme-doctocat/src/components/heading'
import {CheckCircleFillIcon, CircleIcon, SkipIcon} from '@primer/octicons-react'
import React from 'react'
Expand Down Expand Up @@ -88,11 +88,11 @@ Checklist.Item = ({checked, children}) => {
<Box as="li" display="grid" gridTemplateColumns="auto 1fr" gridGap={2} sx={{listStyleType: 'none'}}>
<Box height="24px" display="flex" alignItems="center">
{checked ? (
<StyledOcticon aria-label="Completed" icon={CheckCircleFillIcon} sx={{color: 'success.fg'}} />
<Octicon aria-label="Completed" icon={CheckCircleFillIcon} sx={{color: 'success.fg'}} />
) : checked === null ? (
<StyledOcticon icon={SkipIcon} sx={{color: 'fg.subtle'}} />
<Octicon icon={SkipIcon} sx={{color: 'fg.subtle'}} />
) : (
<StyledOcticon aria-label="To do" icon={CircleIcon} sx={{color: 'fg.subtle'}} />
<Octicon aria-label="To do" icon={CircleIcon} sx={{color: 'fg.subtle'}} />
)}
</Box>
<Text color={checked === null ? 'fg.subtle' : 'fg.default'}>
Expand Down
4 changes: 2 additions & 2 deletions docs/src/component-statuses.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import componentMetadata from '@primer/component-metadata'
import {Link, Label, StyledOcticon} from '@primer/react'
import {Link, Label, Octicon} from '@primer/react'
import {AccessibilityInsetIcon} from '@primer/octicons-react'
import StatusLabel from '@primer/gatsby-theme-doctocat/src/components/status-label'
import Table from '@primer/gatsby-theme-doctocat/src/components/table'
Expand Down Expand Up @@ -79,7 +79,7 @@ export function ComponentStatuses() {
borderColor: 'transparent',
}}
>
<StyledOcticon icon={AccessibilityInsetIcon} sx={{fill: 'done.fg'}} />
<Octicon icon={AccessibilityInsetIcon} sx={{fill: 'done.fg'}} />
Reviewed
</Label>
) : (
Expand Down
5 changes: 5 additions & 0 deletions e2e/components/ToggleSwitch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ test.describe('ToggleSwitch', () => {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},

// the 'default' preview does not associate a label with the button
'button-name': {
enabled: false,
},
},
})
})
Expand Down
Loading

0 comments on commit 2c7c09a

Please sign in to comment.