PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.2
GenerateBlocks v2.0.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 2 years ago mobile.js 2 years ago tablet-only.js 4 years ago tablet.js 2 years ago
mobile.js
78 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 import BorderCSS from '../../../extend/inspector-control/controls/borders/BorderCSS';
6
7 export default function MobileCSS( props ) {
8 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', props.attributes, props );
9
10 const {
11 uniqueId,
12 borderColor,
13 objectFitMobile,
14 widthMobile,
15 heightMobile,
16 alignment,
17 alignmentTablet,
18 alignmentMobile,
19 } = attributes;
20
21 const {
22 borderTopLeftRadiusTablet,
23 borderTopRightRadiusTablet,
24 borderBottomRightRadiusTablet,
25 borderBottomLeftRadiusTablet,
26 } = attributes.borders;
27
28 let cssObj = [];
29
30 const floats = {
31 floatLeft: 'left',
32 floatRight: 'right',
33 floatNone: 'none',
34 };
35
36 let float = alignmentMobile.startsWith( 'float' ) ? floats[ alignmentMobile ] : null;
37
38 if (
39 alignmentMobile &&
40 ! float &&
41 (
42 alignmentTablet.startsWith( 'float' ) ||
43 alignment.startsWith( 'float' )
44 )
45 ) {
46 // We have a mobile alignment and tablet/desktop is set to float, so let's disable it.
47 float = 'none';
48 }
49
50 cssObj[ '.editor-styles-wrapper .gb-block-image-' + uniqueId ] = [ {
51 'text-align': ! alignmentMobile.startsWith( 'float' ) ? alignmentMobile : null,
52 float,
53 position: float && 'none' !== float ? 'relative' : null,
54 'z-index': float && 'none' !== float ? '22' : null,
55 } ];
56
57 SpacingCSS( cssObj, '.editor-styles-wrapper .gb-block-image-' + uniqueId, attributes.spacing, 'Mobile' );
58
59 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ] = [ {
60 'border-color': borderColor,
61 width: widthMobile,
62 height: heightMobile,
63 'object-fit': objectFitMobile,
64 } ];
65
66 BorderCSS( cssObj, '.editor-styles-wrapper .gb-image-' + uniqueId, attributes.borders, 'Mobile' );
67
68 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId + ' + .components-placeholder__illustration' ] = [ {
69 'border-radius': shorthandCSS( borderTopLeftRadiusTablet, borderTopRightRadiusTablet, borderBottomRightRadiusTablet, borderBottomLeftRadiusTablet ),
70 } ];
71
72 cssObj = applyFilters( 'generateblocks.editor.mobileCSS', cssObj, props, 'image' );
73
74 return (
75 <style>{ buildCSS( cssObj ) }</style>
76 );
77 }
78