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