From cb6a610a44f694fd074974e4dcc687615e98ec91 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 19 Dec 2023 16:07:44 +0200 Subject: [PATCH] spaser for editing --- blocks/Container/src/index.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/blocks/Container/src/index.jsx b/blocks/Container/src/index.jsx index 76770637..31208af6 100644 --- a/blocks/Container/src/index.jsx +++ b/blocks/Container/src/index.jsx @@ -11,18 +11,24 @@ const { useSelect } = wp.data; const { InspectorControls, useBlockProps, InnerBlocks } = wp.blockEditor; const { PanelBody, SelectControl, RangeControl, CheckboxControl } = wp.components; const numberOfGrid = 5; + const spacers = ['m', 'p']; const spacersName = ['t', 'b', 'e', 's']; + registerBlockType( metadata, { getEditWrapperProps(attributes) { const { size } = attributes; const classes = []; + // console.log(attributes.size); Object.values(size).forEach((item) => { if (item.valueRange) { Object.keys(item.valueRange).forEach(i => { - classes.push(`${i}-${item.valueRange[i]}`); + + const modifiedClass = `${i}-${item.valueRange[i] === (numberOfGrid + 1) ? 'auto' : item.valueRange[i]}`.replace('-xs', ''); + + classes.push(modifiedClass); }); } }); @@ -88,6 +94,8 @@ registerBlockType( {spacers.map((spacer, index) => ( spacersName.map((spacerName, innerIndex) => { const uniqueKey = `${spacer}${spacerName}-${breakpoint}`; + const maxGrid = spacer === 'p' ? numberOfGrid : numberOfGrid + 1; + return ( );