PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.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 4 years ago main.js 2 years ago mobile.js 2 years ago tablet-only.js 4 years ago tablet.js 2 years ago
tablet.js
133 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 import TypographyCSS from '../../../extend/inspector-control/controls/typography/components/TypographyCSS';
9
10 import {
11 Component,
12 } from '@wordpress/element';
13
14 import {
15 applyFilters,
16 } from '@wordpress/hooks';
17 import sizingValue from '../../../utils/sizingValue';
18 import BorderCSS from '../../../extend/inspector-control/controls/borders/BorderCSS';
19
20 export default class TabletCSS extends Component {
21 render() {
22 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', this.props.attributes, this.props );
23
24 const {
25 uniqueId,
26 isGrid,
27 flexGrowTablet,
28 flexShrinkTablet,
29 flexBasisTablet,
30 verticalAlignmentTablet,
31 orderTablet,
32 shapeDividers,
33 bgImage,
34 bgOptions,
35 gridId,
36 useInnerContainer,
37 sizing,
38 } = attributes;
39
40 const {
41 paddingTopTablet,
42 paddingRightTablet,
43 paddingBottomTablet,
44 paddingLeftTablet,
45 } = attributes.spacing;
46
47 const {
48 borderTopLeftRadiusTablet,
49 borderTopRightRadiusTablet,
50 borderBottomRightRadiusTablet,
51 borderBottomLeftRadiusTablet,
52 } = attributes.borders;
53
54 let cssObj = [];
55
56 TypographyCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, attributes.typography, 'Tablet' );
57 SpacingCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, { ...attributes.spacing, useInnerContainer }, 'Tablet' );
58 BorderCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, attributes.borders, 'Tablet' );
59 SizingCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, attributes, 'Tablet' );
60 LayoutCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, attributes, 'Tablet' );
61 FlexChildCSS( cssObj, '.editor-styles-wrapper .gb-container-' + uniqueId, attributes, 'Tablet' );
62
63 if ( useInnerContainer ) {
64 cssObj[ '.gb-container-' + uniqueId + ' > .gb-inside-container' ] = [ {
65 'padding-top': paddingTopTablet,
66 'padding-right': paddingRightTablet,
67 'padding-bottom': paddingBottomTablet,
68 'padding-left': paddingLeftTablet,
69 'width': sizingValue( 'minHeightTablet', sizing ) && ! isGrid ? '100%' : false, // eslint-disable-line quote-props
70 } ];
71
72 if ( sizingValue( 'minHeightTablet', sizing ) && ! isGrid ) {
73 cssObj[ '.editor-styles-wrapper .gb-container-' + uniqueId ].push( {
74 'display': 'flex', // eslint-disable-line quote-props
75 'flex-direction': 'row',
76 'align-items': 'inherit' !== verticalAlignmentTablet ? verticalAlignmentTablet : null,
77 } );
78 }
79
80 if ( isGrid && 'inherit' !== verticalAlignmentTablet ) {
81 cssObj[ '.editor-styles-wrapper .gb-container-' + uniqueId ].push( {
82 'display': 'flex', // eslint-disable-line quote-props
83 'flex-direction': 'column',
84 'height': '100%', // eslint-disable-line quote-props
85 'justify-content': verticalAlignmentTablet,
86 } );
87 }
88 }
89
90 if ( isGrid ) {
91 const gridColumnSelectors = [
92 '.gb-post-template-' + gridId + ' > .gb-post-template-wrapper > .block-editor-inner-blocks',
93 '.gb-grid-wrapper > .block-editor-inner-blocks > .block-editor-block-list__layout > .gb-grid-column-' + uniqueId,
94 ];
95
96 cssObj[ gridColumnSelectors.join( ',' ) ] = [ {
97 width: sizingValue( 'widthTablet', sizing ),
98 'flex-grow': flexGrowTablet,
99 'flex-shrink': flexShrinkTablet,
100 'flex-basis': flexBasisTablet,
101 order: orderTablet,
102 } ];
103 }
104
105 if ( !! bgImage && 'pseudo-element' === bgOptions.selector ) {
106 cssObj[ '.gb-container-' + uniqueId + ':before' ] = [ {
107 'border-top-left-radius': borderTopLeftRadiusTablet,
108 'border-top-right-radius': borderTopRightRadiusTablet,
109 'border-bottom-right-radius': borderBottomRightRadiusTablet,
110 'border-bottom-left-radius': borderBottomLeftRadiusTablet,
111 } ];
112 }
113
114 if ( shapeDividers.length ) {
115 shapeDividers.forEach( ( location, index ) => {
116 const shapeNumber = index + 1;
117
118 cssObj[ '.gb-container-' + uniqueId + ' > .gb-shapes .gb-shape-' + shapeNumber + ' svg' ] = [ {
119 height: valueWithUnit( shapeDividers[ index ].heightTablet, 'px' ),
120 width: valueWithUnit( shapeDividers[ index ].widthTablet, '%' ),
121 } ];
122 } );
123 }
124
125 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, this.props, 'container' );
126
127 return (
128 <style>{ buildCSS( cssObj ) }</style>
129 );
130 }
131 }
132 /* eslint-enable quotes */
133