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