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