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 / tablet.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
tablet.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 TabletCSS 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 alignmentTablet,
25 fontSizeTablet,
26 fontSizeUnit,
27 lineHeightTablet,
28 lineHeightUnit,
29 letterSpacingTablet,
30 marginTopTablet,
31 marginRightTablet,
32 marginBottomTablet,
33 marginLeftTablet,
34 marginUnit,
35 paddingTopTablet,
36 paddingRightTablet,
37 paddingBottomTablet,
38 paddingLeftTablet,
39 paddingUnit,
40 borderSizeTopTablet,
41 borderSizeRightTablet,
42 borderSizeBottomTablet,
43 borderSizeLeftTablet,
44 borderRadiusTopRightTablet,
45 borderRadiusBottomRightTablet,
46 borderRadiusBottomLeftTablet,
47 borderRadiusTopLeftTablet,
48 borderRadiusUnit,
49 icon,
50 iconLocationTablet,
51 iconVerticalAlignmentTablet,
52 iconPaddingTopTablet,
53 iconPaddingRightTablet,
54 iconPaddingBottomTablet,
55 iconPaddingLeftTablet,
56 iconPaddingUnit,
57 iconSizeTablet,
58 iconSizeUnit,
59 inlineWidthTablet,
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': alignmentTablet,
69 'font-size': valueWithUnit( fontSizeTablet, fontSizeUnit ),
70 'line-height': valueWithUnit( lineHeightTablet, lineHeightUnit ),
71 'letter-spacing': valueWithUnit( letterSpacingTablet, 'em' ),
72 display: !! icon ? 'flex' : false,
73 'align-items': 'inline' === iconLocationTablet ? flexboxAlignment( iconVerticalAlignmentTablet ) : flexboxAlignment( alignmentTablet ),
74 'justify-content': flexboxAlignment( alignmentTablet ),
75 'flex-direction': icon && 'above' === iconLocationTablet ? 'column' : false,
76 'margin-top': valueWithUnit( marginTopTablet, marginUnit ) + ' !important',
77 'margin-right': valueWithUnit( marginRightTablet, marginUnit ) + ' !important',
78 'margin-bottom': valueWithUnit( marginBottomTablet, marginUnit ) + ' !important',
79 'margin-left': valueWithUnit( marginLeftTablet, marginUnit ) + ' !important',
80 'padding-top': valueWithUnit( paddingTopTablet, paddingUnit ),
81 'padding-right': valueWithUnit( paddingRightTablet, paddingUnit ),
82 'padding-bottom': valueWithUnit( paddingBottomTablet, paddingUnit ),
83 'padding-left': valueWithUnit( paddingLeftTablet, paddingUnit ),
84 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
85 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
86 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
87 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
88 } ];
89
90 if ( icon ) {
91 inlineWidthValue = 'inline-flex';
92
93 cssObj[ '.editor-styles-wrapper ' + selector ].push( {
94 'display': inlineWidthTablet ? inlineWidthValue : false, // eslint-disable-line quote-props
95 } );
96 }
97
98 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
99 cssObj[ '.editor-styles-wrapper ' + selector ].push( {
100 'border-top-width': valueWithUnit( borderSizeTopTablet, 'px' ),
101 'border-right-width': valueWithUnit( borderSizeRightTablet, 'px' ),
102 'border-bottom-width': valueWithUnit( borderSizeBottomTablet, 'px' ),
103 'border-left-width': valueWithUnit( borderSizeLeftTablet, 'px' ),
104 'border-style': 'solid',
105 } );
106 }
107
108 cssObj[ selector + ' .gb-icon' ] = [ {
109 'padding-top': ! removeText ? valueWithUnit( iconPaddingTopTablet, iconPaddingUnit ) : false,
110 'padding-right': ! removeText ? valueWithUnit( iconPaddingRightTablet, iconPaddingUnit ) : false,
111 'padding-bottom': ! removeText ? valueWithUnit( iconPaddingBottomTablet, iconPaddingUnit ) : false,
112 'padding-left': ! removeText ? valueWithUnit( iconPaddingLeftTablet, iconPaddingUnit ) : false,
113 'align-self': icon && 'above' === iconLocationTablet ? flexboxAlignment( alignmentTablet ) : false,
114 'display': icon && 'above' === iconLocationTablet ? 'inline' : false, // eslint-disable-line quote-props
115 } ];
116
117 cssObj[ selector + ' .gb-icon svg' ] = [ {
118 'width': valueWithUnit( iconSizeTablet, iconSizeUnit ), // eslint-disable-line quote-props
119 'height': valueWithUnit( iconSizeTablet, iconSizeUnit ), // eslint-disable-line quote-props
120 } ];
121
122 cssObj[ '#block-' + clientId ] = [ {
123 'display': inlineWidthTablet ? 'inline-flex' : false, // eslint-disable-line quote-props
124 } ];
125
126 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'text' );
127
128 return (
129 <style>{ buildCSS( cssObj ) }</style>
130 );
131 }
132 }
133