Skip to content

Commit

Permalink
spaser for editing
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHalkin committed Dec 19, 2023
1 parent 016561b commit cb6a610
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions blocks/Container/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
});
Expand Down Expand Up @@ -88,6 +94,8 @@ registerBlockType(
{spacers.map((spacer, index) => (

Check warning on line 94 in blocks/Container/src/index.jsx

View workflow job for this annotation

GitHub Actions / stylelint

'index' is defined but never used
spacersName.map((spacerName, innerIndex) => {

Check warning on line 95 in blocks/Container/src/index.jsx

View workflow job for this annotation

GitHub Actions / stylelint

'innerIndex' is defined but never used
const uniqueKey = `${spacer}${spacerName}-${breakpoint}`;
const maxGrid = spacer === 'p' ? numberOfGrid : numberOfGrid + 1;

return (
<RangeControl
key={uniqueKey}
Expand Down Expand Up @@ -139,7 +147,7 @@ registerBlockType(
}}

min={-1}
max={numberOfGrid + 1}
max={maxGrid}
{...props}
/>
);
Expand Down

0 comments on commit cb6a610

Please sign in to comment.