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