PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / grid / get-background-styles.js

get-background-styles.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.2, at gutenberg/blocks/grid/get-background-styles.js

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Returns object with background image styles for Row and Column.
3 *
4 * @param {Object} attributes - block attributes.
5 *
6 * @return {Object} Styles object.
7 */
8 export default function getBackgroundStyles(attributes) {
9 const {
10 awb_image: image,
11 awb_imageBackgroundSize: imageBackgroundSize,
12 awb_imageBackgroundPosition: imageBackgroundPosition,
13 } = attributes;
14
15 const styles = {};
16
17 styles['> .nk-awb .jarallax-img'] = {
18 'object-fit': undefined,
19 'object-position': undefined,
20 'background-repeat': undefined,
21 'background-position': undefined,
22
23 // Remove unused fallback styles.
24 'font-family': undefined,
25 };
26
27 // <img> tag with object-fit style
28 if (image) {
29 if (imageBackgroundSize !== 'pattern') {
30 if (imageBackgroundSize) {
31 styles['> .nk-awb .jarallax-img']['object-fit'] =
32 imageBackgroundSize;
33 }
34 if (imageBackgroundPosition) {
35 styles['> .nk-awb .jarallax-img']['object-position'] =
36 imageBackgroundPosition;
37 }
38
39 // background image with pattern size
40 } else {
41 if (imageBackgroundSize) {
42 styles['> .nk-awb .jarallax-img']['background-repeat'] =
43 'repeat';
44 }
45 if (imageBackgroundSize) {
46 styles['> .nk-awb .jarallax-img']['background-position'] =
47 imageBackgroundPosition;
48 }
49 }
50 }
51
52 return styles;
53 }
54