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
desktop.js
62 lines
| 1 | import buildCSS from '../../../utils/build-css'; |
| 2 | import flexboxAlignment from '../../../utils/flexbox-alignment'; |
| 3 | |
| 4 | import { |
| 5 | Component, |
| 6 | } from '@wordpress/element'; |
| 7 | |
| 8 | import { |
| 9 | applyFilters, |
| 10 | } from '@wordpress/hooks'; |
| 11 | |
| 12 | export default class DesktopCSS extends Component { |
| 13 | render() { |
| 14 | const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props ); |
| 15 | |
| 16 | const { |
| 17 | uniqueId, |
| 18 | alignment, |
| 19 | stack, |
| 20 | fillHorizontalSpace, |
| 21 | } = attributes; |
| 22 | |
| 23 | let cssObj = []; |
| 24 | |
| 25 | cssObj[ '.gb-button-wrapper-' + uniqueId ] = [ { |
| 26 | display: fillHorizontalSpace ? 'block' : false, |
| 27 | 'flex-direction': stack ? 'column' : false, |
| 28 | 'align-items': stack ? flexboxAlignment( alignment ) : false, |
| 29 | } ]; |
| 30 | |
| 31 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout' ] = [ { |
| 32 | 'flex-direction': stack ? 'column' : false, |
| 33 | 'align-items': stack ? flexboxAlignment( alignment ) : false, |
| 34 | } ]; |
| 35 | |
| 36 | if ( fillHorizontalSpace ) { |
| 37 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ { |
| 38 | flex: '1', |
| 39 | } ]; |
| 40 | |
| 41 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .components-button' ] = [ { |
| 42 | background: '#fff', |
| 43 | border: '1px solid #ddd', |
| 44 | 'margin-top': '10px', |
| 45 | } ]; |
| 46 | } |
| 47 | |
| 48 | if ( stack && fillHorizontalSpace ) { |
| 49 | cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ { |
| 50 | width: '100% !important', |
| 51 | 'box-sizing': 'border-box', |
| 52 | } ]; |
| 53 | } |
| 54 | |
| 55 | cssObj = applyFilters( 'generateblocks.editor.desktopCSS', cssObj, this.props, 'button-container' ); |
| 56 | |
| 57 | return ( |
| 58 | <style>{ buildCSS( cssObj ) }</style> |
| 59 | ); |
| 60 | } |
| 61 | } |
| 62 |