Skip to content

Commit 38d75f0

Browse files
committed
fix: add row and column gaps deprecations
1 parent 4441660 commit 38d75f0

File tree

1 file changed

+48
-0
lines changed
  • src/block-components/columns/deprecated

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { getAttrNameFunction } from '~stackable/util'
2+
3+
export const deprecatedAddAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
4+
attrObject.add( {
5+
attributes: {
6+
columnGap: {
7+
stkResponsive: true,
8+
type: 'number',
9+
default: '',
10+
},
11+
rowGap: {
12+
stkResponsive: true,
13+
type: 'number',
14+
default: '',
15+
},
16+
},
17+
attrNameTemplate,
18+
versionAdded: '3.0.0',
19+
versionDeprecated: '3.15.3',
20+
} )
21+
}
22+
23+
export const deprecateColumnAndRowGap = {
24+
isEligible: attrNameTemplate => attributes => {
25+
const getAttrName = getAttrNameFunction( attrNameTemplate )
26+
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
27+
28+
const columnGap = getAttribute( 'columnGap' )
29+
const rowGap = getAttribute( 'rowGap' )
30+
31+
return typeof columnGap === 'number' || typeof rowGap === 'number'
32+
},
33+
migrate: attrNameTemplate => attributes => {
34+
const getAttrName = getAttrNameFunction( attrNameTemplate )
35+
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
36+
37+
const columnGap = getAttribute( 'columnGap' )
38+
const rowGap = getAttribute( 'rowGap' )
39+
40+
const newAttributes = {
41+
...attributes,
42+
[ getAttrName( 'columnGap' ) ]: String( columnGap ),
43+
[ getAttrName( 'rowGap' ) ]: String( rowGap ),
44+
}
45+
46+
return newAttributes
47+
},
48+
}

0 commit comments

Comments
 (0)