PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / query-loop / components / LayoutSelector.js
generateblocks / src / blocks / query-loop / components Last commit date
inspector-controls 3 years ago BlockControls.js 3 years ago InspectorAdvancedControls.js 2 years ago InspectorControls.js 3 years ago LayoutSelector.js 3 years ago LoopRenderer.js 3 years ago QueryLoopRenderer.js 2 years ago utils.js 3 years ago
LayoutSelector.js
45 lines
1 import { Placeholder, Button } from '@wordpress/components';
2 import { __ } from '@wordpress/i18n';
3 import templates from '../templates';
4 import { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
5 import { useDispatch } from '@wordpress/data';
6 import getIcon from '../../../utils/get-icon';
7
8 export default ( { clientId, isDisabled } ) => {
9 if ( isDisabled ) {
10 return false;
11 }
12
13 const { replaceInnerBlocks } = useDispatch( 'core/block-editor' );
14
15 return (
16 <Placeholder
17 label={ __( 'Query Loop', 'generateblocks' ) }
18 icon={ getIcon( 'query-loop' ) }
19 instructions={ __( 'Choose a layout to start with.', 'generateblocks' ) }
20 className="gblocks-query-loop-layout-selector"
21 >
22 <div className="gblocks-query-loop-layout-selector__content">
23 { templates.map( ( template ) => {
24 return (
25 <Button
26 key={ `template-${ template.name }` }
27 onClick={ () => {
28 replaceInnerBlocks(
29 clientId,
30 createBlocksFromInnerBlocksTemplate( template.innerBlocks )
31 );
32 } }
33 >
34 { template.icon }
35 <p>
36 { template.title }
37 </p>
38 </Button>
39 );
40 } ) }
41 </div>
42 </Placeholder>
43 );
44 };
45