diff --git a/packages/block-editor/src/components/block-vertical-alignment-control/icons.js b/packages/block-editor/src/components/block-vertical-alignment-control/icons.js index 14c68957b9e6a..87c4aa64a69e5 100644 --- a/packages/block-editor/src/components/block-vertical-alignment-control/icons.js +++ b/packages/block-editor/src/components/block-vertical-alignment-control/icons.js @@ -20,3 +20,16 @@ export const alignTop = ( ); + +// Todo: Replace with the real icons. +export const alignStretch = ( + + + +); + +export const spaceBetween = ( + + + +); diff --git a/packages/block-editor/src/components/block-vertical-alignment-control/ui.js b/packages/block-editor/src/components/block-vertical-alignment-control/ui.js index 3a243da1b9572..f8a69710e3b75 100644 --- a/packages/block-editor/src/components/block-vertical-alignment-control/ui.js +++ b/packages/block-editor/src/components/block-vertical-alignment-control/ui.js @@ -7,7 +7,13 @@ import { ToolbarGroup, ToolbarDropdownMenu } from '@wordpress/components'; /** * Internal dependencies */ -import { alignTop, alignCenter, alignBottom } from './icons'; +import { + alignTop, + alignCenter, + alignBottom, + alignStretch, + spaceBetween, +} from './icons'; const BLOCK_ALIGNMENTS_CONTROLS = { top: { @@ -22,6 +28,14 @@ const BLOCK_ALIGNMENTS_CONTROLS = { icon: alignBottom, title: _x( 'Align bottom', 'Block vertical alignment setting' ), }, + stretch: { + icon: alignStretch, + title: _x( 'Stretch to fill', 'Block vertical alignment setting' ), + }, + spaceBetween: { + icon: spaceBetween, + title: _x( 'Space between', 'Block vertical alignment setting' ), + }, }; const DEFAULT_CONTROLS = [ 'top', 'center', 'bottom' ]; diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js index 948eceb6624d6..3e3e179a03cfb 100644 --- a/packages/block-editor/src/layouts/flex.js +++ b/packages/block-editor/src/layouts/flex.js @@ -44,12 +44,15 @@ const alignItemsMap = { left: 'flex-start', right: 'flex-end', center: 'center', + stretch: 'stretch', }; const verticalAlignmentMap = { top: 'flex-start', center: 'center', bottom: 'flex-end', + stretch: 'stretch', + spaceBetween: 'space-between', }; const flexWrapOptions = [ 'wrap', 'nowrap' ]; @@ -101,14 +104,13 @@ export default { onChange={ onChange } isToolbar /> - { allowVerticalAlignment && - layout?.orientation !== 'vertical' && ( - - ) } + { allowVerticalAlignment && ( + + ) } ); }, @@ -153,6 +155,9 @@ export default { rules.push( `justify-content: ${ justifyContent }` ); } } else { + if ( verticalAlignment ) { + rules.push( `justify-content: ${ verticalAlignment }` ); + } rules.push( 'flex-direction: column' ); rules.push( `align-items: ${ alignItems }` ); } @@ -188,7 +193,14 @@ function FlexLayoutVerticalAlignmentControl( { onChange, isToolbar = false, } ) { - const { verticalAlignment = verticalAlignmentMap.center } = layout; + const { orientation = 'horizontal' } = layout; + + const defaultVerticalAlignment = + orientation === 'horizontal' + ? verticalAlignmentMap.center + : verticalAlignmentMap.top; + + const { verticalAlignment = defaultVerticalAlignment } = layout; const onVerticalAlignmentChange = ( value ) => { onChange( { @@ -201,6 +213,11 @@ function FlexLayoutVerticalAlignmentControl( { ); } @@ -255,6 +272,8 @@ function FlexLayoutJustifyContentControl( { const allowedControls = [ 'left', 'center', 'right' ]; if ( orientation === 'horizontal' ) { allowedControls.push( 'space-between' ); + } else { + allowedControls.push( 'stretch' ); } if ( isToolbar ) { return ( @@ -293,6 +312,13 @@ function FlexLayoutJustifyContentControl( { icon: justifySpaceBetween, label: __( 'Space between items' ), } ); + } else { + // Todo: we also need an icon here. + justificationOptions.push( { + value: 'stretch', + icon: justifySpaceBetween, + label: __( 'Stretch items' ), + } ); } return (