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 / container / components / LegacyLayoutControls.js
generateblocks / src / blocks / container / components Last commit date
BlockAppender.js 3 years ago BlockControls.js 2 years ago ComponentCSS.js 1 year ago ContainerContentRenderer.js 2 years ago GridItem.js 4 years ago InspectorAdvancedControls.js 2 years ago LegacyLayoutControls.js 3 years ago ShapeDividers.js 4 years ago TagName.js 3 years ago
LegacyLayoutControls.js
181 lines
1 import {
2 SelectControl,
3 TextControl,
4 } from '@wordpress/components';
5 import { Fragment } from '@wordpress/element';
6 import { __ } from '@wordpress/i18n';
7 import { applyFilters } from '@wordpress/hooks';
8 import UnitPicker from '../../../components/unit-picker';
9 import sizingValue from '../../../utils/sizingValue';
10
11 export default ( props ) => {
12 const {
13 attributes,
14 setAttributes,
15 deviceType,
16 blockDefaults,
17 } = props;
18
19 const {
20 isGrid,
21 outerContainer,
22 innerContainer,
23 containerWidth,
24 align,
25 useInnerContainer,
26 sizing,
27 verticalAlignment,
28 verticalAlignmentTablet,
29 verticalAlignmentMobile,
30 } = attributes;
31
32 if ( ! useInnerContainer ) {
33 return null;
34 }
35
36 return (
37 <>
38 { ! isGrid && (
39 <>
40 { 'Desktop' === deviceType &&
41 <Fragment>
42 <SelectControl
43 label={ __( 'Container', 'generateblocks' ) }
44 value={ outerContainer }
45 options={ [
46 { label: __( 'Full width', 'generateblocks' ), value: 'full' },
47 { label: __( 'Contained width', 'generateblocks' ), value: 'contained' },
48 ] }
49 onChange={ ( value ) => {
50 setAttributes( {
51 outerContainer: value,
52 } );
53
54 if ( 'contained' === value && 'full' === align ) {
55 setAttributes( {
56 align: '',
57 } );
58 }
59 } }
60 />
61
62 { 'full' === outerContainer &&
63 <SelectControl
64 label={ __( 'Inner Container', 'generateblocks' ) }
65 value={ innerContainer }
66 options={ [
67 { label: __( 'Full width', 'generateblocks' ), value: 'full' },
68 { label: __( 'Contained width', 'generateblocks' ), value: 'contained' },
69 ] }
70 onChange={ ( value ) => {
71 setAttributes( {
72 innerContainer: value,
73 } );
74 } }
75 />
76 }
77
78 { ( 'contained' === outerContainer || 'contained' === innerContainer ) &&
79 <Fragment>
80 <UnitPicker
81 label={
82 'full' === outerContainer &&
83 'contained' === innerContainer
84 ? __( 'Inner Container Width', 'generateblocks' )
85 : __( 'Container Width', 'generateblocks' )
86 }
87 value={ 'px' }
88 units={ [ 'px' ] }
89 onClick={ () => {
90 return false;
91 } }
92 />
93
94 <TextControl
95 type={ 'number' }
96 className="gblocks-container-width"
97 value={ parseFloat( containerWidth ) || '' }
98 placeholder={ blockDefaults.containerWidth }
99 onChange={ ( value ) => {
100 setAttributes( {
101 containerWidth: '' !== value ? parseFloat( value ) : undefined,
102 } );
103 } }
104 />
105 </Fragment>
106 }
107 </Fragment>
108 }
109 </>
110 ) }
111
112 { 'Desktop' === deviceType &&
113 <>
114 { ( !! isGrid || sizingValue( 'minHeight', sizing ) ) &&
115 <>
116 <SelectControl
117 label={ __( 'Vertical Alignment', 'generateblocks' ) }
118 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
119 value={ verticalAlignment }
120 options={ [
121 { label: __( 'Default', 'generateblocks' ), value: '' },
122 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
123 { label: __( 'Center', 'generateblocks' ), value: 'center' },
124 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
125 ] }
126 onChange={ ( value ) => {
127 setAttributes( {
128 verticalAlignment: value,
129 } );
130 } }
131 />
132 </>
133 }
134 </>
135 }
136
137 { 'Tablet' === deviceType && ( !! isGrid || sizingValue( 'minHeight', sizing ) || sizingValue( 'minHeightTablet', sizing ) ) &&
138 <SelectControl
139 label={ __( 'Vertical Alignment', 'generateblocks' ) }
140 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
141 value={ verticalAlignmentTablet }
142 options={ [
143 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
144 { label: __( 'Default', 'generateblocks' ), value: '' },
145 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
146 { label: __( 'Center', 'generateblocks' ), value: 'center' },
147 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
148 ] }
149 onChange={ ( value ) => {
150 setAttributes( {
151 verticalAlignmentTablet: value,
152 } );
153 } }
154 />
155 }
156
157 { 'Mobile' === deviceType && ( !! isGrid || sizingValue( 'minHeight', sizing ) || sizingValue( 'minHeightTablet', sizing ) || sizingValue( 'minHeightMobile', sizing ) ) &&
158 <SelectControl
159 label={ __( 'Vertical Alignment', 'generateblocks' ) }
160 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
161 value={ verticalAlignmentMobile }
162 options={ [
163 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
164 { label: __( 'Default', 'generateblocks' ), value: '' },
165 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
166 { label: __( 'Center', 'generateblocks' ), value: 'center' },
167 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
168 ] }
169 onChange={ ( value ) => {
170 setAttributes( {
171 verticalAlignmentMobile: value,
172 } );
173 } }
174 />
175 }
176
177 { applyFilters( 'generateblocks.editor.controls', '', 'containerLayout', props ) }
178 </>
179 );
180 };
181