PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.3.0
GenerateBlocks v1.3.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 5 years ago mobile.js 5 years ago tablet-only.js 5 years ago tablet.js 5 years ago
tablet.js
126 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 minHeightTablet,
26 minHeightUnitTablet,
27 paddingTopTablet,
28 paddingRightTablet,
29 paddingBottomTablet,
30 paddingLeftTablet,
31 paddingUnit,
32 marginTopTablet,
33 marginRightTablet,
34 marginBottomTablet,
35 marginLeftTablet,
36 marginUnit,
37 borderSizeTopTablet,
38 borderSizeRightTablet,
39 borderSizeBottomTablet,
40 borderSizeLeftTablet,
41 borderRadiusTopRightTablet,
42 borderRadiusBottomRightTablet,
43 borderRadiusBottomLeftTablet,
44 borderRadiusTopLeftTablet,
45 borderRadiusUnit,
46 verticalAlignmentTablet,
47 alignmentTablet,
48 fontSizeTablet,
49 fontSizeUnit,
50 shapeDividers,
51 } = attributes;
52
53 let cssObj = [];
54 cssObj[ '.gb-container-' + uniqueId ] = [ {
55 'border-top-left-radius': valueWithUnit( borderRadiusTopLeftTablet, borderRadiusUnit ),
56 'border-top-right-radius': valueWithUnit( borderRadiusTopRightTablet, borderRadiusUnit ),
57 'border-bottom-right-radius': valueWithUnit( borderRadiusBottomRightTablet, borderRadiusUnit ),
58 'border-bottom-left-radius': valueWithUnit( borderRadiusBottomLeftTablet, borderRadiusUnit ),
59 'margin-top': valueWithUnit( marginTopTablet, marginUnit ),
60 'margin-right': valueWithUnit( marginRightTablet, marginUnit ),
61 'margin-bottom': valueWithUnit( marginBottomTablet, marginUnit ),
62 'margin-left': valueWithUnit( marginLeftTablet, marginUnit ),
63 'text-align': alignmentTablet,
64 'font-size': valueWithUnit( fontSizeTablet, fontSizeUnit ),
65 'min-height': valueWithUnit( minHeightTablet, minHeightUnitTablet ),
66 } ];
67
68 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
69 cssObj[ '.gb-container-' + uniqueId ].push( {
70 'border-top-width': valueWithUnit( borderSizeTopTablet, 'px' ),
71 'border-right-width': valueWithUnit( borderSizeRightTablet, 'px' ),
72 'border-bottom-width': valueWithUnit( borderSizeBottomTablet, 'px' ),
73 'border-left-width': valueWithUnit( borderSizeLeftTablet, 'px' ),
74 'border-style': 'solid',
75 } );
76 }
77
78 if ( minHeightTablet && ! isGrid ) {
79 cssObj[ '.gb-container-' + uniqueId ].push( {
80 'display': 'flex', // eslint-disable-line quote-props
81 'flex-direction': 'row',
82 'align-items': 'inherit' !== verticalAlignmentTablet ? verticalAlignmentTablet : null,
83 } );
84 }
85
86 if ( isGrid && 'inherit' !== verticalAlignmentTablet ) {
87 cssObj[ '.gb-container-' + uniqueId ].push( {
88 'display': 'flex', // eslint-disable-line quote-props
89 'flex-direction': 'column',
90 'height': '100%', // eslint-disable-line quote-props
91 'justify-content': verticalAlignmentTablet,
92 } );
93 }
94
95 cssObj[ '.gb-container-' + uniqueId + ' > .gb-inside-container' ] = [ {
96 'padding-top': valueWithUnit( paddingTopTablet, paddingUnit ),
97 'padding-right': valueWithUnit( paddingRightTablet, paddingUnit ),
98 'padding-bottom': valueWithUnit( paddingBottomTablet, paddingUnit ),
99 'padding-left': valueWithUnit( paddingLeftTablet, paddingUnit ),
100 'width': minHeightTablet && ! isGrid ? '100%' : false, // eslint-disable-line quote-props
101 } ];
102
103 cssObj[ '.gb-grid-wrapper > div > .block-editor-block-list__layout > #block-' + clientId ] = [ {
104 'width': valueWithUnit( widthTablet, '%' ), // eslint-disable-line quote-props
105 } ];
106
107 if ( shapeDividers.length ) {
108 shapeDividers.forEach( ( location, index ) => {
109 const shapeNumber = index + 1;
110
111 cssObj[ '.gb-container-' + uniqueId + ' > .gb-shapes .gb-shape-' + shapeNumber + ' svg' ] = [ {
112 height: valueWithUnit( shapeDividers[ index ].heightTablet, 'px' ),
113 width: valueWithUnit( shapeDividers[ index ].widthTablet, '%' ),
114 } ];
115 } );
116 }
117
118 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'container' );
119
120 return (
121 <style>{ buildCSS( cssObj ) }</style>
122 );
123 }
124 }
125 /* eslint-enable quotes */
126