PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.0
GenerateBlocks v1.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 / edit.js
generateblocks / src / blocks / container Last commit date
css 6 years ago attributes.js 6 years ago block-controls.js 6 years ago block.js 6 years ago edit.js 6 years ago editor.scss 6 years ago save.js 6 years ago section-tag.js 6 years ago style.scss 6 years ago
edit.js
1474 lines
1 /**
2 * Block: Container
3 */
4
5 import Section from './section-tag';
6 import ColorPicker from '../../components/color-picker';
7 import getIcon from '../../utils/get-icon';
8 import classnames from 'classnames';
9 import DimensionsControl from '../../components/dimensions/';
10 import PanelArea from '../../components/panel-area/';
11 import TypographyControls from '../../components/typography';
12 import GradientControl from '../../components/gradient/';
13 import ResponsiveTabs from '../../components/responsive-tabs';
14 import DesktopCSS from './css/desktop.js';
15
16 const {
17 __,
18 _x,
19 sprintf,
20 } = wp.i18n;
21
22 const {
23 RangeControl,
24 Button,
25 ButtonGroup,
26 ResponsiveWrapper,
27 ToggleControl,
28 SelectControl,
29 TextControl,
30 Tooltip,
31 BaseControl,
32 } = wp.components;
33
34 const {
35 Fragment,
36 Component,
37 } = wp.element;
38
39 const {
40 InspectorControls,
41 InnerBlocks,
42 MediaUpload,
43 AlignmentToolbar,
44 } = wp.blockEditor;
45
46 const {
47 applyFilters,
48 } = wp.hooks;
49
50 const ELEMENT_ID_REGEX = /[\s#]/g;
51 const gbContainerIds = [];
52
53 class GenerateBlockContainer extends Component {
54 constructor() {
55 super( ...arguments );
56
57 this.state = {
58 selectedDevice: 'desktop',
59 };
60 }
61
62 componentDidMount() {
63 const id = this.props.clientId.substr( 2, 9 ).replace( '-', '' );
64
65 if ( ! this.props.attributes.uniqueId ) {
66 this.props.setAttributes( {
67 uniqueId: id,
68 } );
69
70 gbContainerIds.push( id );
71 } else if ( gbContainerIds.includes( this.props.attributes.uniqueId ) ) {
72 this.props.setAttributes( {
73 uniqueId: id,
74 } );
75
76 gbContainerIds.push( id );
77 } else {
78 gbContainerIds.push( this.props.attributes.uniqueId );
79 }
80 }
81
82 render() {
83 const {
84 attributes,
85 setAttributes,
86 hasChildBlocks,
87 clientId,
88 } = this.props;
89
90 const {
91 selectedDevice,
92 } = this.state;
93
94 const onSelectBgImage = ( media ) => {
95 setAttributes( {
96 bgImage: {
97 id: media.id,
98 image: media.sizes.full,
99 },
100 } );
101 };
102
103 const onRemoveBgImage = () => {
104 setAttributes( {
105 bgImage: null,
106 } );
107 };
108
109 const {
110 uniqueId,
111 tagName,
112 elementId,
113 cssClasses,
114 isGrid,
115 width,
116 widthTablet,
117 widthMobile,
118 outerContainer,
119 innerContainer,
120 containerWidth,
121 minHeight,
122 minHeightUnit,
123 minHeightTablet,
124 minHeightUnitTablet,
125 minHeightMobile,
126 minHeightUnitMobile,
127 borderColor,
128 borderColorOpacity,
129 backgroundColor,
130 backgroundColorOpacity,
131 textColor,
132 linkColor,
133 linkColorHover,
134 bgImage,
135 bgOptions,
136 verticalAlignment,
137 verticalAlignmentTablet,
138 verticalAlignmentMobile,
139 zindex,
140 removeVerticalGap,
141 removeVerticalGapTablet,
142 removeVerticalGapMobile,
143 orderTablet,
144 orderMobile,
145 alignment,
146 alignmentTablet,
147 alignmentMobile,
148 fontFamily,
149 googleFont,
150 googleFontVariants,
151 fullWidthContent,
152 } = attributes;
153
154 const minHeightUnits = [
155 {
156 name: _x( 'Pixel', 'A size unit for CSS markup' ),
157 unitValue: 'px',
158 },
159 {
160 name: _x( 'VH', 'A size unit for CSS markup' ),
161 unitValue: 'vh',
162 },
163 {
164 name: _x( 'VW', 'A size unit for CSS markup' ),
165 unitValue: 'vw',
166 },
167 ];
168
169 const pageBuilderContainerOption = document.getElementById( '_generate-full-width-content' );
170 const changeEvent = new Event( 'change' ); // eslint-disable-line no-undef
171 const getRootId = wp.data.select( 'core/block-editor' ).getBlockHierarchyRootClientId( clientId );
172 const isRootContainer = getRootId === clientId;
173
174 const fullWidthContentOptions = () => {
175 return (
176 <div>
177 { generateBlocksInfo.isGeneratePress && isRootContainer && pageBuilderContainerOption &&
178 <ToggleControl
179 label={ __( 'Set Full Width Content', 'generateblocks' ) }
180 help={ __( 'This option tells the content container that contains all of the blocks on this page to be full width.', 'generateblocks' ) }
181 checked={ fullWidthContent ? true : false }
182 onChange={ ( value ) => {
183 if ( value ) {
184 pageBuilderContainerOption.checked = true;
185 pageBuilderContainerOption.setAttribute( 'value', 'true' );
186 pageBuilderContainerOption.dispatchEvent( changeEvent );
187
188 setAttributes( {
189 fullWidthContent: 'true',
190 } );
191 } else {
192 pageBuilderContainerOption.checked = false;
193 pageBuilderContainerOption.setAttribute( 'value', '' );
194 document.querySelector( 'input[name="_generate-full-width-content"]#default-content' ).checked = true;
195 pageBuilderContainerOption.dispatchEvent( changeEvent );
196
197 setAttributes( {
198 fullWidthContent: '',
199 } );
200 }
201 } }
202 />
203 }
204 </div>
205 );
206 };
207
208 let googleFontsAttr = '';
209
210 if ( googleFontVariants ) {
211 googleFontsAttr = ':' + googleFontVariants;
212 }
213
214 let parentBlockId = false,
215 parentBlock = false,
216 hasGridContainer = false,
217 gridContainerId = '';
218
219 if ( typeof wp.data.select( 'core/block-editor' ).getBlockParents === 'function' ) {
220 parentBlockId = wp.data.select( 'core/block-editor' ).getBlockParents( clientId, true )[ 0 ];
221
222 if ( parentBlockId ) {
223 parentBlock = wp.data.select( 'core/block-editor' ).getBlocksByClientId( parentBlockId );
224
225 if ( parentBlock && 'generateblocks/grid' === parentBlock[ 0 ].name ) {
226 hasGridContainer = true;
227 gridContainerId = parentBlock[ 0 ].attributes.uniqueId;
228 }
229 }
230 }
231
232 return (
233 <Fragment>
234 <InspectorControls>
235 <ResponsiveTabs { ...this.props }
236 selectedDevice={ selectedDevice }
237 onClick={ ( device ) => {
238 this.setState( {
239 selectedDevice: device,
240 } );
241 } }
242 />
243
244 { ! isGrid && (
245 <PanelArea { ...this.props }
246 title={ __( 'Layout', 'generateblocks' ) }
247 initialOpen={ true }
248 icon={ getIcon( 'layout' ) }
249 className={ 'gblocks-panel-label' }
250 id={ 'containerLayout' }
251 state={ this.state }
252 showPanel={ 'desktop' === selectedDevice || false }
253 >
254
255 <Fragment>
256 { hasGridContainer &&
257 <ToggleControl
258 label={ __( 'Grid Item', 'generateblocks' ) }
259 help={ __( 'This Container is inside a Grid Block but is not set as a grid item. Enable this option for optimal results.', 'generateblocks' ) }
260 checked={ !! isGrid }
261 onChange={ ( value ) => {
262 setAttributes( {
263 isGrid: value,
264 gridId: gridContainerId,
265 } );
266 } }
267 />
268 }
269
270 { fullWidthContentOptions() }
271
272 <SelectControl
273 label={ __( 'Container', 'generateblocks' ) }
274 value={ outerContainer }
275 options={ [
276 { label: __( 'Full width', 'generateblocks' ), value: 'full' },
277 { label: __( 'Contained', 'generateblocks' ), value: 'contained' },
278 ] }
279 onChange={ ( value ) => {
280 setAttributes( {
281 outerContainer: value,
282 } );
283 } }
284 />
285
286 { ! generateBlocksInfo.isGeneratePress && 'full' === outerContainer &&
287 <BaseControl
288 label={ __( 'Full width containers will only work if your theme allows you to set your content to be full width.', 'generateblocks' ) }
289 />
290 }
291
292 <SelectControl
293 label={ __( 'Inner Container', 'generateblocks' ) }
294 value={ innerContainer }
295 options={ [
296 { label: __( 'Full width', 'generateblocks' ), value: 'full' },
297 { label: __( 'Contained', 'generateblocks' ), value: 'contained' },
298 ] }
299 onChange={ ( value ) => {
300 setAttributes( {
301 innerContainer: value,
302 } );
303 } }
304 />
305
306 <div className="components-gblocks-control__header">
307 <div className="components-gblocks-control__label">
308 { __( 'Container Width', 'generateblocks' ) }
309 </div>
310
311 <div className="components-gblocks-control__units">
312 <Tooltip text={ __( 'Pixel Units' ) } key={ 'container-width-unit' }>
313 <Button
314 key={ 'container-width-unit' }
315 isSmall
316 isPrimary={ true }
317 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
318 aria-label={ __( 'Pixel Units' ) }
319 >
320 px
321 </Button>
322 </Tooltip>
323 </div>
324 </div>
325
326 <TextControl
327 type={ 'number' }
328 value={ parseFloat( containerWidth ) || '' }
329 placeholder={ generateBlocksDefaults.container.containerWidth }
330 onChange={ ( value ) => {
331 setAttributes( {
332 containerWidth: '' !== value ? parseFloat( value ) : undefined,
333 } );
334 } }
335 />
336 </Fragment>
337
338 { applyFilters( 'generateblocks.editor.controls', '', 'containerLayout', this.props, this.state ) }
339 </PanelArea>
340 ) }
341
342 { isGrid && (
343 <PanelArea { ...this.props }
344 title={ __( 'Layout', 'generateblocks' ) }
345 initialOpen={ true }
346 icon={ getIcon( 'layout' ) }
347 className={ 'gblocks-panel-label' }
348 id={ 'containerGridLayout' }
349 state={ this.state }
350 >
351 { ! hasGridContainer &&
352 <ToggleControl
353 label={ __( 'Grid Item', 'generateblocks' ) }
354 help={ __( 'This container is set as a grid item but is not inside a grid block. Deactivate this option for optimal results.', 'generateblocks' ) }
355 checked={ !! isGrid }
356 onChange={ ( value ) => {
357 setAttributes( {
358 isGrid: value,
359 gridId: '',
360 } );
361 } }
362 />
363 }
364
365 { 'desktop' === selectedDevice && (
366 <Fragment>
367 <div className="components-gblocks-control__header">
368 <div className="components-gblocks-control__label">
369 { __( 'Container Width', 'generateblocks' ) }
370 </div>
371
372 <div className="components-gblocks-control__units">
373 <Tooltip text={ __( 'Percentage Units' ) } key={ 'percentage-unit' }>
374 <Button
375 key={ 'percentage-unit' }
376 isSmall
377 isPrimary={ true }
378 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
379 aria-label={ __( 'Percentage Units' ) }
380 >
381 %
382 </Button>
383 </Tooltip>
384 </div>
385 </div>
386
387 <ButtonGroup className={ 'widthButtons' }>
388 <Button isLarge isPrimary={ width === 25 } onClick={ () => setAttributes( { width: 25 } ) }>25</Button>
389 <Button isLarge isPrimary={ width === 33.33 } onClick={ () => setAttributes( { width: 33.33 } ) }>33</Button>
390 <Button isLarge isPrimary={ width === 50 } onClick={ () => setAttributes( { width: 50 } ) }>50</Button>
391 <Button isLarge isPrimary={ width === 66.66 } onClick={ () => setAttributes( { width: 66.66 } ) }>66</Button>
392 <Button isLarge isPrimary={ width === 75 } onClick={ () => setAttributes( { width: 75 } ) }>75</Button>
393 <Button isLarge isPrimary={ width === 100 } onClick={ () => setAttributes( { width: 100 } ) }>100</Button>
394 </ButtonGroup>
395
396 <RangeControl
397 className={ 'gblocks-column-width-control' }
398 value={ width || '' }
399 onChange={ ( value ) => {
400 setAttributes( {
401 width: value,
402 } );
403 } }
404 min={ 0 }
405 max={ 100 }
406 step={ 0.01 }
407 initialPosition={ generateBlocksDefaults.container.width }
408 />
409
410 <SelectControl
411 label={ __( 'Vertical Alignment', 'generateblocks' ) }
412 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
413 value={ verticalAlignment }
414 options={ [
415 { label: __( 'Default', 'generateblocks' ), value: '' },
416 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
417 { label: __( 'Center', 'generateblocks' ), value: 'center' },
418 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
419 ] }
420 onChange={ ( value ) => {
421 setAttributes( {
422 verticalAlignment: value,
423 } );
424 } }
425 />
426
427 <ToggleControl
428 label={ __( 'Remove Vertical Gap', 'generateblocks' ) }
429 checked={ !! removeVerticalGap }
430 onChange={ ( value ) => {
431 setAttributes( {
432 removeVerticalGap: value,
433 } );
434 } }
435 />
436 </Fragment>
437 ) }
438
439 { 'tablet' === selectedDevice && (
440 <Fragment>
441 <div className="components-gblocks-control__header">
442 <div className="components-gblocks-control__label">
443 { __( 'Container Width', 'generateblocks' ) }
444 </div>
445
446 <div className="components-gblocks-control__units">
447 <Tooltip text={ __( 'Percentage Units' ) } key={ 'percentage-unit' }>
448 <Button
449 key={ 'percentage-unit' }
450 isSmall
451 isPrimary={ true }
452 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
453 aria-label={ __( 'Percentage Units' ) }
454 >
455 %
456 </Button>
457 </Tooltip>
458 </div>
459 </div>
460
461 <ButtonGroup className={ 'widthButtons' }>
462 <Button isLarge isPrimary={ widthTablet === 25 } onClick={ () => setAttributes( { widthTablet: 25 } ) }>25</Button>
463 <Button isLarge isPrimary={ widthTablet === 33.33 } onClick={ () => setAttributes( { widthTablet: 33.33 } ) }>33</Button>
464 <Button isLarge isPrimary={ widthTablet === 50 } onClick={ () => setAttributes( { widthTablet: 50 } ) }>50</Button>
465 <Button isLarge isPrimary={ widthTablet === 66.66 } onClick={ () => setAttributes( { widthTablet: 66.66 } ) }>66</Button>
466 <Button isLarge isPrimary={ widthTablet === 75 } onClick={ () => setAttributes( { widthTablet: 75 } ) }>75</Button>
467 <Button isLarge isPrimary={ widthTablet === 100 } onClick={ () => setAttributes( { widthTablet: 100 } ) }>100</Button>
468 </ButtonGroup>
469
470 <RangeControl
471 className={ 'gblocks-column-width-control' }
472 value={ widthTablet || '' }
473 onChange={ ( value ) => {
474 setAttributes( {
475 widthTablet: value,
476 } );
477 } }
478 min={ 0 }
479 max={ 100 }
480 step={ 0.01 }
481 initialPosition={ generateBlocksDefaults.container.widthTablet }
482 />
483
484 <SelectControl
485 label={ __( 'Vertical Alignment', 'generateblocks' ) }
486 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
487 value={ verticalAlignmentTablet }
488 options={ [
489 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
490 { label: __( 'Default', 'generateblocks' ), value: '' },
491 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
492 { label: __( 'Center', 'generateblocks' ), value: 'center' },
493 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
494 ] }
495 onChange={ ( value ) => {
496 setAttributes( {
497 verticalAlignmentTablet: value,
498 } );
499 } }
500 />
501
502 <ToggleControl
503 label={ __( 'Remove Vertical Gap', 'generateblocks' ) }
504 checked={ !! removeVerticalGapTablet }
505 onChange={ ( value ) => {
506 setAttributes( {
507 removeVerticalGapTablet: value,
508 } );
509 } }
510 />
511
512 <TextControl
513 type={ 'number' }
514 label={ __( 'Order', 'generateblocks' ) }
515 value={ orderTablet || 0 === orderTablet ? orderTablet : '' }
516 onChange={ ( value ) => {
517 setAttributes( {
518 orderTablet: parseFloat( value ),
519 } );
520 } }
521 />
522 </Fragment>
523 ) }
524
525 { 'mobile' === selectedDevice && (
526 <Fragment>
527 <div className="components-gblocks-control__header">
528 <div className="components-gblocks-control__label">
529 { __( 'Container Width', 'generateblocks' ) }
530 </div>
531
532 <div className="components-gblocks-control__units">
533 <Tooltip text={ __( 'Percentage Units' ) } key={ 'percentage-unit' }>
534 <Button
535 key={ 'percentage-unit' }
536 isSmall
537 isPrimary={ true }
538 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
539 aria-label={ __( 'Percentage Units' ) }
540 >
541 %
542 </Button>
543 </Tooltip>
544 </div>
545 </div>
546
547 <ButtonGroup className={ 'widthButtons' }>
548 <Button isLarge isPrimary={ widthMobile === 25 } onClick={ () => setAttributes( { widthMobile: 25 } ) }>25</Button>
549 <Button isLarge isPrimary={ widthMobile === 33.33 } onClick={ () => setAttributes( { widthMobile: 33.33 } ) }>33</Button>
550 <Button isLarge isPrimary={ widthMobile === 50 } onClick={ () => setAttributes( { widthMobile: 50 } ) }>50</Button>
551 <Button isLarge isPrimary={ widthMobile === 66.66 } onClick={ () => setAttributes( { widthMobile: 66.66 } ) }>66</Button>
552 <Button isLarge isPrimary={ widthMobile === 75 } onClick={ () => setAttributes( { widthMobile: 75 } ) }>75</Button>
553 <Button isLarge isPrimary={ widthMobile === 100 } onClick={ () => setAttributes( { widthMobile: 100 } ) }>100</Button>
554 </ButtonGroup>
555
556 <RangeControl
557 className={ 'gblocks-column-width-control' }
558 value={ widthMobile || '' }
559 onChange={ ( value ) => {
560 setAttributes( {
561 widthMobile: value,
562 } );
563 } }
564 min={ 0 }
565 max={ 100 }
566 step={ 0.01 }
567 initialPosition={ generateBlocksDefaults.container.widthMobile }
568 />
569
570 <SelectControl
571 label={ __( 'Vertical Alignment', 'generateblocks' ) }
572 help={ __( 'Align grid item content. Does not apply if vertical alignment is set in the grid.', 'generateblocks' ) }
573 value={ verticalAlignmentMobile }
574 options={ [
575 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
576 { label: __( 'Default', 'generateblocks' ), value: '' },
577 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
578 { label: __( 'Center', 'generateblocks' ), value: 'center' },
579 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
580 ] }
581 onChange={ ( value ) => {
582 setAttributes( {
583 verticalAlignmentMobile: value,
584 } );
585 } }
586 />
587
588 <ToggleControl
589 label={ __( 'Remove Vertical Gap', 'generateblocks' ) }
590 checked={ !! removeVerticalGapMobile }
591 onChange={ ( value ) => {
592 setAttributes( {
593 removeVerticalGapMobile: value,
594 } );
595 } }
596 />
597
598 <TextControl
599 type={ 'number' }
600 label={ __( 'Order', 'generateblocks' ) }
601 value={ orderMobile || 0 === orderMobile ? orderMobile : '' }
602 onChange={ ( value ) => {
603 setAttributes( {
604 orderMobile: parseFloat( value ),
605 } );
606 } }
607 />
608 </Fragment>
609 ) }
610
611 { applyFilters( 'generateblocks.editor.controls', '', 'containerGridLayout', this.props, this.state ) }
612 </PanelArea>
613 ) }
614
615 <PanelArea { ...this.props }
616 title={ __( 'Typography', 'generateblocks' ) }
617 initialOpen={ false }
618 icon={ getIcon( 'typography' ) }
619 className={ 'gblocks-panel-label' }
620 id={ 'containerTypography' }
621 state={ this.state }
622 >
623
624 { 'desktop' === selectedDevice && (
625 <Fragment>
626 <BaseControl label={ __( 'Text Alignment', 'generateblocks' ) }>
627 <AlignmentToolbar
628 isCollapsed={ false }
629 value={ alignment }
630 onChange={ ( value ) => {
631 setAttributes( { alignment: value } );
632 } }
633 />
634 </BaseControl>
635
636 <TypographyControls { ...this.props }
637 showFontFamily={ true }
638 showFontWeight={ true }
639 showTextTransform={ true }
640 showFontSize={ true }
641 defaultFontSize={ generateBlocksDefaults.container.fontSize }
642 defaultFontSizeUnit={ generateBlocksDefaults.container.fontSizeUnit }
643 defaultLineHeight={ generateBlocksDefaults.container.lineHeight }
644 defaultLineHeightUnit={ generateBlocksDefaults.container.lineHeightUnit }
645 defaultLetterSpacing={ generateBlocksDefaults.container.letterSpacing }
646 />
647 </Fragment>
648 ) }
649
650 { 'tablet' === selectedDevice && (
651 <Fragment>
652 <BaseControl label={ __( 'Text Alignment', 'generateblocks' ) }>
653 <AlignmentToolbar
654 isCollapsed={ false }
655 value={ alignmentTablet }
656 onChange={ ( value ) => {
657 setAttributes( { alignmentTablet: value } );
658 } }
659 />
660 </BaseControl>
661
662 <TypographyControls { ...this.props }
663 showFontSize={ true }
664 defaultFontSize={ generateBlocksDefaults.container.fontSizeTablet }
665 defaultFontSizeUnit={ generateBlocksDefaults.container.fontSizeUnit }
666 defaultLineHeight={ generateBlocksDefaults.container.lineHeightTablet }
667 defaultLineHeightUnit={ generateBlocksDefaults.container.lineHeightUnit }
668 defaultLetterSpacing={ generateBlocksDefaults.container.letterSpacingTablet }
669 />
670 </Fragment>
671 ) }
672
673 { 'mobile' === selectedDevice && (
674 <Fragment>
675 <BaseControl label={ __( 'Text Alignment', 'generateblocks' ) }>
676 <AlignmentToolbar
677 isCollapsed={ false }
678 value={ alignmentMobile }
679 onChange={ ( value ) => {
680 setAttributes( { alignmentMobile: value } );
681 } }
682 />
683 </BaseControl>
684
685 <TypographyControls { ...this.props }
686 showFontSize={ true }
687 defaultFontSize={ generateBlocksDefaults.container.fontSizeMobile }
688 defaultFontSizeUnit={ generateBlocksDefaults.container.fontSizeUnit }
689 defaultLineHeight={ generateBlocksDefaults.container.lineHeightMobile }
690 defaultLineHeightUnit={ generateBlocksDefaults.container.lineHeightUnit }
691 defaultLetterSpacing={ generateBlocksDefaults.container.letterSpacingMobile }
692 />
693 </Fragment>
694 ) }
695
696 { applyFilters( 'generateblocks.editor.controls', '', 'containerTypography', this.props, this.state ) }
697 </PanelArea>
698
699 <PanelArea { ...this.props }
700 title={ __( 'Spacing', 'generateblocks' ) }
701 initialOpen={ false }
702 icon={ getIcon( 'spacing' ) }
703 className={ 'gblocks-panel-label' }
704 id={ 'containerSpacing' }
705 state={ this.state }
706 >
707
708 { 'desktop' === selectedDevice && (
709 <Fragment>
710 <div className="components-gblocks-dimensions-control__header">
711 <div className="components-gblocks-dimensions-control__label">
712 { __( 'Minimum Height', 'generateblocks' ) }
713 </div>
714
715 <div className="components-gblocks-control__units">
716 <ButtonGroup className="components-gblocks-dimensions-control__units" aria-label={ __( 'Select Units' ) }>
717 { minHeightUnits.map( ( unit ) =>
718 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
719 <Tooltip text={ sprintf( __( '%s Units' ), unit.name ) } key={ unit.unitValue }>
720 <Button
721 key={ unit.unitValue }
722 className={ 'components-gblocks-dimensions-control__units--' + unit.name }
723 isSmall
724 isPrimary={ minHeightUnit === unit.unitValue }
725 aria-pressed={ minHeightUnit === unit.unitValue }
726 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
727 aria-label={ sprintf( __( '%s Units' ), unit.name ) }
728 onClick={ () => setAttributes( { minHeightUnit: unit.unitValue } ) }
729 >
730 { unit.unitValue }
731 </Button>
732 </Tooltip>
733 ) }
734 </ButtonGroup>
735 </div>
736 </div>
737
738 <TextControl
739 type={ 'number' }
740 value={ minHeight ? minHeight : '' }
741 onChange={ ( value ) => {
742 setAttributes( {
743 minHeight: parseFloat( value ),
744 } );
745 } }
746 />
747
748 { !! minHeight && ! isGrid &&
749 <SelectControl
750 label={ __( 'Vertical Alignment', 'generateblocks' ) }
751 value={ verticalAlignment }
752 options={ [
753 { label: __( 'Default', 'generateblocks' ), value: '' },
754 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
755 { label: __( 'Center', 'generateblocks' ), value: 'center' },
756 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
757 ] }
758 onChange={ ( value ) => {
759 setAttributes( {
760 verticalAlignment: value,
761 } );
762 } }
763 />
764 }
765
766 <DimensionsControl { ...this.props }
767 device={ selectedDevice }
768 type={ 'padding' }
769 label={ __( 'Padding', 'generateblocks' ) }
770 attrTop={ 'paddingTop' }
771 attrRight={ 'paddingRight' }
772 attrBottom={ 'paddingBottom' }
773 attrLeft={ 'paddingLeft' }
774 attrUnit={ 'paddingUnit' }
775 attrSyncUnits={ 'paddingSyncUnits' }
776 defaults={ generateBlocksDefaults.container }
777 />
778
779 <DimensionsControl { ...this.props }
780 device={ selectedDevice }
781 type={ 'margin' }
782 label={ __( 'Margin', 'generateblocks' ) }
783 attrTop={ 'marginTop' }
784 attrRight={ 'marginRight' }
785 attrBottom={ 'marginBottom' }
786 attrLeft={ 'marginLeft' }
787 attrUnit={ 'marginUnit' }
788 attrSyncUnits={ 'marginSyncUnits' }
789 defaults={ generateBlocksDefaults.container }
790 />
791
792 <DimensionsControl { ...this.props }
793 device={ selectedDevice }
794 type={ 'padding' }
795 label={ __( 'Border Size', 'generateblocks' ) }
796 attrTop={ 'borderSizeTop' }
797 attrRight={ 'borderSizeRight' }
798 attrBottom={ 'borderSizeBottom' }
799 attrLeft={ 'borderSizeLeft' }
800 attrSyncUnits={ 'borderSizeSyncUnits' }
801 displayUnit={ 'px' }
802 defaults={ generateBlocksDefaults.container }
803 />
804
805 <DimensionsControl { ...this.props }
806 device={ selectedDevice }
807 type={ 'padding' }
808 label={ __( 'Border Radius', 'generateblocks' ) }
809 attrTop={ 'borderRadiusTopLeft' }
810 attrRight={ 'borderRadiusTopRight' }
811 attrBottom={ 'borderRadiusBottomRight' }
812 attrLeft={ 'borderRadiusBottomLeft' }
813 attrUnit={ 'borderRadiusUnit' }
814 attrSyncUnits={ 'borderRadiusSyncUnits' }
815 labelTop={ __( 'T-Left', 'generateblocks' ) }
816 labelRight={ __( 'T-Right', 'generateblocks' ) }
817 labelBottom={ __( 'B-Right', 'generateblocks' ) }
818 labelLeft={ __( 'B-Left', 'generateblocks' ) }
819 defaults={ generateBlocksDefaults.container }
820 />
821 </Fragment>
822 ) }
823
824 { 'tablet' === selectedDevice && (
825 <Fragment>
826 <div className="components-gblocks-dimensions-control__header">
827 <div className="components-gblocks-dimensions-control__label">
828 { __( 'Minimum Height', 'generateblocks' ) }
829 </div>
830
831 <div className="components-gblocks-control__units">
832 <ButtonGroup className="components-gblocks-dimensions-control__units" aria-label={ __( 'Select Units' ) }>
833 { minHeightUnits.map( ( unit ) =>
834 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
835 <Tooltip text={ sprintf( __( '%s Units' ), unit.name ) } key={ unit.unitValue }>
836 <Button
837 key={ unit.unitValue }
838 className={ 'components-gblocks-dimensions-control__units--' + unit.name }
839 isSmall
840 isPrimary={ minHeightUnitTablet === unit.unitValue }
841 aria-pressed={ minHeightUnitTablet === unit.unitValue }
842 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
843 aria-label={ sprintf( __( '%s Units' ), unit.name ) }
844 onClick={ () => setAttributes( { minHeightUnitTablet: unit.unitValue } ) }
845 >
846 { unit.unitValue }
847 </Button>
848 </Tooltip>
849 ) }
850 </ButtonGroup>
851 </div>
852 </div>
853
854 <TextControl
855 type={ 'number' }
856 value={ minHeightTablet ? minHeightTablet : '' }
857 onChange={ ( value ) => {
858 setAttributes( {
859 minHeightTablet: parseFloat( value ),
860 } );
861 } }
862 />
863
864 { ( !! minHeight || !! minHeightTablet ) && ! isGrid &&
865 <SelectControl
866 label={ __( 'Vertical Alignment', 'generateblocks' ) }
867 value={ verticalAlignmentTablet }
868 options={ [
869 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
870 { label: __( 'Default', 'generateblocks' ), value: '' },
871 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
872 { label: __( 'Center', 'generateblocks' ), value: 'center' },
873 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
874 ] }
875 onChange={ ( value ) => {
876 setAttributes( {
877 verticalAlignmentTablet: value,
878 } );
879 } }
880 />
881 }
882
883 <DimensionsControl { ...this.props }
884 device={ selectedDevice }
885 type={ 'padding' }
886 label={ __( 'Padding', 'generateblocks' ) }
887 attrTop={ 'paddingTopTablet' }
888 attrRight={ 'paddingRightTablet' }
889 attrBottom={ 'paddingBottomTablet' }
890 attrLeft={ 'paddingLeftTablet' }
891 attrUnit={ 'paddingUnit' }
892 attrSyncUnits={ 'paddingSyncUnits' }
893 defaults={ generateBlocksDefaults.container }
894 />
895
896 <DimensionsControl { ...this.props }
897 device={ selectedDevice }
898 type={ 'margin' }
899 label={ __( 'Margin', 'generateblocks' ) }
900 attrTop={ 'marginTopTablet' }
901 attrRight={ 'marginRightTablet' }
902 attrBottom={ 'marginBottomTablet' }
903 attrLeft={ 'marginLeftTablet' }
904 attrUnit={ 'marginUnit' }
905 attrSyncUnits={ 'marginSyncUnits' }
906 defaults={ generateBlocksDefaults.container }
907 />
908
909 <DimensionsControl { ...this.props }
910 device={ selectedDevice }
911 type={ 'padding' }
912 label={ __( 'Border Size', 'generateblocks' ) }
913 attrTop={ 'borderSizeTopTablet' }
914 attrRight={ 'borderSizeRightTablet' }
915 attrBottom={ 'borderSizeBottomTablet' }
916 attrLeft={ 'borderSizeLeftTablet' }
917 attrSyncUnits={ 'borderSizeSyncUnits' }
918 displayUnit={ 'px' }
919 defaults={ generateBlocksDefaults.container }
920 />
921
922 <DimensionsControl { ...this.props }
923 device={ selectedDevice }
924 type={ 'padding' }
925 label={ __( 'Border Radius', 'generateblocks' ) }
926 attrTop={ 'borderRadiusTopLeftTablet' }
927 attrRight={ 'borderRadiusTopRightTablet' }
928 attrBottom={ 'borderRadiusBottomRightTablet' }
929 attrLeft={ 'borderRadiusBottomLeftTablet' }
930 attrUnit={ 'borderRadiusUnit' }
931 attrSyncUnits={ 'borderRadiusSyncUnits' }
932 labelTop={ __( 'T-Left', 'generateblocks' ) }
933 labelRight={ __( 'T-Right', 'generateblocks' ) }
934 labelBottom={ __( 'B-Right', 'generateblocks' ) }
935 labelLeft={ __( 'B-Left', 'generateblocks' ) }
936 defaults={ generateBlocksDefaults.container }
937 />
938 </Fragment>
939 ) }
940
941 { 'mobile' === selectedDevice && (
942 <Fragment>
943 <div className="components-gblocks-dimensions-control__header">
944 <div className="components-gblocks-dimensions-control__label">
945 { __( 'Minimum Height', 'generateblocks' ) }
946 </div>
947
948 <div className="components-gblocks-control__units">
949 <ButtonGroup className="components-gblocks-dimensions-control__units" aria-label={ __( 'Select Units' ) }>
950 { minHeightUnits.map( ( unit ) =>
951 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
952 <Tooltip text={ sprintf( __( '%s Units' ), unit.name ) } key={ unit.unitValue }>
953 <Button
954 key={ unit.unitValue }
955 className={ 'components-gblocks-dimensions-control__units--' + unit.name }
956 isSmall
957 isPrimary={ minHeightUnitMobile === unit.unitValue }
958 aria-pressed={ minHeightUnitMobile === unit.unitValue }
959 /* translators: %s: values associated with CSS syntax, 'Pixel', 'Em', 'Percentage' */
960 aria-label={ sprintf( __( '%s Units' ), unit.name ) }
961 onClick={ () => setAttributes( { minHeightUnitMobile: unit.unitValue } ) }
962 >
963 { unit.unitValue }
964 </Button>
965 </Tooltip>
966 ) }
967 </ButtonGroup>
968 </div>
969 </div>
970
971 <TextControl
972 type={ 'number' }
973 value={ minHeightMobile ? minHeightMobile : '' }
974 onChange={ ( value ) => {
975 setAttributes( {
976 minHeightMobile: parseFloat( value ),
977 } );
978 } }
979 />
980
981 { ( !! minHeight || !! minHeightTablet || !! minHeightMobile ) && ! isGrid &&
982 <SelectControl
983 label={ __( 'Vertical Alignment', 'generateblocks' ) }
984 value={ verticalAlignmentMobile }
985 options={ [
986 { label: __( 'Inherit', 'generateblocks' ), value: 'inherit' },
987 { label: __( 'Default', 'generateblocks' ), value: '' },
988 { label: __( 'Top', 'generateblocks' ), value: 'flex-start' },
989 { label: __( 'Center', 'generateblocks' ), value: 'center' },
990 { label: __( 'Bottom', 'generateblocks' ), value: 'flex-end' },
991 ] }
992 onChange={ ( value ) => {
993 setAttributes( {
994 verticalAlignmentMobile: value,
995 } );
996 } }
997 />
998 }
999
1000 <DimensionsControl { ...this.props }
1001 device={ selectedDevice }
1002 type={ 'padding' }
1003 label={ __( 'Padding', 'generateblocks' ) }
1004 attrTop={ 'paddingTopMobile' }
1005 attrRight={ 'paddingRightMobile' }
1006 attrBottom={ 'paddingBottomMobile' }
1007 attrLeft={ 'paddingLeftMobile' }
1008 attrUnit={ 'paddingUnit' }
1009 attrSyncUnits={ 'paddingSyncUnits' }
1010 defaults={ generateBlocksDefaults.container }
1011 />
1012
1013 <DimensionsControl { ...this.props }
1014 device={ selectedDevice }
1015 type={ 'margin' }
1016 label={ __( 'Margin', 'generateblocks' ) }
1017 attrTop={ 'marginTopMobile' }
1018 attrRight={ 'marginRightMobile' }
1019 attrBottom={ 'marginBottomMobile' }
1020 attrLeft={ 'marginLeftMobile' }
1021 attrUnit={ 'marginUnit' }
1022 attrSyncUnits={ 'marginSyncUnits' }
1023 defaults={ generateBlocksDefaults.container }
1024 />
1025
1026 <DimensionsControl { ...this.props }
1027 device={ selectedDevice }
1028 type={ 'padding' }
1029 label={ __( 'Border Size', 'generateblocks' ) }
1030 attrTop={ 'borderSizeTopMobile' }
1031 attrRight={ 'borderSizeRightMobile' }
1032 attrBottom={ 'borderSizeBottomMobile' }
1033 attrLeft={ 'borderSizeLeftMobile' }
1034 attrSyncUnits={ 'borderSizeSyncUnits' }
1035 displayUnit={ 'px' }
1036 defaults={ generateBlocksDefaults.container }
1037 />
1038
1039 <DimensionsControl { ...this.props }
1040 device={ selectedDevice }
1041 type={ 'padding' }
1042 label={ __( 'Border Radius', 'generateblocks' ) }
1043 attrTop={ 'borderRadiusTopLeftMobile' }
1044 attrRight={ 'borderRadiusTopRightMobile' }
1045 attrBottom={ 'borderRadiusBottomRightMobile' }
1046 attrLeft={ 'borderRadiusBottomLeftMobile' }
1047 attrUnit={ 'borderRadiusUnit' }
1048 attrSyncUnits={ 'borderRadiusSyncUnits' }
1049 labelTop={ __( 'T-Left', 'generateblocks' ) }
1050 labelRight={ __( 'T-Right', 'generateblocks' ) }
1051 labelBottom={ __( 'B-Right', 'generateblocks' ) }
1052 labelLeft={ __( 'B-Left', 'generateblocks' ) }
1053 defaults={ generateBlocksDefaults.container }
1054 />
1055 </Fragment>
1056 ) }
1057
1058 { applyFilters( 'generateblocks.editor.controls', '', 'containerSpacing', this.props, this.state ) }
1059 </PanelArea>
1060
1061 <PanelArea { ...this.props }
1062 title={ __( 'Colors', 'generateblocks' ) }
1063 initialOpen={ false }
1064 icon={ getIcon( 'colors' ) }
1065 className={ 'gblocks-panel-label' }
1066 id={ 'containerColors' }
1067 state={ this.state }
1068 showPanel={ 'desktop' === selectedDevice || false }
1069 >
1070 <Fragment>
1071 <ColorPicker
1072 label={ __( 'Background Color', 'generateblocks' ) }
1073 value={ backgroundColor }
1074 alpha={ true }
1075 valueOpacity={ backgroundColorOpacity }
1076 attrOpacity={ 'backgroundColorOpacity' }
1077 onChange={ ( nextBackgroundColor ) =>
1078 setAttributes( {
1079 backgroundColor: nextBackgroundColor,
1080 } )
1081 }
1082 onOpacityChange={ ( value ) =>
1083 setAttributes( {
1084 backgroundColorOpacity: value,
1085 } )
1086 }
1087 />
1088
1089 <ColorPicker
1090 label={ __( 'Text Color', 'generateblocks' ) }
1091 value={ textColor }
1092 alpha={ false }
1093 onChange={ ( nextTextColor ) =>
1094 setAttributes( {
1095 textColor: nextTextColor,
1096 } )
1097 }
1098 />
1099
1100 <ColorPicker
1101 label={ __( 'Link Color', 'generateblocks' ) }
1102 value={ linkColor }
1103 alpha={ false }
1104 onChange={ ( nextLinkColor ) =>
1105 setAttributes( {
1106 linkColor: nextLinkColor,
1107 } )
1108 }
1109 />
1110
1111 <ColorPicker
1112 label={ __( 'Link Color Hover', 'generateblocks' ) }
1113 value={ linkColorHover }
1114 alpha={ false }
1115 onChange={ ( nextLinkColorHover ) =>
1116 setAttributes( {
1117 linkColorHover: nextLinkColorHover,
1118 } )
1119 }
1120 />
1121
1122 <ColorPicker
1123 label={ __( 'Border Color', 'generateblocks' ) }
1124 value={ borderColor }
1125 alpha={ true }
1126 valueOpacity={ borderColorOpacity }
1127 attrOpacity={ 'borderColorOpacity' }
1128 onChange={ ( value ) =>
1129 setAttributes( {
1130 borderColor: value,
1131 } )
1132 }
1133 onOpacityChange={ ( value ) =>
1134 setAttributes( {
1135 borderColorOpacity: value,
1136 } )
1137 }
1138 />
1139 </Fragment>
1140
1141 { applyFilters( 'generateblocks.editor.controls', '', 'containerColors', this.props, this.state ) }
1142 </PanelArea>
1143
1144 <PanelArea { ...this.props }
1145 title={ __( 'Background Gradient', 'generateblocks' ) }
1146 initialOpen={ false }
1147 icon={ getIcon( 'gradients' ) }
1148 className={ 'gblocks-panel-label' }
1149 id={ 'containerBackgroundGradient' }
1150 state={ this.state }
1151 showPanel={ 'desktop' === selectedDevice || false }
1152 >
1153 <GradientControl { ...this.props }
1154 attrGradient={ 'gradient' }
1155 attrGradientDirection={ 'gradientDirection' }
1156 attrGradientColorOne={ 'gradientColorOne' }
1157 attrGradientColorStopOne={ 'gradientColorStopOne' }
1158 attrGradientColorTwo={ 'gradientColorTwo' }
1159 attrGradientColorStopTwo={ 'gradientColorStopTwo' }
1160 attrGradientColorOneOpacity={ 'gradientColorOneOpacity' }
1161 attrGradientColorTwoOpacity={ 'gradientColorTwoOpacity' }
1162 defaultColorOne={ generateBlocksDefaults.container.gradientColorOne }
1163 defaultColorTwo={ generateBlocksDefaults.container.gradientColorTwo }
1164 />
1165
1166 { applyFilters( 'generateblocks.editor.controls', '', 'containerBackgroundGradient', this.props, this.state ) }
1167 </PanelArea>
1168
1169 <PanelArea { ...this.props }
1170 title={ __( 'Background Image', 'generateblocks' ) }
1171 initialOpen={ false }
1172 icon={ getIcon( 'backgrounds' ) }
1173 className={ 'gblocks-panel-label' }
1174 id={ 'containerBackgroundImage' }
1175 state={ this.state }
1176 showPanel={ 'desktop' === selectedDevice || false }
1177 >
1178 { ! bgImage && (
1179 <div>
1180 <MediaUpload
1181 title={ __( 'Set background image', 'generateblocks' ) }
1182 onSelect={ onSelectBgImage }
1183 allowedTypes={ [ 'image' ] }
1184 modalClass="editor-post-featured-image__media-modal"
1185 render={ ( { open } ) => (
1186 <Button className="editor-post-featured-image__toggle" onClick={ open }>
1187 { __( 'Set background image', 'generateblocks' ) }
1188 </Button>
1189 ) }
1190 />
1191 </div>
1192 ) }
1193
1194 { !! bgImage && (
1195 <MediaUpload
1196 title={ __( 'Set background image', 'generateblocks' ) }
1197 onSelect={ onSelectBgImage }
1198 allowedTypes={ [ 'image' ] }
1199 value={ bgImage.id }
1200 modalClass="editor-post-featured-image__media-modal"
1201 render={ ( { open } ) => (
1202 <div className="editor-bg-image">
1203 <Button className="editor-post-featured-image__preview" onClick={ open }>
1204 <ResponsiveWrapper
1205 naturalWidth={ bgImage.image.width }
1206 naturalHeight={ bgImage.image.height }
1207 >
1208 <img src={ bgImage.image.url } alt={ __( 'BG Image' ) } />
1209 </ResponsiveWrapper>
1210 </Button>
1211 <div className={ 'edit-bg-buttons' }>
1212 <Button onClick={ open } isDefault isLarge>
1213 { __( 'Replace image' ) }
1214 </Button>
1215 <Button onClick={ onRemoveBgImage } isLink isDestructive>
1216 { __( 'Remove background image', 'generateblocks' ) }
1217 </Button>
1218 </div>
1219 </div>
1220 ) }
1221 />
1222 ) }
1223
1224 { !! bgImage && (
1225 <div className="section-bg-settings">
1226 <ToggleControl
1227 label={ __( 'Background Color Overlay', 'generateblocks' ) }
1228 checked={ !! bgOptions.overlay }
1229 onChange={ ( nextOverlay ) => {
1230 setAttributes( {
1231 bgOptions: {
1232 ...bgOptions,
1233 overlay: nextOverlay,
1234 },
1235 } );
1236 } }
1237 />
1238
1239 { !! bgOptions.overlay && (
1240 <div className="gblocks-notice">
1241 { __( 'Your background color must have transparency for the image to show.', 'generateblocks' ) }
1242 </div>
1243 ) }
1244
1245 <TextControl
1246 label={ __( 'Size', 'generateblocks' ) }
1247 value={ bgOptions.size }
1248 onChange={ ( nextSize ) => {
1249 setAttributes( {
1250 bgOptions: {
1251 ...bgOptions,
1252 size: nextSize,
1253 },
1254 } );
1255 } }
1256 />
1257
1258 <TextControl
1259 label={ __( 'Position', 'generateblocks' ) }
1260 value={ bgOptions.position }
1261 onChange={ ( nextPosition ) => {
1262 setAttributes( {
1263 bgOptions: {
1264 ...bgOptions,
1265 position: nextPosition,
1266 },
1267 } );
1268 } }
1269 />
1270
1271 <SelectControl
1272 label={ __( 'Repeat', 'generateblocks' ) }
1273 value={ bgOptions.repeat }
1274 options={ [
1275 { label: 'no-repeat', value: 'no-repeat' },
1276 { label: 'repeat', value: 'repeat' },
1277 { label: 'repeat-x', value: 'repeat-x' },
1278 { label: 'repeat-y', value: 'repeat-y' },
1279 ] }
1280 onChange={ ( nextRepeat ) => {
1281 setAttributes( {
1282 bgOptions: {
1283 ...bgOptions,
1284 repeat: nextRepeat,
1285 },
1286 } );
1287 } }
1288 />
1289
1290 <SelectControl
1291 label={ __( 'Attachment', 'generateblocks' ) }
1292 value={ bgOptions.attachment }
1293 options={ [
1294 { label: 'scroll', value: '' },
1295 { label: 'fixed', value: 'fixed' },
1296 { label: 'local', value: 'local' },
1297 ] }
1298 onChange={ ( nextAttachment ) => {
1299 setAttributes( {
1300 bgOptions: {
1301 ...bgOptions,
1302 attachment: nextAttachment,
1303 },
1304 } );
1305 } }
1306 />
1307 </div>
1308 ) }
1309
1310 { applyFilters( 'generateblocks.editor.controls', '', 'containerBackgroundImage', this.props, this.state ) }
1311 </PanelArea>
1312
1313 <PanelArea { ...this.props }
1314 title={ __( 'Advanced', 'generateblocks' ) }
1315 initialOpen={ false }
1316 icon={ getIcon( 'advanced' ) }
1317 className={ 'gblocks-panel-label' }
1318 id={ 'containerAdvanced' }
1319 state={ this.state }
1320 showPanel={ 'desktop' === selectedDevice || false }
1321 >
1322 <SelectControl
1323 label={ __( 'Element Tag', 'generateblocks' ) }
1324 value={ tagName }
1325 options={ [
1326 { label: 'div', value: 'div' },
1327 { label: 'section', value: 'section' },
1328 { label: 'header', value: 'header' },
1329 { label: 'footer', value: 'footer' },
1330 ] }
1331 onChange={ ( value ) => {
1332 setAttributes( {
1333 tagName: value,
1334 } );
1335 } }
1336 />
1337
1338 <TextControl
1339 label={ __( 'Element ID', 'generateblocks' ) }
1340 value={ elementId }
1341 onChange={ ( value ) => {
1342 const newElementId = value.replace( ELEMENT_ID_REGEX, '-' );
1343
1344 setAttributes( {
1345 elementId: newElementId,
1346 } );
1347 } }
1348 />
1349
1350 <TextControl
1351 label={ __( 'CSS Classes', 'generateblocks' ) }
1352 value={ cssClasses }
1353 onChange={ ( value ) => {
1354 setAttributes( {
1355 cssClasses: value,
1356 } );
1357 } }
1358 />
1359
1360 <TextControl
1361 label={ __( 'z-index', 'generateblocks' ) }
1362 type={ 'number' }
1363 value={ zindex || 0 === zindex ? zindex : '' }
1364 onChange={ ( value ) => {
1365 setAttributes( {
1366 zindex: value,
1367 } );
1368 } }
1369 onBlur={ () => {
1370 setAttributes( {
1371 zindex: parseFloat( zindex ),
1372 } );
1373 } }
1374 onClick={ ( e ) => {
1375 // Make sure onBlur fires in Firefox.
1376 e.currentTarget.focus();
1377 } }
1378 />
1379
1380 { applyFilters( 'generateblocks.editor.controls', '', 'containerAdvanced', this.props, this.state ) }
1381 </PanelArea>
1382
1383 <PanelArea { ...this.props }
1384 title={ __( 'Documentation', 'generateblocks' ) }
1385 initialOpen={ false }
1386 icon={ getIcon( 'documentation' ) }
1387 className={ 'gblocks-panel-label' }
1388 id={ 'containerDocumentation' }
1389 state={ this.state }
1390 >
1391 <p>{ __( 'Need help with this block?', 'generateblocks' ) }</p>
1392 <a href="https://docs.generateblocks.com/collection/container/" target="_blank" rel="noreferrer noopener">{ __( 'Visit our documentation', 'generateblocks' ) }</a>
1393
1394 { applyFilters( 'generateblocks.editor.controls', '', 'containerDocumentation', this.props, this.state ) }
1395 </PanelArea>
1396 </InspectorControls>
1397
1398 <DesktopCSS { ...this.props } />
1399
1400 { fontFamily && googleFont &&
1401 <link
1402 rel="stylesheet"
1403 href={ 'https://fonts.googleapis.com/css?family=' + fontFamily.replace( / /g, '+' ) + googleFontsAttr }
1404 />
1405 }
1406
1407 { !! isGrid && (
1408 <div className={ classnames( {
1409 'gb-grid-column': true,
1410 [ `gb-grid-column-${ uniqueId }` ]: true,
1411 } ) }>
1412 <Section
1413 tagName={ tagName }
1414 id={ elementId }
1415 className={ classnames( {
1416 'gb-container': true,
1417 [ `gb-container-${ uniqueId }` ]: true,
1418 [ `${ cssClasses }` ]: '' !== cssClasses,
1419 } ) }
1420 >
1421 { applyFilters( 'generateblocks.editor.insideContainerWrapper', '', this.props ) }
1422 <div
1423 className={ classnames( {
1424 'gb-inside-container': true,
1425 } ) }
1426 >
1427 <InnerBlocks
1428 templateLock={ false }
1429 renderAppender={ (
1430 hasChildBlocks ?
1431 undefined :
1432 () => <InnerBlocks.ButtonBlockAppender />
1433 ) }
1434 />
1435 </div>
1436 </Section>
1437 </div>
1438 ) }
1439
1440 { ! isGrid && (
1441 <Section
1442 tagName={ tagName }
1443 id={ elementId }
1444 className={ classnames( {
1445 'gb-container': true,
1446 [ `gb-container-${ uniqueId }` ]: true,
1447 [ `${ cssClasses }` ]: '' !== cssClasses,
1448 } ) }
1449 >
1450 { applyFilters( 'generateblocks.editor.insideContainerWrapper', '', this.props ) }
1451 <div
1452 className={ classnames( {
1453 'gb-inside-container': true,
1454 } ) }
1455 >
1456 <InnerBlocks
1457 templateLock={ false }
1458 renderAppender={ (
1459 hasChildBlocks ?
1460 undefined :
1461 () => <InnerBlocks.ButtonBlockAppender />
1462 ) }
1463 />
1464 </div>
1465 </Section>
1466 ) }
1467
1468 </Fragment>
1469 );
1470 }
1471 }
1472
1473 export default ( GenerateBlockContainer );
1474