PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.3
GenerateBlocks v1.8.3
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 2 years ago mobile.js 2 years ago tablet-only.js 4 years ago tablet.js 2 years ago
main.js
61 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 MainCSS( props ) {
8 const attributes = applyFilters( 'generateblocks.editor.cssAttrs', props.attributes, props );
9
10 const {
11 uniqueId,
12 objectFit,
13 width,
14 height,
15 alignment,
16 } = attributes;
17
18 const {
19 borderTopLeftRadius,
20 borderTopRightRadius,
21 borderBottomRightRadius,
22 borderBottomLeftRadius,
23 } = attributes.spacing;
24
25 let cssObj = [];
26
27 const floats = {
28 floatLeft: 'left',
29 floatRight: 'right',
30 floatNone: 'none',
31 };
32
33 cssObj[ '.editor-styles-wrapper .gb-block-image-' + uniqueId ] = [ {
34 'text-align': ! alignment.startsWith( 'float' ) ? alignment : null,
35 float: alignment.startsWith( 'float' ) ? floats[ alignment ] : 'none',
36 position: alignment.startsWith( 'float' ) ? 'relative' : null,
37 'z-index': alignment.startsWith( 'float' ) ? '22' : null,
38 'max-width': 'unset',
39 } ];
40
41 SpacingCSS( cssObj, '.editor-styles-wrapper .gb-block-image-' + uniqueId, attributes.spacing );
42
43 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId ] = [ {
44 width,
45 height,
46 'object-fit': objectFit,
47 } ];
48
49 BorderCSS( cssObj, '.editor-styles-wrapper .gb-image-' + uniqueId, attributes.borders );
50
51 cssObj[ '.editor-styles-wrapper .gb-image-' + uniqueId + ' + .components-placeholder__illustration' ] = [ {
52 'border-radius': shorthandCSS( borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius ),
53 } ];
54
55 cssObj = applyFilters( 'generateblocks.editor.mainCSS', cssObj, props, 'image' );
56
57 return (
58 <style>{ buildCSS( cssObj ) }</style>
59 );
60 }
61