-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (40 loc) · 1.43 KB
/
index.js
File metadata and controls
50 lines (40 loc) · 1.43 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
import { getAttrNameFunction } from '~stackable/util'
export const deprecatedAddAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
attrObject.add( {
attributes: {
innerBlockRowGap: {
stkResponsive: true,
type: 'number',
default: '',
},
},
attrNameTemplate,
versionAdded: '3.0.0',
versionDeprecated: '3.16.0',
} )
}
export const deprecateInnerBlockRowGapAndContainerHeight = {
isEligible: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const containerHeight = getAttribute( 'containerHeight' )
const innerBlockRowGap = getAttribute( 'innerBlockRowGap' )
return typeof containerHeight === 'number' || typeof innerBlockRowGap === 'number'
},
migrate: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const newAttributes = {
...attributes,
}
const containerHeight = getAttribute( 'containerHeight' )
const innerBlockRowGap = getAttribute( 'innerBlockRowGap' )
if ( typeof containerHeight === 'number' ) {
newAttributes[ getAttrName( 'containerHeight' ) ] = String( containerHeight )
}
if ( typeof innerBlockRowGap === 'number' ) {
newAttributes[ getAttrName( 'innerBlockRowGap' ) ] = String( innerBlockRowGap )
}
return newAttributes
},
}