I’m attempting to put together a variable/mixed content carousel block. I’m having issues trying to figure out how to create/delete individual slides in the carousel (using something like rangecontrol).
So far I have this:
const ALLOWED_BLOCKS = [ 'core/paragraph' ];
const BLOCKS_TEMPLATE = [
[ 'core/columns', {}, [] ],
];
registerBlockType( 'blocks/carousel', {
title: __( 'Carousel' ),
icon: 'layout',
attributes: {
count: {
type: 'number',
},
},
edit( { attributes, setAttributes, className } ) {
const onChangeCount = value => {
setAttributes( { count: value } );
};
return [
<InspectorControls key="controls">
<PanelBody>
<RangeControl
label={ __( 'Slides' ) }
value={ attributes.count }
onChange={ onChangeCount }
min={ 2 }
max={ 6 }
/>
</PanelBody>
</InspectorControls>,
<div className={ className } key="content">
<InnerBlocks
template={ BLOCKS_TEMPLATE }
allowedBlocks={ ALLOWED_BLOCKS }
templateLock="all"
/>
</div>,
];
},
save( { attributes } ) {
return (
<div>
<InnerBlocks.Content />
</div>
);
},
} );
So I’m not entirely sure what I need to allow for creating/deleting the slides via the range. If someone could offer me a rough solution and/or point me at some documentation I’d appreciate it.