PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.9.0
GenerateBlocks v1.9.0
2.4.1 2.4.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 / extend / inspector-control / controls / flex-child-panel / index.js
generateblocks / src / extend / inspector-control / controls / flex-child-panel Last commit date
components 3 years ago attributes.js 3 years ago index.js 3 years ago
index.js
56 lines
1 import { __ } from '@wordpress/i18n';
2 import PanelArea from '../../../../components/panel-area';
3 import { useContext } from '@wordpress/element';
4 import ControlsContext from '../../../../block-context';
5 import getAttribute from '../../../../utils/get-attribute';
6 import getResponsivePlaceholder from '../../../../utils/get-responsive-placeholder';
7 import FlexControls from './components/FlexControls';
8 import hasNumericValue from '../../../../utils/has-numeric-value';
9 import { TextControl } from '@wordpress/components';
10 import getDeviceType from '../../../../utils/get-device-type';
11
12 export default function FlexChild( { attributes, setAttributes } ) {
13 const device = getDeviceType();
14 const { id, supports: { flexChildPanel } } = useContext( ControlsContext );
15
16 const componentProps = {
17 attributes,
18 deviceType: device,
19 };
20
21 const {
22 useInnerContainer,
23 isGrid,
24 } = attributes;
25
26 return (
27 <PanelArea
28 title={ __( 'Flex Child', 'generateblocks' ) }
29 initialOpen={ false }
30 className="gblocks-panel-label"
31 id={ `${ id }FlexChild` }
32 >
33 { flexChildPanel.flex && ( ! useInnerContainer || ( useInnerContainer && isGrid ) ) &&
34 <FlexControls
35 attributes={ attributes }
36 setAttributes={ setAttributes }
37 />
38 }
39
40 { flexChildPanel.order && ( ! useInnerContainer || ( useInnerContainer && isGrid ) ) &&
41 <TextControl
42 type={ 'number' }
43 label={ __( 'Order', 'generateblocks' ) }
44 value={ hasNumericValue( getAttribute( 'order', componentProps ) ) ? getAttribute( 'order', componentProps ) : '' }
45 placeholder={ getResponsivePlaceholder( 'order', attributes, device ) }
46 onChange={ ( value ) => {
47 setAttributes( {
48 [ getAttribute( 'order', componentProps, true ) ]: parseFloat( value ),
49 } );
50 } }
51 />
52 }
53 </PanelArea>
54 );
55 }
56