diff --git a/docs/manifest-devhub.json b/docs/manifest-devhub.json index 34e54832509a7..a2960d6d7110c 100644 --- a/docs/manifest-devhub.json +++ b/docs/manifest-devhub.json @@ -1325,6 +1325,12 @@ "markdown_source": "../packages/i18n/README.md", "parent": "packages" }, + { + "title": "@wordpress/icons", + "slug": "packages-icons", + "markdown_source": "../packages/icons/README.md", + "parent": "packages" + }, { "title": "@wordpress/is-shallow-equal", "slug": "packages-is-shallow-equal", diff --git a/package-lock.json b/package-lock.json index f53ef6ab607ea..bd8ddca28b333 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9550,6 +9550,7 @@ "@wordpress/element": "file:packages/element", "@wordpress/escape-html": "file:packages/escape-html", "@wordpress/i18n": "file:packages/i18n", + "@wordpress/icons": "file:packages/icons", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", "@wordpress/rich-text": "file:packages/rich-text", @@ -9622,6 +9623,7 @@ "@wordpress/element": "file:packages/element", "@wordpress/hooks": "file:packages/hooks", "@wordpress/i18n": "file:packages/i18n", + "@wordpress/icons": "file:packages/icons", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", "@wordpress/primitives": "file:packages/primitives", @@ -9870,6 +9872,7 @@ "@wordpress/hooks": "file:packages/hooks", "@wordpress/html-entities": "file:packages/html-entities", "@wordpress/i18n": "file:packages/i18n", + "@wordpress/icons": "file:packages/icons", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keyboard-shortcuts": "file:packages/keyboard-shortcuts", "@wordpress/keycodes": "file:packages/keycodes", @@ -9972,6 +9975,25 @@ "tannin": "^1.1.0" } }, + "@wordpress/icons": { + "version": "file:packages/icons", + "requires": { + "@wordpress/element": "file:packages/element", + "@wordpress/primitives": "file:packages/primitives" + }, + "dependencies": { + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "pascalcase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-1.0.0.tgz", + "integrity": "sha512-BSExi0rRnCHReJys6NocaK+cfTXNinAegfWBvr0JD3hiaEG7Nuc7r0CIdOJunXrs8gU/sbHQ9dxVAtiVQisjmg==" + } + } + }, "@wordpress/is-shallow-equal": { "version": "file:packages/is-shallow-equal", "requires": { diff --git a/package.json b/package.json index 9ac0e8b7aa25d..1b19266fb01ab 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@wordpress/hooks": "file:packages/hooks", "@wordpress/html-entities": "file:packages/html-entities", "@wordpress/i18n": "file:packages/i18n", + "@wordpress/icons": "file:packages/icons", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keyboard-shortcuts": "file:packages/keyboard-shortcuts", "@wordpress/keycodes": "file:packages/keycodes", diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss index f9c23e29b6062..c9c369d051dea 100644 --- a/packages/base-styles/_z-index.scss +++ b/packages/base-styles/_z-index.scss @@ -125,7 +125,7 @@ $z-layers: ( ".components-circular-option-picker__option.is-pressed": 1, // Needs to be higher than .components-circular-option-picker__option.is-pressed. - ".components-circular-option-picker__option.is-pressed + .dashicons-saved": 2 + ".components-circular-option-picker__option.is-pressed + svg": 2 ); @function z-index( $key ) { diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap index 22ff1e94352ba..bb4c84c0d9f96 100644 --- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap +++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap @@ -49,12 +49,11 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` /> -); diff --git a/packages/block-library/src/paragraph/index.js b/packages/block-library/src/paragraph/index.js index 34c6169455f9d..d95174b9acbea 100644 --- a/packages/block-library/src/paragraph/index.js +++ b/packages/block-library/src/paragraph/index.js @@ -7,13 +7,13 @@ import { isEmpty } from 'lodash'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; +import { paragraph as icon } from '@wordpress/icons'; /** * Internal dependencies */ import deprecated from './deprecated'; import edit from './edit'; -import icon from './icon'; import metadata from './block.json'; import save from './save'; import transforms from './transforms'; diff --git a/packages/components/package.json b/packages/components/package.json index 100a2b899fce8..0152ada85794c 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -36,6 +36,7 @@ "@wordpress/element": "file:../element", "@wordpress/hooks": "file:../hooks", "@wordpress/i18n": "file:../i18n", + "@wordpress/icons": "file:../icons", "@wordpress/is-shallow-equal": "file:../is-shallow-equal", "@wordpress/keycodes": "file:../keycodes", "@wordpress/primitives": "file:../primitives", diff --git a/packages/components/src/circular-option-picker/index.js b/packages/components/src/circular-option-picker/index.js index 17f1b7ce930b8..92bd47b051592 100644 --- a/packages/components/src/circular-option-picker/index.js +++ b/packages/components/src/circular-option-picker/index.js @@ -3,13 +3,17 @@ */ import classnames from 'classnames'; +/** + * WordPress dependencies + */ +import { __experimentalIcon as Icon, check } from '@wordpress/icons'; + /** * Internal dependencies */ import Button from '../button'; import Dropdown from '../dropdown'; import Tooltip from '../tooltip'; -import Dashicon from '../dashicon'; function Option( { className, @@ -33,7 +37,7 @@ function Option( { ( { optionButton } ) : optionButton } - { isSelected && } + { isSelected && } ); } diff --git a/packages/components/src/circular-option-picker/style.scss b/packages/components/src/circular-option-picker/style.scss index 659dbbe78df44..a76a852559f7b 100644 --- a/packages/components/src/circular-option-picker/style.scss +++ b/packages/components/src/circular-option-picker/style.scss @@ -72,12 +72,12 @@ $color-palette-circle-spacing: 12px; position: relative; z-index: z-index(".components-circular-option-picker__option.is-pressed"); - & + .dashicons-saved { + & + svg { position: absolute; - left: 4px; - top: 4px; + left: 2px; + top: 2px; border-radius: 50%; - z-index: z-index(".components-circular-option-picker__option.is-pressed + .dashicons-saved"); + z-index: z-index(".components-circular-option-picker__option.is-pressed + svg"); background: $white; pointer-events: none; } diff --git a/packages/components/src/color-palette/test/__snapshots__/index.js.snap b/packages/components/src/color-palette/test/__snapshots__/index.js.snap index eb5ddef6b1986..1813d62aaccd8 100644 --- a/packages/components/src/color-palette/test/__snapshots__/index.js.snap +++ b/packages/components/src/color-palette/test/__snapshots__/index.js.snap @@ -318,27 +318,37 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = ` /> - + + + } > - + { item === selectedItem && ( - ) } diff --git a/packages/editor/package.json b/packages/editor/package.json index dc56e097afb33..4041abb1cf0c8 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -39,6 +39,7 @@ "@wordpress/hooks": "file:../hooks", "@wordpress/html-entities": "file:../html-entities", "@wordpress/i18n": "file:../i18n", + "@wordpress/icons": "file:../icons", "@wordpress/is-shallow-equal": "file:../is-shallow-equal", "@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts", "@wordpress/keycodes": "file:../keycodes", diff --git a/packages/editor/src/components/post-saved-state/index.js b/packages/editor/src/components/post-saved-state/index.js index fcabe37c1f230..b6dbf6792112c 100644 --- a/packages/editor/src/components/post-saved-state/index.js +++ b/packages/editor/src/components/post-saved-state/index.js @@ -14,6 +14,7 @@ import { withSelect, withDispatch } from '@wordpress/data'; import { displayShortcut } from '@wordpress/keycodes'; import { withSafeTimeout, compose } from '@wordpress/compose'; import { withViewportMatch } from '@wordpress/viewport'; +import { __experimentalIcon as Icon, check } from '@wordpress/icons'; /** * Internal dependencies @@ -88,7 +89,7 @@ export class PostSavedState extends Component { if ( forceSavedMessage || ( ! isNew && ! isDirty ) ) { return ( - + { __( 'Saved' ) } ); diff --git a/packages/editor/src/components/post-saved-state/style.scss b/packages/editor/src/components/post-saved-state/style.scss index 49f546627651a..7840f2816140a 100644 --- a/packages/editor/src/components/post-saved-state/style.scss +++ b/packages/editor/src/components/post-saved-state/style.scss @@ -7,10 +7,11 @@ overflow: hidden; white-space: nowrap; - .dashicon { + svg { display: inline-block; flex: 0 0 auto; - margin-right: $grid-size; + margin-right: $grid-size-small; + fill: currentColor; } @include break-small() { diff --git a/packages/editor/src/components/post-saved-state/test/index.js b/packages/editor/src/components/post-saved-state/test/index.js index 38b094c642321..8466002b8b614 100644 --- a/packages/editor/src/components/post-saved-state/test/index.js +++ b/packages/editor/src/components/post-saved-state/test/index.js @@ -48,7 +48,7 @@ describe( 'PostSavedState', () => { isSaveable={ true } /> ); - expect( wrapper.childAt( 0 ).name() ).toBe( 'Dashicon' ); + expect( wrapper.childAt( 0 ).name() ).toBe( 'Icon' ); expect( wrapper.childAt( 1 ).text() ).toBe( 'Saved' ); } ); diff --git a/packages/icons/.npmrc b/packages/icons/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/icons/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/icons/CHANGELOG.md b/packages/icons/CHANGELOG.md new file mode 100644 index 0000000000000..3a94f4422ce9b --- /dev/null +++ b/packages/icons/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 (2019-08-15) + +- Initial release diff --git a/packages/icons/README.md b/packages/icons/README.md new file mode 100644 index 0000000000000..9f03b4ee89563 --- /dev/null +++ b/packages/icons/README.md @@ -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, check } from '@wordpress/icons'; + + +``` + +## Props + +Name | Type | Default | Description +--- | --- | --- | --- +`size` | `integer` | `24` | Size of icon in pixels. + + + diff --git a/packages/icons/package.json b/packages/icons/package.json new file mode 100644 index 0000000000000..412c3daa9e87d --- /dev/null +++ b/packages/icons/package.json @@ -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" + } +} diff --git a/packages/icons/src/icon/index.js b/packages/icons/src/icon/index.js new file mode 100644 index 0000000000000..eb196b9d05b6d --- /dev/null +++ b/packages/icons/src/icon/index.js @@ -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; diff --git a/packages/icons/src/icon/stories/index.js b/packages/icons/src/icon/stories/index.js new file mode 100644 index 0000000000000..a2a63b0e3ec49 --- /dev/null +++ b/packages/icons/src/icon/stories/index.js @@ -0,0 +1,29 @@ +/** + * Internal dependencies + */ +import Icon from '../'; +import check from '../../library/check'; +import paragraph from '../../library/paragraph'; + +export default { title: 'Icons/Icon', component: Icon }; + +export const _default = () => { + return ( + <> + + Dashicons (corrected viewport) + + + + + + + Material and Other + + + + + + > + ); +}; diff --git a/packages/icons/src/index.js b/packages/icons/src/index.js new file mode 100644 index 0000000000000..b3b5316dc9a05 --- /dev/null +++ b/packages/icons/src/index.js @@ -0,0 +1,4 @@ +export { default as __experimentalIcon } from './icon'; + +export { default as check } from './library/check'; +export { default as paragraph } from './library/paragraph'; diff --git a/packages/icons/src/library/check.js b/packages/icons/src/library/check.js new file mode 100644 index 0000000000000..165318e842117 --- /dev/null +++ b/packages/icons/src/library/check.js @@ -0,0 +1,19 @@ +/** + * WordPress dependencies + */ +import { SVG, Path } from '@wordpress/primitives'; + +const saved = ( + + + +); + +export default saved; + diff --git a/packages/icons/src/library/paragraph.js b/packages/icons/src/library/paragraph.js new file mode 100644 index 0000000000000..c5bc4042b422b --- /dev/null +++ b/packages/icons/src/library/paragraph.js @@ -0,0 +1,12 @@ +/** + * WordPress dependencies + */ +import { SVG, Path } from '@wordpress/primitives'; + +const paragraph = ( + + + +); + +export default paragraph; diff --git a/storybook/main.js b/storybook/main.js index 99c4c5290dff8..41417bd1e907e 100644 --- a/storybook/main.js +++ b/storybook/main.js @@ -1,6 +1,7 @@ const stories = [ process.env.NODE_ENV !== 'test' && './stories/**/*.(js|mdx)', '../packages/components/src/**/stories/*.js', + '../packages/icons/src/**/stories/*.js', ].filter( Boolean ); module.exports = { diff --git a/storybook/test/__snapshots__/index.js.snap b/storybook/test/__snapshots__/index.js.snap index 8dfddc4bb32cd..b2f61d491bb3e 100644 --- a/storybook/test/__snapshots__/index.js.snap +++ b/storybook/test/__snapshots__/index.js.snap @@ -5697,3 +5697,96 @@ Array [ , ] `; + +exports[`Storyshots Icons/Icon Default 1`] = ` +Array [ + + + Dashicons (corrected viewport) + + + + + + + + + + + , + + + Material and Other + + + + + + + + + + + , +] +`;