PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
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-column / get-col-class.js

get-col-class.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/grid-column/get-col-class.js

73 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import classnames from 'classnames/dedupe';
2
3 import { applyFilters } from '@wordpress/hooks';
4
5 /**
6 * Returns the ready to use className for grid column.
7 *
8 * @param {Object} props - block properties.
9 *
10 * @return {string} Classname for Grid container.
11 */
12 export default function getColClass(props) {
13 const { attributes } = props;
14 let result = 'ghostkit-col';
15
16 // Responsive classes.
17 Object.keys(attributes).forEach((key) => {
18 if (attributes[key]) {
19 let prefix = key.split('_')[0];
20 let type = key.split('_')[1];
21
22 if (!type) {
23 type = prefix;
24 prefix = '';
25 }
26
27 if (
28 type &&
29 (type === 'size' ||
30 type === 'order' ||
31 type === 'verticalAlign')
32 ) {
33 prefix = prefix && `-${prefix}`;
34
35 switch (type) {
36 case 'size':
37 type = '';
38 break;
39 case 'order':
40 type = `-${type}`;
41 break;
42 case 'verticalAlign':
43 type = '-align-self';
44 break;
45 // no default
46 }
47
48 result = classnames(
49 result,
50 `ghostkit-col${type}${prefix || ''}${
51 attributes[key] !== 'auto' ? `-${attributes[key]}` : ''
52 }`
53 );
54 }
55 }
56 });
57
58 // Sticky content.
59 if (
60 attributes.stickyContent &&
61 typeof attributes.stickyContentOffset !== 'undefined'
62 ) {
63 result = classnames(
64 result,
65 `ghostkit-col-sticky-${attributes.stickyContent}`
66 );
67 }
68
69 result = applyFilters('ghostkit.editor.className', result, props);
70
71 return result;
72 }
73