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 / main.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
main.js
74 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 MainCSS( props ) {
6 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', props.attributes, props );
7
8 const {
9 uniqueId,
10 paddingTop,
11 paddingRight,
12 paddingBottom,
13 paddingLeft,
14 paddingUnit,
15 marginTop,
16 marginRight,
17 marginBottom,
18 marginLeft,
19 marginUnit,
20 borderSizeTop,
21 borderSizeRight,
22 borderSizeBottom,
23 borderSizeLeft,
24 borderRadiusTopRight,
25 borderRadiusBottomRight,
26 borderRadiusBottomLeft,
27 borderRadiusTopLeft,
28 borderRadiusUnit,
29 borderColor,
30 objectFit,
31 width,
32 height,
33 alignment,
34 } = attributes;
35
36 let cssObj = [];
37
38 const floats = {
39 floatLeft: 'left',
40 floatRight: 'right',
41 floatNone: 'none',
42 };
43
44 cssObj[ '.editor-styles-wrapper .gb-block-image-' + uniqueId ] = [ {
45 margin: shorthandCSS( marginTop, marginRight, marginBottom, marginLeft, marginUnit ),
46 padding: shorthandCSS( paddingTop, paddingRight, paddingBottom, paddingLeft, paddingUnit ),
47 'text-align': ! alignment.startsWith( 'float' ) ? alignment : null,
48 float: alignment.startsWith( 'float' ) ? floats[ alignment ] : 'none',
49 position: alignment.startsWith( 'float' ) ? 'relative' : null,
50 'z-index': alignment.startsWith( 'float' ) ? '22' : null,
51 } ];
52
53 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ] = [ {
54 'border-radius': shorthandCSS( borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomRight, borderRadiusBottomLeft, borderRadiusUnit ),
55 'border-color': borderColor,
56 width,
57 height,
58 'object-fit': objectFit,
59 } ];
60
61 if ( borderSizeTop || borderSizeRight || borderSizeBottom || borderSizeLeft ) {
62 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ].push( {
63 'border-width': shorthandCSS( borderSizeTop, borderSizeRight, borderSizeBottom, borderSizeLeft, 'px' ),
64 'border-style': 'solid',
65 } );
66 }
67
68 cssObj = applyFilters( 'generateblocks.editor.mainCSS', cssObj, props, 'image' );
69
70 return (
71 <style>{ buildCSS( cssObj ) }</style>
72 );
73 }
74