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 / container / css / tablet.js
generateblocks / src / blocks / container / css Last commit date
desktop.js 5 years ago main.js 4 years ago mobile.js 4 years ago tablet-only.js 5 years ago tablet.js 4 years ago
tablet.js
147 lines
1 /* eslint-disable quotes */
2 import buildCSS from '../../../utils/build-css';
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 isGrid,
24 widthTablet,
25 autoWidthTablet,
26 flexGrowTablet,
27 flexShrinkTablet,
28 flexBasisTablet,
29 flexBasisUnit,
30 minHeightTablet,
31 minHeightUnitTablet,
32 paddingTopTablet,
33 paddingRightTablet,
34 paddingBottomTablet,
35 paddingLeftTablet,
36 paddingUnit,
37 marginTopTablet,
38 marginRightTablet,
39 marginBottomTablet,
40 marginLeftTablet,
41 marginUnit,
42 borderSizeTopTablet,
43 borderSizeRightTablet,
44 borderSizeBottomTablet,
45 borderSizeLeftTablet,
46 borderRadiusTopRightTablet,
47 borderRadiusBottomRightTablet,
48 borderRadiusBottomLeftTablet,
49 borderRadiusTopLeftTablet,
50 borderRadiusUnit,
51 verticalAlignmentTablet,
52 alignmentTablet,
53 fontSizeTablet,
54 fontSizeUnit,
55 orderTablet,
56 shapeDividers,
57 bgImage,
58 bgOptions,
59 } = attributes;
60
61 let cssObj = [];
62 cssObj[ '.gb-container-' + uniqueId ] = [ {
63 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
64 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
65 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
66 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
67 'margin-top': valueWithUnit( marginTopTablet, marginUnit ),
68 'margin-right': valueWithUnit( marginRightTablet, marginUnit ),
69 'margin-bottom': valueWithUnit( marginBottomTablet, marginUnit ),
70 'margin-left': valueWithUnit( marginLeftTablet, marginUnit ),
71 'text-align': alignmentTablet,
72 'font-size': valueWithUnit( fontSizeTablet, fontSizeUnit ),
73 'min-height': valueWithUnit( minHeightTablet, minHeightUnitTablet ),
74 } ];
75
76 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
77 cssObj[ '.gb-container-' + uniqueId ].push( {
78 'border-top-width': valueWithUnit( borderSizeTopTablet, 'px' ),
79 'border-right-width': valueWithUnit( borderSizeRightTablet, 'px' ),
80 'border-bottom-width': valueWithUnit( borderSizeBottomTablet, 'px' ),
81 'border-left-width': valueWithUnit( borderSizeLeftTablet, 'px' ),
82 'border-style': 'solid',
83 } );
84 }
85
86 if ( minHeightTablet && ! isGrid ) {
87 cssObj[ '.gb-container-' + uniqueId ].push( {
88 'display': 'flex', // eslint-disable-line quote-props
89 'flex-direction': 'row',
90 'align-items': 'inherit' !== verticalAlignmentTablet ? verticalAlignmentTablet : null,
91 } );
92 }
93
94 if ( isGrid && 'inherit' !== verticalAlignmentTablet ) {
95 cssObj[ '.gb-container-' + uniqueId ].push( {
96 'display': 'flex', // eslint-disable-line quote-props
97 'flex-direction': 'column',
98 'height': '100%', // eslint-disable-line quote-props
99 'justify-content': verticalAlignmentTablet,
100 } );
101 }
102
103 cssObj[ '.gb-container-' + uniqueId + ' > .gb-inside-container' ] = [ {
104 'padding-top': valueWithUnit( paddingTopTablet, paddingUnit ),
105 'padding-right': valueWithUnit( paddingRightTablet, paddingUnit ),
106 'padding-bottom': valueWithUnit( paddingBottomTablet, paddingUnit ),
107 'padding-left': valueWithUnit( paddingLeftTablet, paddingUnit ),
108 'width': minHeightTablet && ! isGrid ? '100%' : false, // eslint-disable-line quote-props
109 } ];
110
111 cssObj[ '.gb-grid-wrapper > div > .block-editor-block-list__layout > #block-' + clientId ] = [ {
112 width: ! autoWidthTablet ? valueWithUnit( widthTablet, '%' ) : 'auto',
113 'flex-grow': flexGrowTablet,
114 'flex-shrink': flexShrinkTablet,
115 'flex-basis': isNaN( flexBasisTablet ) ? flexBasisTablet : valueWithUnit( flexBasisTablet, flexBasisUnit ),
116 order: orderTablet,
117 } ];
118
119 if ( !! bgImage && 'pseudo-element' === bgOptions.selector ) {
120 cssObj[ '.gb-container-' + uniqueId + ':before' ] = [ {
121 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
122 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
123 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
124 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
125 } ];
126 }
127
128 if ( shapeDividers.length ) {
129 shapeDividers.forEach( ( location, index ) => {
130 const shapeNumber = index + 1;
131
132 cssObj[ '.gb-container-' + uniqueId + ' > .gb-shapes .gb-shape-' + shapeNumber + ' svg' ] = [ {
133 height: valueWithUnit( shapeDividers[ index ].heightTablet, 'px' ),
134 width: valueWithUnit( shapeDividers[ index ].widthTablet, '%' ),
135 } ];
136 } );
137 }
138
139 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'container' );
140
141 return (
142 <style>{ buildCSS( cssObj ) }</style>
143 );
144 }
145 }
146 /* eslint-enable quotes */
147