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