PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.7.2
GenerateBlocks v1.7.2
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 / css / mobile.js
generateblocks / src / blocks / button / css Last commit date
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
mobile.js
103 lines
1 /* eslint-disable quotes */
2 import buildCSS from '../../../utils/build-css';
3 import valueWithUnit from '../../../utils/value-with-unit';
4 import LayoutCSS from '../../../extend/inspector-control/controls/layout/components/LayoutCSS';
5 import SizingCSS from '../../../extend/inspector-control/controls/sizing/components/SizingCSS';
6 import FlexChildCSS from '../../../extend/inspector-control/controls/flex-child-panel/components/FlexChildCSS';
7 import SpacingCSS from '../../../extend/inspector-control/controls/spacing/components/SpacingCSS';
8
9 import {
10 Component,
11 } from '@wordpress/element';
12
13 import {
14 applyFilters,
15 } from '@wordpress/hooks';
16
17 export default class MobileCSS extends Component {
18 render() {
19 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props );
20
21 const {
22 uniqueId,
23 removeText,
24 letterSpacingMobile,
25 fontSizeMobile,
26 fontSizeUnit,
27 paddingTopMobile,
28 paddingRightMobile,
29 paddingBottomMobile,
30 paddingLeftMobile,
31 paddingUnit,
32 borderSizeTopMobile,
33 borderSizeRightMobile,
34 borderSizeBottomMobile,
35 borderSizeLeftMobile,
36 borderRadiusTopRightMobile,
37 borderRadiusBottomRightMobile,
38 borderRadiusBottomLeftMobile,
39 borderRadiusTopLeftMobile,
40 borderRadiusUnit,
41 iconPaddingTopMobile,
42 iconPaddingRightMobile,
43 iconPaddingBottomMobile,
44 iconPaddingLeftMobile,
45 iconPaddingUnit,
46 iconSizeMobile,
47 iconSizeUnit,
48 hasButtonContainer,
49 alignmentMobile,
50 } = attributes;
51
52 const containerSelector = !! hasButtonContainer ? '.gb-button-wrapper ' : '';
53 let selector = '.gb-button-' + uniqueId;
54 selector = '.editor-styles-wrapper ' + containerSelector + selector;
55
56 let cssObj = [];
57
58 cssObj[ selector ] = [ {
59 'padding-top': valueWithUnit( paddingTopMobile, paddingUnit ),
60 'padding-right': valueWithUnit( paddingRightMobile, paddingUnit ),
61 'padding-bottom': valueWithUnit( paddingBottomMobile, paddingUnit ),
62 'padding-left': valueWithUnit( paddingLeftMobile, paddingUnit ),
63 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftMobile, borderRadiusUnit ),
64 'border-top-right-radius': valueWithUnit( borderRadiusTopRightMobile, borderRadiusUnit ),
65 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightMobile, borderRadiusUnit ),
66 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftMobile, borderRadiusUnit ),
67 'font-size': valueWithUnit( fontSizeMobile, fontSizeUnit ),
68 'letter-spacing': valueWithUnit( letterSpacingMobile, 'em' ),
69 'text-align': alignmentMobile,
70 } ];
71
72 SpacingCSS( cssObj, selector, attributes, 'Mobile' );
73 LayoutCSS( cssObj, selector, attributes, 'Mobile' );
74 SizingCSS( cssObj, selector, attributes, 'Mobile' );
75 FlexChildCSS( cssObj, selector, attributes, 'Mobile' );
76
77 if ( borderSizeTopMobile || borderSizeRightMobile || borderSizeBottomMobile || borderSizeLeftMobile ) {
78 cssObj[ selector ].push( {
79 'border-top-width': valueWithUnit( borderSizeTopMobile, 'px' ),
80 'border-right-width': valueWithUnit( borderSizeRightMobile, 'px' ),
81 'border-bottom-width': valueWithUnit( borderSizeBottomMobile, 'px' ),
82 'border-left-width': valueWithUnit( borderSizeLeftMobile, 'px' ),
83 'border-style': 'solid',
84 } );
85 }
86
87 cssObj[ selector + ' .gb-icon' ] = [ {
88 'padding-top': ! removeText ? valueWithUnit( iconPaddingTopMobile, iconPaddingUnit ) : false,
89 'padding-right': ! removeText ? valueWithUnit( iconPaddingRightMobile, iconPaddingUnit ) : false,
90 'padding-bottom': ! removeText ? valueWithUnit( iconPaddingBottomMobile, iconPaddingUnit ) : false,
91 'padding-left': ! removeText ? valueWithUnit( iconPaddingLeftMobile, iconPaddingUnit ) : false,
92 'font-size': valueWithUnit( iconSizeMobile, iconSizeUnit ),
93 } ];
94
95 cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, this.props, 'button' );
96
97 return (
98 <style>{ buildCSS( cssObj ) }</style>
99 );
100 }
101 }
102 /* eslint-enable quotes */
103