PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.0
GenerateBlocks v1.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / button-container / css / desktop.js
generateblocks / src / blocks / button-container / css Last commit date
desktop.js 6 years ago
desktop.js
66 lines
1 import buildCSS from '../../../utils/build-css';
2 import shorthandCSS from '../../../utils/shorthand-css';
3 import flexboxAlignment from '../../../utils/flexbox-alignment';
4
5 const { Component } = wp.element;
6 const { applyFilters } = wp.hooks;
7
8 export default class DesktopCSS extends Component {
9 render() {
10 const {
11 attributes,
12 } = this.props;
13
14 const {
15 uniqueId,
16 alignment,
17 marginTop,
18 marginRight,
19 marginBottom,
20 marginLeft,
21 marginUnit,
22 stack,
23 fillHorizontalSpace,
24 } = attributes;
25
26 let cssObj = [];
27
28 cssObj[ '.gb-button-wrapper-' + uniqueId ] = [ {
29 'display': fillHorizontalSpace ? 'block' : false, // eslint-disable-line quote-props
30 'margin': shorthandCSS( marginTop, marginRight, marginBottom, marginLeft, marginUnit ), // eslint-disable-line quote-props
31 'justify-content': flexboxAlignment( alignment ),
32 'flex-direction': stack ? 'column' : false,
33 'align-items': stack ? flexboxAlignment( alignment ) : false,
34 } ];
35
36 cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout' ] = [ {
37 'flex-direction': stack ? 'column' : false,
38 } ];
39
40 if ( fillHorizontalSpace ) {
41 cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ {
42 'flex': '1', // eslint-disable-line quote-props
43 } ];
44
45 cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .components-button' ] = [ {
46 'background': '#fff', // eslint-disable-line quote-props
47 'border': '1px solid #ddd', // eslint-disable-line quote-props
48 'margin-top': '10px',
49 } ];
50 }
51
52 if ( stack && fillHorizontalSpace ) {
53 cssObj[ '.gb-button-wrapper-' + uniqueId + ' > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block' ] = [ {
54 'width': '100% !important', // eslint-disable-line quote-props
55 'box-sizing': 'border-box',
56 } ];
57 }
58
59 cssObj = applyFilters( 'generateblocks.editor.desktopCSS', cssObj, 'button-container', this.props );
60
61 return (
62 <style>{ buildCSS( cssObj ) }</style>
63 );
64 }
65 }
66