From 46fcca71fb972334710a97d42338f9e4743a148d Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Wed, 22 Jan 2020 09:41:44 +0100 Subject: [PATCH] Introduce the Icons package (#17055) --- docs/manifest-devhub.json | 6 ++ package-lock.json | 22 +++++ package.json | 1 + packages/base-styles/_z-index.scss | 2 +- .../test/__snapshots__/control.js.snap | 7 +- packages/block-library/package.json | 1 + packages/block-library/src/paragraph/icon.js | 8 -- packages/block-library/src/paragraph/index.js | 2 +- packages/components/package.json | 1 + .../src/circular-option-picker/index.js | 8 +- .../src/circular-option-picker/style.scss | 8 +- .../test/__snapshots__/index.js.snap | 32 ++++--- .../src/custom-select-control/index.js | 8 +- packages/editor/package.json | 1 + .../src/components/post-saved-state/index.js | 3 +- .../components/post-saved-state/style.scss | 5 +- .../components/post-saved-state/test/index.js | 2 +- packages/icons/.npmrc | 1 + packages/icons/CHANGELOG.md | 3 + packages/icons/README.md | 30 ++++++ packages/icons/package.json | 31 +++++++ packages/icons/src/icon/index.js | 14 +++ packages/icons/src/icon/stories/index.js | 29 ++++++ packages/icons/src/index.js | 4 + packages/icons/src/library/check.js | 19 ++++ packages/icons/src/library/paragraph.js | 12 +++ storybook/main.js | 1 + storybook/test/__snapshots__/index.js.snap | 93 +++++++++++++++++++ 28 files changed, 317 insertions(+), 37 deletions(-) delete mode 100644 packages/block-library/src/paragraph/icon.js create mode 100644 packages/icons/.npmrc create mode 100644 packages/icons/CHANGELOG.md create mode 100644 packages/icons/README.md create mode 100644 packages/icons/package.json create mode 100644 packages/icons/src/icon/index.js create mode 100644 packages/icons/src/icon/stories/index.js create mode 100644 packages/icons/src/index.js create mode 100644 packages/icons/src/library/check.js create mode 100644 packages/icons/src/library/paragraph.js 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`] = ` /> - + + + } > - +