File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
src/block-components/columns/deprecated Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments