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