From 2c6947356fa309a5ae82df799c364b3c8fcef897 Mon Sep 17 00:00:00 2001 From: andrei draganescu Date: Thu, 30 Apr 2020 14:13:13 +0300 Subject: [PATCH] Block Library: enhance the author block (#19894) * revert bad merge * removed author storage we also set post author on change from the block itself. * linting * use sizes to label avatar size this aloows us to use the sizes as the API serves them * adds some review suggestions props @ockham * removes null coalescing operator --- packages/block-editor/README.md | 4 + .../components/color-style-selector/index.js | 86 ++++++ packages/block-editor/src/components/index.js | 1 + packages/block-library/src/editor.scss | 1 + .../block-library/src/post-author/block.json | 31 +- .../block-library/src/post-author/edit.js | 264 ++++++++++++++++-- .../block-library/src/post-author/editor.scss | 34 +++ .../block-library/src/post-author/icon.js | 10 + .../block-library/src/post-author/index.js | 2 + .../block-library/src/post-author/index.php | 126 ++++++++- .../block-library/src/post-author/style.scss | 31 ++ packages/block-library/src/style.scss | 1 + 12 files changed, 565 insertions(+), 26 deletions(-) create mode 100644 packages/block-editor/src/components/color-style-selector/index.js create mode 100644 packages/block-library/src/post-author/editor.scss create mode 100644 packages/block-library/src/post-author/icon.js create mode 100644 packages/block-library/src/post-author/style.scss diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index 4c9673524d397..48f4fad4bdff6 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -93,6 +93,10 @@ _Returns_ - `WPElement`: Block Breadcrumb. +# **BlockColorsStyleSelector** + +Undocumented declaration. + # **BlockContextProvider** Component which merges passed value with current consumed block context. diff --git a/packages/block-editor/src/components/color-style-selector/index.js b/packages/block-editor/src/components/color-style-selector/index.js new file mode 100644 index 0000000000000..688f614b03058 --- /dev/null +++ b/packages/block-editor/src/components/color-style-selector/index.js @@ -0,0 +1,86 @@ +/** + * WordPress dependencies + */ +import { + Button, + Dropdown, + ToolbarGroup, + SVG, + Path, +} from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; +import { DOWN } from '@wordpress/keycodes'; + +const ColorSelectorSVGIcon = () => ( + + + +); + +/** + * Color Selector Icon component. + * + * @param {Object} colorControlProps colorControl properties. + * @return {*} React Icon component. + */ +const ColorSelectorIcon = ( { style, className } ) => { + return ( +
+
+ +
+
+ ); +}; + +/** + * Renders the Colors Selector Toolbar with the icon button. + * + * @param {Object} colorControlProps colorControl properties. + * @return {*} React toggle button component. + */ +const renderToggleComponent = ( { TextColor, BackgroundColor } ) => ( { + onToggle, + isOpen, +} ) => { + const openOnArrowDown = ( event ) => { + if ( ! isOpen && event.keyCode === DOWN ) { + event.preventDefault(); + event.stopPropagation(); + onToggle(); + } + }; + + return ( + +