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

Create @primer/styled-octicons package #417

Merged
merged 30 commits into from May 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b9eaacd
Start styled-octicons package
colebemis Apr 24, 2020
1a0ce68
Attempt to add styled octicons package to workflow
colebemis Apr 24, 2020
cedfc45
Remove next site from styled octicons package
colebemis Apr 24, 2020
44a8bc7
Add package-lock
colebemis Apr 24, 2020
9f56fa6
Add files to package.json
colebemis Apr 24, 2020
52b26a5
Update dependencies
colebemis Apr 24, 2020
a0de56e
Ad types
colebemis Apr 27, 2020
bd0d1dd
Add types for system props
colebemis Apr 27, 2020
7f5b09c
Update tests
colebemis Apr 27, 2020
f670ef5
Remove display prop
colebemis Apr 27, 2020
aca723e
Add tests for system props
colebemis Apr 27, 2020
3751a86
Update ts-tests
colebemis Apr 27, 2020
07a0bc8
Add @types/styled-system as a dependency
colebemis Apr 27, 2020
79962a1
Add name to workflow steps
colebemis Apr 27, 2020
d8dffb8
Start docs for styled-octicons
colebemis Apr 27, 2020
0c5fcfc
Remove prop types
colebemis Apr 27, 2020
dddece5
Update docs
colebemis Apr 29, 2020
ae29ea7
Write icon components into their own file
colebemis May 1, 2020
92d68d5
Fix generated pathname
colebemis May 1, 2020
24cce42
Fix lint error
colebemis May 1, 2020
a1fb469
Bundle individual icons
colebemis May 1, 2020
44c5a6d
Write copy script
colebemis May 1, 2020
ba674af
Update package lock
colebemis May 1, 2020
af9c04b
Add sx prop
colebemis May 1, 2020
ba70d35
Update lib/octicons_styled/script/copy.sh
colebemis May 1, 2020
394a15b
Run copy script after rollup
colebemis May 1, 2020
c36f7e4
Merge branch 'styled-octicons' of github.com:primer/octicons into sty…
colebemis May 1, 2020
7c415e0
Update docs
colebemis May 4, 2020
35511fe
Export Icon and IconProps
colebemis May 4, 2020
df8e278
Merge remote-tracking branch 'origin/v2' into styled-octicons
colebemis May 4, 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
9 changes: 8 additions & 1 deletion .github/workflows/push.yml
Expand Up @@ -107,8 +107,15 @@ jobs:
with:
name: octicons
path: ./lib/build
- uses: ./.github/actions/build_node
- name: Build @primer/octicons-react
uses: ./.github/actions/build_node
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
with:
args: octicons_react
- name: Build @primer/styled-octicons
uses: ./.github/actions/build_node
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
with:
args: octicons_styled
44 changes: 44 additions & 0 deletions docs/content/packages/styled-system.mdx
@@ -0,0 +1,44 @@
---
title: Styled System
status: Experimental
source: 'https://github.com/primer/octicons/tree/v2/lib/octicons_styled'
---

[![npm version](https://img.shields.io/npm/v/@primer/styled-octicons/canary.svg)](https://www.npmjs.org/package/@primer/styled-octicons)

The `@primer/styled-octicons` package wraps icon components from [`@primer/octicons-v2-react`](/packages/react) with [system props](https://primer.style/components/system-props), making them easier to style in projects that use [styled system](https://styled-system.com/)—like [Primer Components](https://primer.style/components).

## Install

```shell
npm install @primer/styled-octicons@canary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we recommend folks to install the canary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until the v2 branch is merged, there won't actually be a @latest version of the package. When the v2 branch is merged, we'll update the docs to remove @canary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

```

## Usage

`@primer/styled-octicons` exports each icons as a named export. This allows you to import only the icons you need:

```jsx
import {AlertIcon} from '@primer/styled-octicons'

export () => (
<AlertIcon color="red.6" mr={2} />
)
```

## System props

All icon components in `@primer/styled-octicons` get `color` and `space` system props as well as the `sx` prop. Read our [System Props](https://primer.style/components/system-props) documentation for a full list of available props.


## Props

In addition to system props, icon components in `@primer/styled-octicons` accept the same props as components in `@primer/octicons-v2-react`:

| Name | Type | Default | Description |
| :- | :- | :-: | :- |
| aria-label | String | | Sets the [`aria-label`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute) attribute of the `<svg>`. If no `aria-label` is defined, `aria-hidden` will be set to `true`. |
| className | String | | Sets the `class` attribute on the `<svg>` |
| size | Number \| `"small"` \| `"medium"` \| `"large"` | `16` | The height of the icon. Width will be scaled proportionally. |
| verticalAlign | `"middle"` \| `"text-bottom"` \| `"text-top"` \| `"top"` \| `"unset"` | `"text-bottom"` | The vertical alignment of the `<svg>` |

2 changes: 2 additions & 0 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Expand Up @@ -11,3 +11,5 @@
url: /packages/javascript
- title: React
url: /packages/react
- title: Styled System
url: /packages/styled-system
1 change: 1 addition & 0 deletions lib/octicons_react/script/build.js
Expand Up @@ -74,6 +74,7 @@ ${icons.map(({name}) => `declare const ${name}: Icon`).join('\n')}

export {
Icon,
IconProps,
${icons.map(({name}) => name).join(',\n ')}
}`
return fse.writeFile(file, code, 'utf8').then(() => {
Expand Down
8 changes: 8 additions & 0 deletions lib/octicons_styled/.babelrc
@@ -0,0 +1,8 @@
{
"presets": ["env", "stage-0", "react"],
"env": {
"production": {
"presets": ["next/babel"]
}
}
}
1 change: 1 addition & 0 deletions lib/octicons_styled/.eslintignore
@@ -0,0 +1 @@
src/__generated__/
14 changes: 14 additions & 0 deletions lib/octicons_styled/.eslintrc.json
@@ -0,0 +1,14 @@
{
"extends": [
"plugin:github/recommended",
"plugin:github/es6",
"plugin:github/react"
],
"rules": {
},
"settings": {
"react": {
"version": "16"
}
}
}
4 changes: 4 additions & 0 deletions lib/octicons_styled/.gitignore
@@ -0,0 +1,4 @@
.cache
.next
dist/
src/__generated__/
9 changes: 9 additions & 0 deletions lib/octicons_styled/.npmignore
@@ -0,0 +1,9 @@
*.config.js
.*.sw?
.*rc
.cache
.eslint*
.gitignore
.next
script
src
1 change: 1 addition & 0 deletions lib/octicons_styled/.nvmrc
@@ -0,0 +1 @@
8
21 changes: 21 additions & 0 deletions lib/octicons_styled/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 GitHub Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 5 additions & 0 deletions lib/octicons_styled/README.md
@@ -0,0 +1,5 @@
# @primer/styled-octicons

[![npm version](https://img.shields.io/npm/v/@primer/styled-octicons.svg)](https://www.npmjs.org/package/@primer/styled-octicons)

See https://primer.style/octicons/packages/styled-system