diff --git a/src/blocks/testimonial/block.json b/src/blocks/testimonial/block.json index f2d8674b..f281beaa 100644 --- a/src/blocks/testimonial/block.json +++ b/src/blocks/testimonial/block.json @@ -15,6 +15,10 @@ "type": "number", "default": 2 }, + "gap": { + "type": "string", + "default": "" + }, "templateLock": { "type": [ "string", "boolean" ], "enum": [ "all", "insert", "contentOnly", false ] diff --git a/src/blocks/testimonial/edit.js b/src/blocks/testimonial/edit.js index 9266f820..6e7d5219 100644 --- a/src/blocks/testimonial/edit.js +++ b/src/blocks/testimonial/edit.js @@ -8,6 +8,7 @@ import { } from '@wordpress/block-editor'; import { + BaseControl, RangeControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, @@ -33,7 +34,7 @@ export default function ( { attributes, setAttributes, className, clientId } ) { }, ] ); - const { md, lg, templateLock } = attributes; + const { md, lg, gap, templateLock } = attributes; const hasInnerBlocks = useSelect( ( select ) => @@ -43,7 +44,9 @@ export default function ( { attributes, setAttributes, className, clientId } ) { ); const classes = classnames( 'smb-testimonial', className ); - const rowClasses = classnames( 'c-row', 'c-row--margin' ); + const rowClasses = classnames( 'c-row', 'c-row--margin', { + [ `c-row--margin-${ gap }` ]: !! gap, + } ); const blockProps = useBlockProps( { className: classes, @@ -64,6 +67,21 @@ export default function ( { attributes, setAttributes, className, clientId } ) { } ); + const gapOptions = [ + { + label: 'S', + value: 1, + }, + { + label: 'M', + value: 2, + }, + { + label: 'L', + value: 3, + }, + ]; + return ( <> @@ -122,6 +140,65 @@ export default function ( { attributes, setAttributes, className, clientId } ) { + + gap !== metadata.attributes.gap.default } + isShownByDefault + label={ __( + 'The gap between each item', + 'snow-monkey-blocks' + ) } + onDeselect={ () => + setAttributes( { + gap: metadata.attributes.gap.default, + } ) + } + panelId={ clientId } + > + + + option.label?.toLowerCase() === gap + )?.[ 0 ]?.value + } + resetFallbackValue={ undefined } + onChange={ ( value ) => + setAttributes( { + gap: gapOptions + .filter( + ( option ) => option.value === value + )?.[ 0 ] + ?.label?.toLowerCase(), + } ) + } + withInputField={ false } + min={ 1 } + max={ 3 } + marks + renderTooltipContent={ ( _value ) => + gapOptions + .filter( + ( option ) => option.value === _value + )?.[ 0 ] + ?.label?.toUpperCase() + } + hideLabelFromVision + __nextHasNoMarginBottom + /> + + + +