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 / tablet.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
tablet.js
87 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 TabletCSS( props ) {
7 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', props.attributes, props );
8
9 const {
10 uniqueId,
11 paddingTopTablet,
12 paddingRightTablet,
13 paddingBottomTablet,
14 paddingLeftTablet,
15 paddingUnit,
16 borderSizeTopTablet,
17 borderSizeRightTablet,
18 borderSizeBottomTablet,
19 borderSizeLeftTablet,
20 borderRadiusTopRightTablet,
21 borderRadiusBottomRightTablet,
22 borderRadiusBottomLeftTablet,
23 borderRadiusTopLeftTablet,
24 borderRadiusUnit,
25 borderColor,
26 objectFitTablet,
27 widthTablet,
28 heightTablet,
29 alignment,
30 alignmentTablet,
31 } = attributes;
32
33 let cssObj = [];
34
35 const floats = {
36 floatLeft: 'left',
37 floatRight: 'right',
38 floatNone: 'none',
39 };
40
41 let float = alignmentTablet.startsWith( 'float' ) ? floats[ alignmentTablet ] : null;
42
43 if (
44 alignmentTablet &&
45 ! float &&
46 alignment.startsWith( 'float' )
47 ) {
48 // We have a tablet alignment and desktop is set to float, so let's disable it.
49 float = 'none';
50 }
51
52 cssObj[ '.editor-styles-wrapper .gb-block-image-' + uniqueId ] = [ {
53 padding: shorthandCSS( paddingTopTablet, paddingRightTablet, paddingBottomTablet, paddingLeftTablet, paddingUnit ),
54 'text-align': ! alignmentTablet.startsWith( 'float' ) ? alignmentTablet : null,
55 float,
56 position: float && 'none' !== float ? 'relative' : null,
57 'z-index': float && 'none' !== float ? '22' : null,
58 } ];
59
60 SpacingCSS( cssObj, '.editor-styles-wrapper .gb-block-image-' + uniqueId, attributes, 'Tablet' );
61
62 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ] = [ {
63 'border-radius': shorthandCSS( borderRadiusTopLeftTablet, borderRadiusTopRightTablet, borderRadiusBottomRightTablet, borderRadiusBottomLeftTablet, borderRadiusUnit ),
64 'border-color': borderColor,
65 width: widthTablet,
66 height: heightTablet,
67 'object-fit': objectFitTablet,
68 } ];
69
70 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId + ' + .components-placeholder__illustration' ] = [ {
71 'border-radius': shorthandCSS( borderRadiusTopLeftTablet, borderRadiusTopRightTablet, borderRadiusBottomRightTablet, borderRadiusBottomLeftTablet, borderRadiusUnit ),
72 } ];
73
74 if ( borderSizeTopTablet || borderSizeRightTablet || borderSizeBottomTablet || borderSizeLeftTablet ) {
75 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ].push( {
76 'border-width': shorthandCSS( borderSizeTopTablet, borderSizeRightTablet, borderSizeBottomTablet, borderSizeLeftTablet, 'px' ),
77 'border-style': 'solid',
78 } );
79 }
80
81 cssObj = applyFilters( 'generateblocks.editor.tabletCSS', cssObj, props, 'image' );
82
83 return (
84 <style>{ buildCSS( cssObj ) }</style>
85 );
86 }
87