Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octicons v2 #774

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c39f1a6
change version
Apr 22, 2020
c8c2f3c
update imports
Apr 22, 2020
182f3a6
refactor CircleOcticon
Apr 22, 2020
28cf692
Refactor Dialog
Apr 22, 2020
35e8e4b
refactor StateLabel
Apr 22, 2020
3f381bf
refactor StyledOcticon (temporary) just renders a span now
Apr 22, 2020
6df211c
Refactor SelectMenu.Item
Apr 22, 2020
5a2ac5c
add Icon suffix
Apr 22, 2020
9a07f00
Update yarn.lock
Apr 22, 2020
c3e3ceb
lint
Apr 22, 2020
24251ab
Update StyledOcticon.js
Apr 22, 2020
7dd72af
update snaps
Apr 22, 2020
56d3535
remove missing icons
Apr 22, 2020
a920f10
lint fix
Apr 22, 2020
f3ad7e2
Use @primer/styled-octicons package
colebemis May 11, 2020
c10093c
Remove StyledOcticon
colebemis May 11, 2020
15c7e84
Update StateLabel snapshot
colebemis May 11, 2020
5cb65ac
Fix import in CircleOcticon test
colebemis May 11, 2020
3614807
Merge remote-tracking branch 'origin/master' into octicons-v2
colebemis May 11, 2020
d2b4484
Update snapshots
colebemis May 11, 2020
33d8fa5
Update shadowed components
colebemis May 11, 2020
b6b73ba
Use styled-octicons in playroom
colebemis May 11, 2020
e4ee962
Update CircleBadge
colebemis May 11, 2020
9dd119c
Merge branch 'master' into octicons-v2
colebemis May 18, 2020
e9e1417
Update doctocat version
colebemis May 18, 2020
cc94ef5
Merge branch 'octicons-v2' of github.com:primer/components into octic…
colebemis May 18, 2020
5bcf717
Remove @primer/octicons-v2-react
colebemis May 18, 2020
ab0498a
Update toImplementSxBehavior matcher to be more reliable
BinaryMuse May 19, 2020
b5a837b
Re-enable sx behavior test for StateLabel
BinaryMuse May 19, 2020
2e3cc24
Remove getComputedStyles import
colebemis May 20, 2020
bf61c52
Merge branch 'master' into octicons-v2
Jun 24, 2020
7ba76f1
Merge branch 'octicons-v2' of github.com:primer/components into octic…
Jun 24, 2020
b561581
make a peer dep
Jun 24, 2020
53f80b5
update docs
Jun 24, 2020
947bd4e
Update getting-started.md
Jun 24, 2020
3a77ac0
update tests
Jun 24, 2020
859f1b0
Merge branch 'major' into octicons-v2
Jun 24, 2020
ca88cb8
Merge branch 'major' into octicons-v2
Jun 24, 2020
cc5f70b
Update CircleOcticon.js
Jun 24, 2020
1d6450c
update tests
Jun 24, 2020
530937b
pass in theme where necessary
Jun 24, 2020
2d6d29b
Update TextInput.js
Jun 24, 2020
1256c64
add missing CircleBadge.Icon types
Jun 24, 2020
d057d22
lint
Jun 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/CircleBadge.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Use CircleBadge to visually connect logos of third party services like in market

```jsx live
<CircleBadge>
<CircleBadge.Icon icon={Zap} />
<CircleBadge.Icon icon={CheckIcon} />
</CircleBadge>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/content/CircleOcticon.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CircleOcticon renders any Octicon with a circle background. CircleOcticons are m
## Default example

```jsx live
<CircleOcticon icon={Check} size={32} bg="green.5" color="white"/>
<CircleOcticon icon={CheckIcon} size={32} bg="green.5" color="white"/>
```

## System props
Expand Down
2 changes: 1 addition & 1 deletion docs/content/Dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can also pass any non-text content into the header:
<Button onClick={() => setIsOpen(true)}>Open</Button>
<Dialog isOpen={isOpen} onDismiss={() => setIsOpen(false)}>
<Dialog.Header>
<Octicon icon={Zap} />
<AlertIcon />
</Dialog.Header>
<Box p={3}>
<Text fontFamily="sans-serif">Some content</Text>
Expand Down
2 changes: 1 addition & 1 deletion docs/content/FilteredSearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The FilteredSearch component helps style a Dropdown and a TextInput side-by-side
<Dropdown.Item>Item 3</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
<TextInput icon={Search} />
<TextInput icon={SearchIcon} />
</FilteredSearch>
```

Expand Down
10 changes: 5 additions & 5 deletions docs/content/Flash.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Flash components with icons inside of them will automatically set the correct co

```jsx live
<Flash variant="success">
<StyledOcticon icon={Check}/>
<CheckIcon />
Success!
</Flash>
```
Expand All @@ -30,7 +30,7 @@ Flash components get `COMMON` system props. Read our [System Props](/system-prop

## Component props

| Name | Type | Default | Description |
| :- | :- | :-: | :- |
| full | Boolean | | Creates a full width Flash component|
| variant | String | default | Can be one of `default`, `success`, `warning`, or `danger` - sets the background color and border of the Flash component |
| Name | Type | Default | Description |
| :------ | :------ | :-----: | :----------------------------------------------------------------------------------------------------------------------- |
| full | Boolean | | Creates a full width Flash component |
| variant | String | default | Can be one of `default`, `success`, `warning`, or `danger` - sets the background color and border of the Flash component |
54 changes: 27 additions & 27 deletions docs/content/SideNav.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,29 @@ Add the `variant='full'` prop to a `SideNav.Link` to spread child elements acros
<Text>Text Only</Text>
</SideNav.Link>
<SideNav.Link href="#url">
<Avatar
size={16}
mr={2}
src="https://avatars.githubusercontent.com/hubot?s=32"
/>
<Avatar size={16} mr={2} src="https://avatars.githubusercontent.com/hubot?s=32" />
<Text>With an avatar</Text>
</SideNav.Link>
<SideNav.Link href="#url">
<StyledOcticon mr={2} size={16} icon={Zap} />
<HomeIcon mr={2} />
<Text>With an Octicon</Text>
</SideNav.Link>
<SideNav.Link href="#url" variant="full" selected>
<Text>With a status icon</Text>
<StyledOcticon mr={2} size={16} icon={PrimitiveDot} color="green.5" />
<DotFillIcon color="green.5" />
</SideNav.Link>
<SideNav.Link href="#url" variant="full">
<Text>With a label</Text>
<Label bg='blue.5'>label</Label>
<Label bg="blue.5">label</Label>
</SideNav.Link>
<SideNav.Link href="#url" variant="full">
<Text>With a counter</Text>
<CounterLabel>16</CounterLabel>
</SideNav.Link>
<SideNav.Link href="#url">
<Heading as="h5" fontSize={1}>A heading</Heading>
<Heading as="h5" fontSize={1}>
A heading
</Heading>
<Text>and some more content</Text>
</SideNav.Link>
</SideNav>
Expand All @@ -70,9 +68,11 @@ Add the `variant='full'` prop to a `SideNav.Link` to spread child elements acros
Add the `variant="lightweight"` prop to `SideNav` to render an alternative, more lightweight version that has items with no borders and are more condensed.

```jsx live
<BorderBox p={3} backgroundColor='gray.0' maxWidth={360}>
<BorderBox p={3} backgroundColor="gray.0" maxWidth={360}>
<BorderBox borderWidth={0} borderBottomWidth={1} borderRadius={0} mb={2} pb={1}>
<Heading as="h5" fontSize={1} color="gray.7">Menu</Heading>
<Heading as="h5" fontSize={1} color="gray.7">
Menu
</Heading>
</BorderBox>
<SideNav variant="lightweight">
<SideNav.Link href="#url">
Expand All @@ -96,11 +96,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 mr={2} size={16} icon={Person} />
<PersonIcon mr={2} />
<Text>Account</Text>
</SideNav.Link>
<SideNav.Link href="#url" selected>
<StyledOcticon mr={2} size={16} icon={Octoface} />
<FlameIcon mr={2} />
<Text>Profile</Text>
</SideNav.Link>

Expand All @@ -117,7 +117,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={Mail} />
<MailIcon mr={2} />
<Text>Emails</Text>
</SideNav.Link>
</SideNav>
Expand All @@ -139,19 +139,19 @@ If using React Router, you can use the `as` prop to render the element as a `Nav

### SideNav

| Name | Type | Default | Description |
| :- | :- | :-: | :- |
| as | String | 'nav' | Sets the HTML tag for the component. |
| bordered | Boolean | false | Renders the component with a border. |
| variant | String | 'normal' | Set to `lightweight` to render [in a lightweight style](#lightweight-variant). |
| Name | Type | Default | Description |
| :------- | :------ | :------: | :----------------------------------------------------------------------------- |
| as | String | 'nav' | Sets the HTML tag for the component. |
| bordered | Boolean | false | Renders the component with a border. |
| variant | String | 'normal' | Set to `lightweight` to render [in a lightweight style](#lightweight-variant). |

### SideNav.Link

| Name | Type | Default | Description |
| :- | :- | :-: | :- |
| as | String | 'a' | Sets the HTML tag for the component. |
| href | String | | URL to be used for the Link |
| muted | Boolean | false | Uses light gray for Link color, and blue on hover |
| selected | Boolean | false | Sets the link as selected, giving it a different style and setting the `aria-current` attribute. |
| underline | Boolean | false | Adds underline to the Link |
| variant | String | 'normal' | Set to `full` to render [a full variant](#full-variant), suitable for including icons and labels. |
| Name | Type | Default | Description |
| :-------- | :------ | :------: | :------------------------------------------------------------------------------------------------ |
| as | String | 'a' | Sets the HTML tag for the component. |
| href | String | | URL to be used for the Link |
| muted | Boolean | false | Uses light gray for Link color, and blue on hover |
| selected | Boolean | false | Sets the link as selected, giving it a different style and setting the `aria-current` attribute. |
| underline | Boolean | false | Adds underline to the Link |
| variant | String | 'normal' | Set to `full` to render [a full variant](#full-variant), suitable for including icons and labels. |
28 changes: 0 additions & 28 deletions docs/content/StyledOcticon.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/content/SubNav.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This ensures that the NavLink gets `activeClassName='selected'`
<SubNav.Link href="#support">Support</SubNav.Link>
</SubNav.Links>

<TextInput type="search" icon={Search} width={320} />
<TextInput type="search" icon={SearchIcon} width={320} />
</SubNav>
```

Expand All @@ -59,7 +59,7 @@ This ensures that the NavLink gets `activeClassName='selected'`
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
<TextInput type="search" icon={Search} width={320} />
<TextInput type="search" icon={SearchIcon} width={320} />
</FilteredSearch>
<SubNav.Links>
<SubNav.Link href="#home" selected>
Expand Down
2 changes: 1 addition & 1 deletion docs/content/TextInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TextInput is a form component to add default styling to the native text input.
```jsx live
<TextInput aria-label="Zipcode" name="zipcode" placeholder="Zipcode" autoComplete="postal-code" />

<TextInput ml={4} icon={Search} aria-label="Zipcode" name="zipcode" placeholder="Find user" autoComplete="postal-code" />
<TextInput ml={4} icon={SearchIcon} aria-label="Zipcode" name="zipcode" placeholder="Find user" autoComplete="postal-code" />
```

## System props
Expand Down
23 changes: 11 additions & 12 deletions docs/content/Timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Timeline.Item component is used to display items on a vertical timeline, con
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={Flame} />
<FlameIcon />
</Timeline.Badge>
<Timeline.Body>
<Link href="#" fontWeight="bold" color="gray.8" mr={1} muted>
Expand All @@ -35,7 +35,7 @@ The default Timeline.Badge color is dark text on a light grey background.
<Timeline>
<Timeline.Item>
<Timeline.Badge>
<StyledOcticon icon={Flame} />
<FlameIcon />
</Timeline.Badge>
<Timeline.Body>Default badge color</Timeline.Body>
</Timeline.Item>
Expand All @@ -44,32 +44,31 @@ 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.
To have color variants, use the `bg` prop on the `Timeline.Badge`. If an icon is being used, set the `color` prop of the icon if necessary.

```jsx live
<Timeline>
<Timeline.Item>
<Timeline.Badge bg="red.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Red background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="green.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Green background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="purple.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Purple background used when pull requests are merged</Timeline.Body>
</Timeline.Item>
<Timeline.Item>
<Timeline.Badge bg="blue.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Blue background to indicate new events below</Timeline.Body>
</Timeline.Item>
Expand All @@ -84,13 +83,13 @@ Timeline has a condensed prop that will reduce the vertical padding and remove t
<Timeline>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommit} />
<GitCommitIcon />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
<Timeline.Item condensed>
<Timeline.Badge>
<StyledOcticon icon={GitCommit} />
<GitCommitIcon />
</Timeline.Badge>
<Timeline.Body>This is the message of a condensed TimelineItem</Timeline.Body>
</Timeline.Item>
Expand All @@ -105,14 +104,14 @@ To create a visual break in the timeline, use Timeline.Break. This adds a horizo
<Timeline>
<Timeline.Item>
<Timeline.Badge bg="red.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Red background used when closed events occur</Timeline.Body>
</Timeline.Item>
<Timeline.Break />
<Timeline.Item>
<Timeline.Badge bg="green.5">
<StyledOcticon icon={Flame} color="white" />
<FlameIcon color="white" />
</Timeline.Badge>
<Timeline.Body>Green background when opened or passed events occur</Timeline.Body>
</Timeline.Item>
Expand Down
20 changes: 18 additions & 2 deletions docs/content/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ To get started using Primer React, install the package and its peer dependencies

```bash
# with npm
npm install @primer/components react react-dom styled-components
npm install @primer/components react react-dom styled-components @primer/styled-octicons

# with yarn
yarn add @primer/components react react-dom styled-components
yarn add @primer/components react react-dom styled-components @primer/styled-octicons
```

You can now import Primer React from the main package module:
Expand Down Expand Up @@ -49,6 +49,22 @@ Primer React requires the following libraries to be installed along with it:
- `styled-components` at version 4.0.0 or higher
- `react` at versions 16.8.0 or higher
- `react-dom` at versions 16.8.0 or higher
- `@primer/styled-octicons` at versions 10.0.0 or higher

### Using Octicons with Primer React Components
We use the `@primer/styled-octicons` package for Octicons in the Primer React Components library.

In order to avoid version mismatches, `@primer/styled-octicons` is set as a peer dependency. This allows you to decide which version of `@primer/styled-octicons` you'd like to use in your project and makes sure that any Octicons used in other parts of your application match the icons used in Primer React Components.

As mentioned in the previous section on [Peer dependencies](#Peer-dependencies), you'll need to install `@primer/styled-octicons` before getting started with Primer React Components, regardless of whether or not you are using `@primer/styled-octicons` directly. `@primer/styled-octicons` and `@primer/components` are both tree-shaking friendly, so you shouldn't need to worry about dependency bloat.

You can reference the [`@primer/styled-octicons documentation](https://primer.style/octicons/packages/styled-system) for more detail on how to use these components, but in general the `@primer/styled-octicons` components work similar any Primer React component:

```jsx live
<AlertIcon color="red.6" mr={2} />
```

`@primer/styled-octicons` components have access to all [`COMMON`](https://primer.style/components/system-props#system-prop-categories) system props as well as the [`sx`](https://primer.style/components/overriding-styles) prop.

## BaseStyles

Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"node": ">= 10.x"
},
"dependencies": {
"@primer/gatsby-theme-doctocat": "^0.20.0",
"@primer/octicons-react": "^9.2.0",
"@primer/gatsby-theme-doctocat": "0.21.0",
"@primer/styled-octicons": "^10.0.0",
"@styled-system/prop-types": "^5.1.0",
"@styled-system/theme-get": "^5.1.0",
"gatsby": "^2.17.0",
Expand Down
8 changes: 4 additions & 4 deletions docs/src/@primer/gatsby-theme-doctocat/components/layout.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {BorderBox, Box, Flex, Grid, Heading, Position, Text, Details, StyledOcticon} from '@primer/components'
import {ChevronDown, ChevronRight} from '@primer/octicons-react'
import React from 'react'
import {BorderBox, Box, Details, Flex, Grid, Heading, Position, Text} from '@primer/components'
import Head from '@primer/gatsby-theme-doctocat/src/components/head'
import Header, {HEADER_HEIGHT} from '@primer/gatsby-theme-doctocat/src/components/header'
import PageFooter from '@primer/gatsby-theme-doctocat/src/components/page-footer'
import Sidebar from '@primer/gatsby-theme-doctocat/src/components/sidebar'
import SourceLink from '@primer/gatsby-theme-doctocat/src/components/source-link'
import StatusLabel from '@primer/gatsby-theme-doctocat/src/components/status-label'
import TableOfContents from '@primer/gatsby-theme-doctocat/src/components/table-of-contents'
import {ChevronDownIcon, ChevronRightIcon} from '@primer/styled-octicons'
import React from 'react'

function Layout({children, pageContext}) {
const {title, description, status, source, additionalContributors = []} = pageContext.frontmatter
Expand Down Expand Up @@ -62,7 +62,7 @@ function Layout({children, pageContext}) {
{({open}) => (
<>
<Text as="summary" fontWeight="bold">
<StyledOcticon icon={open ? ChevronDown : ChevronRight} mr={2} />
{open ? <ChevronDownIcon mr={2} /> : <ChevronRightIcon mr={2} />}
Table of contents
</Text>
<Box pt={1}>
Expand Down