desktop.js
5 years ago
main.js
5 years ago
mobile.js
5 years ago
tablet-only.js
5 years ago
tablet.js
5 years ago
main.js
46 lines
| 1 | import buildCSS from '../../../utils/build-css'; |
| 2 | import valueWithUnit from '../../../utils/value-with-unit'; |
| 3 | |
| 4 | import { |
| 5 | Component, |
| 6 | } from '@wordpress/element'; |
| 7 | |
| 8 | import { |
| 9 | applyFilters, |
| 10 | } from '@wordpress/hooks'; |
| 11 | |
| 12 | export default class MainCSS extends Component { |
| 13 | render() { |
| 14 | const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props ); |
| 15 | |
| 16 | const { |
| 17 | uniqueId, |
| 18 | horizontalGap, |
| 19 | verticalGap, |
| 20 | verticalAlignment, |
| 21 | horizontalAlignment, |
| 22 | } = attributes; |
| 23 | |
| 24 | let cssObj = []; |
| 25 | |
| 26 | cssObj[ '.gb-grid-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout' ] = [ { |
| 27 | 'align-items': verticalAlignment, |
| 28 | 'justify-content': horizontalAlignment, |
| 29 | 'margin-left': '-' + ( horizontalGap / 2 ) + 'px', |
| 30 | 'margin-right': '-' + ( horizontalGap / 2 ) + 'px', |
| 31 | } ]; |
| 32 | |
| 33 | cssObj[ '.gb-grid-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ { |
| 34 | 'padding-left': ( horizontalGap / 2 ) + 'px', |
| 35 | 'padding-right': ( horizontalGap / 2 ) + 'px', |
| 36 | 'margin-bottom': valueWithUnit( verticalGap, 'px' ), |
| 37 | } ]; |
| 38 | |
| 39 | cssObj = applyFilters( 'generateblocks.editor.mainCSS', cssObj, this.props, 'grid' ); |
| 40 | |
| 41 | return ( |
| 42 | <style>{ buildCSS( cssObj ) }</style> |
| 43 | ); |
| 44 | } |
| 45 | } |
| 46 |