desktop.js
4 years ago
main.js
4 years ago
mobile.js
4 years ago
tablet-only.js
4 years ago
tablet.js
4 years ago
mobile.js
74 lines
| 1 | import buildCSS from '../../../utils/build-css'; |
| 2 | import valueWithUnit from '../../../utils/value-with-unit'; |
| 3 | import flexboxAlignment from '../../../utils/flexbox-alignment'; |
| 4 | |
| 5 | import { |
| 6 | Component, |
| 7 | } from '@wordpress/element'; |
| 8 | |
| 9 | import { |
| 10 | applyFilters, |
| 11 | } from '@wordpress/hooks'; |
| 12 | |
| 13 | export default class MobileCSS extends Component { |
| 14 | render() { |
| 15 | const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props ); |
| 16 | |
| 17 | const { |
| 18 | uniqueId, |
| 19 | alignmentMobile, |
| 20 | marginTopMobile, |
| 21 | marginRightMobile, |
| 22 | marginBottomMobile, |
| 23 | marginLeftMobile, |
| 24 | marginUnit, |
| 25 | stackMobile, |
| 26 | fillHorizontalSpaceMobile, |
| 27 | } = attributes; |
| 28 | |
| 29 | let cssObj = []; |
| 30 | |
| 31 | cssObj[ '.gb-button-wrapper-' + uniqueId ] = [ { |
| 32 | 'display': fillHorizontalSpaceMobile ? 'block' : false, // eslint-disable-line quote-props |
| 33 | 'margin-top': valueWithUnit( marginTopMobile, marginUnit ), |
| 34 | 'margin-right': valueWithUnit( marginRightMobile, marginUnit ), |
| 35 | 'margin-bottom': valueWithUnit( marginBottomMobile, marginUnit ), |
| 36 | 'margin-left': valueWithUnit( marginLeftMobile, marginUnit ), |
| 37 | 'justify-content': flexboxAlignment( alignmentMobile ), |
| 38 | 'flex-direction': stackMobile ? 'column' : false, |
| 39 | 'align-items': stackMobile ? flexboxAlignment( alignmentMobile ) : false, |
| 40 | } ]; |
| 41 | |
| 42 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout' ] = [ { |
| 43 | 'flex-direction': stackMobile ? 'column' : false, |
| 44 | 'align-items': stackMobile ? flexboxAlignment( alignmentMobile ) : false, |
| 45 | 'justify-content': flexboxAlignment( alignmentMobile ), |
| 46 | } ]; |
| 47 | |
| 48 | if ( fillHorizontalSpaceMobile ) { |
| 49 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ { |
| 50 | 'flex': '1', // eslint-disable-line quote-props |
| 51 | } ]; |
| 52 | |
| 53 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .components-button' ] = [ { |
| 54 | 'background': '#fff', // eslint-disable-line quote-props |
| 55 | 'border': '1px solid #ddd', // eslint-disable-line quote-props |
| 56 | 'margin-top': '10px', |
| 57 | } ]; |
| 58 | } |
| 59 | |
| 60 | if ( stackMobile && fillHorizontalSpaceMobile ) { |
| 61 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ { |
| 62 | 'width': '100% !important', // eslint-disable-line quote-props |
| 63 | 'box-sizing': 'border-box', |
| 64 | } ]; |
| 65 | } |
| 66 | |
| 67 | cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, this.props, 'button-container' ); |
| 68 | |
| 69 | return ( |
| 70 | <style>{ buildCSS( cssObj ) }</style> |
| 71 | ); |
| 72 | } |
| 73 | } |
| 74 |