-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Introduce Icons package #17055
Introduce Icons package #17055
Changes from 12 commits
9fd4170
7d8b773
474dbeb
232abe9
ee0c047
3644144
31a3136
253c2e6
39da62d
9868145
035d851
5f6bfc6
1989eeb
7c4f8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 (2019-08-15) | ||
|
||
- Initial release |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Icons | ||
|
||
WordPress Icons Library. | ||
|
||
## Installation | ||
|
||
Install the module: | ||
|
||
```bash | ||
npm install @wordpress/icons --save | ||
``` | ||
|
||
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._ | ||
|
||
## Usage | ||
|
||
```js | ||
import { __experimentalIcon as Icon, saved } from '@wordpress/icons'; | ||
|
||
<Icon icon={ saved } /> | ||
``` | ||
|
||
## Props | ||
|
||
Name | Type | Default | Description | ||
--- | --- | --- | --- | ||
`size` | `integer` | `24` | Size of icon in pixels. | ||
|
||
|
||
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@wordpress/icons", | ||
"version": "1.0.0", | ||
"description": "WordPress Icons package, based on dashicon.", | ||
"author": "The WordPress Contributors", | ||
"license": "GPL-2.0-or-later", | ||
"keywords": [ | ||
"icons", | ||
"dashicon", | ||
"wordpress" | ||
], | ||
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/icons/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/WordPress/gutenberg.git", | ||
"directory": "packages/icons" | ||
}, | ||
"sideEffects": false, | ||
"bugs": { | ||
"url": "https://github.com/WordPress/gutenberg/issues" | ||
}, | ||
"main": "build/index.js", | ||
"module": "build-module/index.js", | ||
"dependencies": { | ||
"@wordpress/element": "../element", | ||
"@wordpress/primitives": "../primitives" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { cloneElement } from '@wordpress/element'; | ||
|
||
function Icon( { icon, size = 24, ...props } ) { | ||
return cloneElement( icon, { | ||
width: size, | ||
height: size, | ||
...props, | ||
} ); | ||
} | ||
|
||
export default Icon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Icon from '../'; | ||
import saved from '../../library/saved'; | ||
import paragraph from '../../library/paragraph'; | ||
|
||
export default { title: 'Icons/Icon', component: Icon }; | ||
|
||
export const _default = () => { | ||
return ( | ||
<> | ||
<div> | ||
<h2>Dashicons (corrected viewport)</h2> | ||
|
||
<Icon icon={ saved } /> | ||
<Icon icon={ saved } size={ 36 } /> | ||
<Icon icon={ saved } size={ 48 } /> | ||
</div> | ||
<div> | ||
<h2>Material and Other</h2> | ||
|
||
<Icon icon={ paragraph } /> | ||
<Icon icon={ paragraph } size={ 36 } /> | ||
<Icon icon={ paragraph } size={ 48 } /> | ||
</div> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { default as __experimentalIcon } from './icon'; | ||
|
||
export { default as saved } from './library/saved'; | ||
export { default as paragraph } from './library/paragraph'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/primitives'; | ||
|
||
const paragraph = ( | ||
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
<Path d="M11 5v7H9.5C7.6 12 6 10.4 6 8.5S7.6 5 9.5 5H11m8-2H9.5C6.5 3 4 5.5 4 8.5S6.5 14 9.5 14H11v7h2V5h2v16h2V5h2V3z" /> | ||
</SVG> | ||
); | ||
|
||
export default paragraph; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/primitives'; | ||
|
||
const saved = ( | ||
<SVG | ||
aria-hidden | ||
role="img" | ||
focusable="false" | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="-2 -2 24 24" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jasmussen @senadir Since we're just adding dashicons to this new package manually as we refactor the Gutenberg icons, I think instead of trying to fix the 20/24 bug programmatically, we should just apply this viewBox to the dashicons SVG as we add them to the package. |
||
> | ||
<Path d="M15.3 5.3l-6.8 6.8-2.8-2.8-1.4 1.4 4.2 4.2 8.2-8.2" /> | ||
</SVG> | ||
); | ||
|
||
export default saved; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be
## Master
:)