desktop.js
5 years ago
main.js
3 years ago
mobile.js
3 years ago
tablet-only.js
5 years ago
tablet.js
3 years ago
tablet.js
55 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 TabletCSS extends Component { |
| 13 | render() { |
| 14 | const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props ); |
| 15 | |
| 16 | const { |
| 17 | uniqueId, |
| 18 | horizontalGapTablet, |
| 19 | verticalGapTablet, |
| 20 | verticalAlignmentTablet, |
| 21 | horizontalAlignmentTablet, |
| 22 | isQueryLoop, |
| 23 | useLegacyRowGap, |
| 24 | } = attributes; |
| 25 | |
| 26 | let cssObj = []; |
| 27 | |
| 28 | const gridSelector = isQueryLoop |
| 29 | ? '.gb-post-template-' + uniqueId + ' > .gb-post-template-wrapper' |
| 30 | : '.gb-grid-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout'; |
| 31 | |
| 32 | const gridItemSelector = isQueryLoop |
| 33 | ? gridSelector + ' > .block-editor-inner-blocks' |
| 34 | : gridSelector + ' > .gb-grid-column'; |
| 35 | |
| 36 | cssObj[ gridSelector ] = [ { |
| 37 | 'align-items': 'inherit' !== verticalAlignmentTablet ? verticalAlignmentTablet : null, |
| 38 | 'justify-content': 'inherit' !== horizontalAlignmentTablet ? horizontalAlignmentTablet : null, |
| 39 | 'margin-left': horizontalGapTablet || 0 === horizontalGapTablet ? '-' + horizontalGapTablet + 'px' : null, |
| 40 | 'row-gap': ! useLegacyRowGap && ( verticalGapTablet || 0 === verticalGapTablet ) ? valueWithUnit( verticalGapTablet, 'px' ) : null, |
| 41 | } ]; |
| 42 | |
| 43 | cssObj[ gridItemSelector ] = [ { |
| 44 | 'padding-left': valueWithUnit( horizontalGapTablet, 'px' ), |
| 45 | 'margin-bottom': !! useLegacyRowGap && ( verticalGapTablet || 0 === verticalGapTablet ) ? valueWithUnit( verticalGapTablet, 'px' ) : null, |
| 46 | } ]; |
| 47 | |
| 48 | cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'grid' ); |
| 49 | |
| 50 | return ( |
| 51 | <style>{ buildCSS( cssObj ) }</style> |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 |