diff --git a/packages/block-editor/src/hooks/layout.scss b/packages/block-editor/src/hooks/layout.scss index 3b06bc44478bad..9d154045c5a282 100644 --- a/packages/block-editor/src/hooks/layout.scss +++ b/packages/block-editor/src/hooks/layout.scss @@ -21,3 +21,9 @@ .block-editor-hooks__layout-controls-helptext { font-size: $helptext-font-size; } + +.block-editor-hooks__flex-layout-justification-controls { + legend { + margin-bottom: $grid-unit-10; + } +} diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js index 2c1b9f69be4a56..471cdc99b99b05 100644 --- a/packages/block-editor/src/layouts/flex.js +++ b/packages/block-editor/src/layouts/flex.js @@ -1,11 +1,14 @@ /** * WordPress dependencies */ -import { __, _x } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import { - __experimentalToggleGroupControl as ToggleGroupControl, - __experimentalToggleGroupControlOption as ToggleGroupControlOption, -} from '@wordpress/components'; + justifyLeft, + justifyCenter, + justifyRight, + justifySpaceBetween, +} from '@wordpress/icons'; +import { Button } from '@wordpress/components'; /** * Internal dependencies @@ -87,12 +90,40 @@ export default { }, }; +const justificationOptions = [ + { + value: 'left', + icon: justifyLeft, + label: __( 'Justify items left' ), + }, + { + value: 'center', + icon: justifyCenter, + label: __( 'Justify items center' ), + }, + { + value: 'right', + icon: justifyRight, + label: __( 'Justify items right' ), + }, + { + value: 'space-between', + icon: justifySpaceBetween, + label: __( 'Space between items' ), + }, +]; function FlexLayoutJustifyContentControl( { layout, onChange, isToolbar = false, } ) { const { justifyContent = 'left' } = layout; + const onJustificationChange = ( value ) => { + onChange( { + ...layout, + justifyContent: value, + } ); + }; if ( isToolbar ) { return ( { - onChange( { - ...layout, - justifyContent: value, - } ); - } } + onChange={ onJustificationChange } popoverProps={ { position: 'bottom right', isAlternate: true, @@ -116,34 +142,23 @@ function FlexLayoutJustifyContentControl( { /> ); } + return ( - { - onChange( { - ...layout, - justifyContent: value, - } ); - } } - isBlock - > - - - - - +
+ { __( 'Justification' ) } +
+ { justificationOptions.map( ( { value, icon, label } ) => { + return ( +
+
); }