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 / image / css / mobile.js
generateblocks / src / blocks / image / 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
mobile.js
91 lines
1 import buildCSS from '../../../utils/build-css';
2 import { applyFilters } from '@wordpress/hooks';
3 import shorthandCSS from '../../../utils/shorthand-css';
4 import SpacingCSS from '../../../extend/inspector-control/controls/spacing/components/SpacingCSS';
5
6 export default function MobileCSS( props ) {
7 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', props.attributes, props );
8
9 const {
10 uniqueId,
11 paddingTopMobile,
12 paddingRightMobile,
13 paddingBottomMobile,
14 paddingLeftMobile,
15 paddingUnit,
16 borderSizeTopMobile,
17 borderSizeRightMobile,
18 borderSizeBottomMobile,
19 borderSizeLeftMobile,
20 borderRadiusTopRightMobile,
21 borderRadiusBottomRightMobile,
22 borderRadiusBottomLeftMobile,
23 borderRadiusTopLeftMobile,
24 borderRadiusUnit,
25 borderColor,
26 objectFitMobile,
27 widthMobile,
28 heightMobile,
29 alignment,
30 alignmentTablet,
31 alignmentMobile,
32 } = attributes;
33
34 let cssObj = [];
35
36 const floats = {
37 floatLeft: 'left',
38 floatRight: 'right',
39 floatNone: 'none',
40 };
41
42 let float = alignmentMobile.startsWith( 'float' ) ? floats[ alignmentMobile ] : null;
43
44 if (
45 alignmentMobile &&
46 ! float &&
47 (
48 alignmentTablet.startsWith( 'float' ) ||
49 alignment.startsWith( 'float' )
50 )
51 ) {
52 // We have a mobile alignment and tablet/desktop is set to float, so let's disable it.
53 float = 'none';
54 }
55
56 cssObj[ '.editor-styles-wrapper .gb-block-image-' + uniqueId ] = [ {
57 padding: shorthandCSS( paddingTopMobile, paddingRightMobile, paddingBottomMobile, paddingLeftMobile, paddingUnit ),
58 'text-align': ! alignmentMobile.startsWith( 'float' ) ? alignmentMobile : null,
59 float,
60 position: float && 'none' !== float ? 'relative' : null,
61 'z-index': float && 'none' !== float ? '22' : null,
62 } ];
63
64 SpacingCSS( cssObj, '.editor-styles-wrapper .gb-block-image-' + uniqueId, attributes, 'Mobile' );
65
66 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ] = [ {
67 'border-radius': shorthandCSS( borderRadiusTopLeftMobile, borderRadiusTopRightMobile, borderRadiusBottomRightMobile, borderRadiusBottomLeftMobile, borderRadiusUnit ),
68 'border-color': borderColor,
69 width: widthMobile,
70 height: heightMobile,
71 'object-fit': objectFitMobile,
72 } ];
73
74 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId + ' + .components-placeholder__illustration' ] = [ {
75 'border-radius': shorthandCSS( borderRadiusTopLeftMobile, borderRadiusTopRightMobile, borderRadiusBottomRightMobile, borderRadiusBottomLeftMobile, borderRadiusUnit ),
76 } ];
77
78 if ( borderSizeTopMobile || borderSizeRightMobile || borderSizeBottomMobile || borderSizeLeftMobile ) {
79 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ].push( {
80 'border-width': shorthandCSS( borderSizeTopMobile, borderSizeRightMobile, borderSizeBottomMobile, borderSizeLeftMobile, 'px' ),
81 'border-style': 'solid',
82 } );
83 }
84
85 cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, props, 'image' );
86
87 return (
88 <style>{ buildCSS( cssObj ) }</style>
89 );
90 }
91