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
save.js
54 lines
| 1 | /** |
| 2 | * Block: Container |
| 3 | */ |
| 4 | |
| 5 | import Section from './section-tag'; |
| 6 | import classnames from 'classnames'; |
| 7 | |
| 8 | const { |
| 9 | InnerBlocks, |
| 10 | } = wp.blockEditor; |
| 11 | |
| 12 | const { |
| 13 | applyFilters, |
| 14 | } = wp.hooks; |
| 15 | |
| 16 | export default ( { attributes } ) => { |
| 17 | const { |
| 18 | uniqueId, |
| 19 | tagName, |
| 20 | elementId, |
| 21 | cssClasses, |
| 22 | isGrid, |
| 23 | } = attributes; |
| 24 | |
| 25 | const ConditionalWrap = ( { condition, wrap, children } ) => condition ? wrap( children ) : children; |
| 26 | |
| 27 | return ( |
| 28 | <ConditionalWrap |
| 29 | condition={ isGrid } |
| 30 | wrap={ children => <div className={ classnames( { |
| 31 | 'gb-grid-column': true, |
| 32 | [ `gb-grid-column-${ uniqueId }` ]: true, |
| 33 | } ) }>{ children }</div> } |
| 34 | > |
| 35 | <Section |
| 36 | tagName={ tagName } |
| 37 | id={ elementId } |
| 38 | className={ classnames( { |
| 39 | 'gb-container': true, |
| 40 | [ `gb-container-${ uniqueId }` ]: true, |
| 41 | [ `${ cssClasses }` ]: '' !== cssClasses, |
| 42 | } ) } |
| 43 | > |
| 44 | { applyFilters( 'generateblocks.editor.insideContainerWrapper', '', this.props ) } |
| 45 | <div className={ classnames( { |
| 46 | 'gb-inside-container': true, |
| 47 | } ) }> |
| 48 | <InnerBlocks.Content /> |
| 49 | </div> |
| 50 | </Section> |
| 51 | </ConditionalWrap> |
| 52 | ); |
| 53 | }; |
| 54 |