PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.4.0
GenerateBlocks v1.4.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 / headline / css / mobile.js
generateblocks / src / blocks / headline / css Last commit date
desktop.js 5 years ago main.js 5 years ago mobile.js 5 years ago tablet-only.js 5 years ago tablet.js 5 years ago
mobile.js
133 lines
1 import buildCSS from '../../../utils/build-css';
2 import flexboxAlignment from '../../../utils/flexbox-alignment';
3 import valueWithUnit from '../../../utils/value-with-unit';
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 clientId,
19 } = this.props;
20
21 const {
22 uniqueId,
23 element,
24 alignmentMobile,
25 fontSizeMobile,
26 fontSizeUnit,
27 lineHeightMobile,
28 lineHeightUnit,
29 letterSpacingMobile,
30 marginTopMobile,
31 marginRightMobile,
32 marginBottomMobile,
33 marginLeftMobile,
34 marginUnit,
35 paddingTopMobile,
36 paddingRightMobile,
37 paddingBottomMobile,
38 paddingLeftMobile,
39 paddingUnit,
40 borderSizeTopMobile,
41 borderSizeRightMobile,
42 borderSizeBottomMobile,
43 borderSizeLeftMobile,
44 borderRadiusTopRightMobile,
45 borderRadiusBottomRightMobile,
46 borderRadiusBottomLeftMobile,
47 borderRadiusTopLeftMobile,
48 borderRadiusUnit,
49 icon,
50 iconLocationMobile,
51 iconVerticalAlignmentMobile,
52 iconPaddingTopMobile,
53 iconPaddingRightMobile,
54 iconPaddingBottomMobile,
55 iconPaddingLeftMobile,
56 iconPaddingUnit,
57 iconSizeMobile,
58 iconSizeUnit,
59 inlineWidthMobile,
60 removeText,
61 } = attributes;
62
63 const selector = element + '.gb-headline-' + uniqueId;
64 let inlineWidthValue = 'inline-block';
65 let cssObj = [];
66
67 cssObj[ '.editor-styles-wrapper ' + selector ] = [ {
68 'text-align': alignmentMobile,
69 'font-size': valueWithUnit( fontSizeMobile, fontSizeUnit ),
70 'line-height': valueWithUnit( lineHeightMobile, lineHeightUnit ),
71 'letter-spacing': valueWithUnit( letterSpacingMobile, 'em' ),
72 display: !! icon ? 'flex' : false,
73 'align-items': 'inline' === iconLocationMobile ? flexboxAlignment( iconVerticalAlignmentMobile ) : flexboxAlignment( alignmentMobile ),
74 'justify-content': flexboxAlignment( alignmentMobile ),
75 'flex-direction': icon && 'above' === iconLocationMobile ? 'column' : false,
76 'margin-top': valueWithUnit( marginTopMobile, marginUnit ) + ' !important',
77 'margin-right': valueWithUnit( marginRightMobile, marginUnit ) + ' !important',
78 'margin-bottom': valueWithUnit( marginBottomMobile, marginUnit ) + ' !important',
79 'margin-left': valueWithUnit( marginLeftMobile, marginUnit ) + ' !important',
80 'padding-top': valueWithUnit( paddingTopMobile, paddingUnit ),
81 'padding-right': valueWithUnit( paddingRightMobile, paddingUnit ),
82 'padding-bottom': valueWithUnit( paddingBottomMobile, paddingUnit ),
83 'padding-left': valueWithUnit( paddingLeftMobile, paddingUnit ),
84 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftMobile, borderRadiusUnit ),
85 'border-top-right-radius': valueWithUnit( borderRadiusTopRightMobile, borderRadiusUnit ),
86 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightMobile, borderRadiusUnit ),
87 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftMobile, borderRadiusUnit ),
88 } ];
89
90 if ( icon ) {
91 inlineWidthValue = 'inline-flex';
92
93 cssObj[ '.editor-styles-wrapper ' + selector ].push( {
94 'display': inlineWidthMobile ? inlineWidthValue : false, // eslint-disable-line quote-props
95 } );
96 }
97
98 if ( borderSizeTopMobile || borderSizeRightMobile || borderSizeBottomMobile || borderSizeLeftMobile ) {
99 cssObj[ '.editor-styles-wrapper ' + selector ].push( {
100 'border-top-width': valueWithUnit( borderSizeTopMobile, 'px' ),
101 'border-right-width': valueWithUnit( borderSizeRightMobile, 'px' ),
102 'border-bottom-width': valueWithUnit( borderSizeBottomMobile, 'px' ),
103 'border-left-width': valueWithUnit( borderSizeLeftMobile, 'px' ),
104 'border-style': 'solid',
105 } );
106 }
107
108 cssObj[ selector + ' .gb-icon' ] = [ {
109 'padding-top': ! removeText ? valueWithUnit( iconPaddingTopMobile, iconPaddingUnit ) : false,
110 'padding-right': ! removeText ? valueWithUnit( iconPaddingRightMobile, iconPaddingUnit ) : false,
111 'padding-bottom': ! removeText ? valueWithUnit( iconPaddingBottomMobile, iconPaddingUnit ) : false,
112 'padding-left': ! removeText ? valueWithUnit( iconPaddingLeftMobile, iconPaddingUnit ) : false,
113 'align-self': icon && 'above' === iconLocationMobile ? flexboxAlignment( alignmentMobile ) : false,
114 'display': icon && 'above' === iconLocationMobile ? 'inline' : false, // eslint-disable-line quote-props
115 } ];
116
117 cssObj[ selector + ' .gb-icon svg' ] = [ {
118 'width': valueWithUnit( iconSizeMobile, iconSizeUnit ), // eslint-disable-line quote-props
119 'height': valueWithUnit( iconSizeMobile, iconSizeUnit ), // eslint-disable-line quote-props
120 } ];
121
122 cssObj[ '#block-' + clientId ] = [ {
123 'display': inlineWidthMobile ? 'inline-flex' : false, // eslint-disable-line quote-props
124 } ];
125
126 cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, this.props, 'headline' );
127
128 return (
129 <style>{ buildCSS( cssObj ) }</style>
130 );
131 }
132 }
133