-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathindex.js
More file actions
66 lines (56 loc) · 1.74 KB
/
Copy pathindex.js
File metadata and controls
66 lines (56 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { getAttrNameFunction } from '~stackable/util'
export const deprecatedAddAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
attrObject.add( {
attributes: {
columnGap: {
stkResponsive: true,
type: 'number',
default: '',
},
rowGap: {
stkResponsive: true,
type: 'number',
default: '',
},
columnSpacing: {
stkResponsive: true,
stkUnits: 'px',
type: 'number',
default: '',
},
},
attrNameTemplate,
versionAdded: '3.0.0',
versionDeprecated: '3.16.0',
} )
}
export const deprecateColumnAndRowGap = {
isEligible: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const columnSpacing = getAttribute( 'columnSpacing' )
const columnGap = getAttribute( 'columnGap' )
const rowGap = getAttribute( 'rowGap' )
return typeof columnSpacing === 'number' || typeof columnGap === 'number' || typeof rowGap === 'number'
},
migrate: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const newAttributes = {
...attributes,
}
const columnSpacing = getAttribute( 'columnSpacing' )
const columnGap = getAttribute( 'columnGap' )
const rowGap = getAttribute( 'rowGap' )
if ( typeof columnSpacing === 'number' ) {
newAttributes[ getAttrName( 'columnSpacing' ) ] = String( columnSpacing )
}
if ( typeof columnGap === 'number' ) {
newAttributes[ getAttrName( 'columnGap' ) ] = String( columnGap )
}
if ( typeof rowGap === 'number' ) {
newAttributes[ getAttrName( 'rowGap' ) ] = String( rowGap )
}
return newAttributes
},
}