Skip to content

Commit 4441660

Browse files
committed
fix: add row and column gaps deprecations
1 parent 4a68153 commit 4441660

8 files changed

Lines changed: 51 additions & 23 deletions

File tree

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export const addAttributes = attrObject => {
1+
import { deprecatedAddAttributes } from './deprecated/index'
2+
3+
export const addAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
4+
deprecatedAddAttributes( attrObject, attrNameTemplate )
5+
26
attrObject.add( {
37
attributes: {
48
columnSpacing: {
@@ -7,6 +11,17 @@ export const addAttributes = attrObject => {
711
type: 'number',
812
default: '',
913
},
14+
columnWrapDesktop: { // Only applies to desktops
15+
type: 'boolean',
16+
default: false,
17+
},
18+
},
19+
versionAdded: '3.0.0',
20+
versionDeprecated: '',
21+
} )
22+
23+
attrObject.add( {
24+
attributes: {
1025
columnGap: {
1126
stkResponsive: true,
1227
type: 'string',
@@ -17,12 +32,9 @@ export const addAttributes = attrObject => {
1732
type: 'string',
1833
default: '',
1934
},
20-
columnWrapDesktop: { // Only applies to desktops
21-
type: 'boolean',
22-
default: false,
23-
},
2435
},
25-
versionAdded: '3.0.0',
36+
attrNameTemplate,
37+
versionAdded: '3.15.3',
2638
versionDeprecated: '',
2739
} )
2840
}

src/block-components/columns/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const Columns = () => {
66
return null
77
}
88

9+
export { deprecateColumnAndRowGap } from './deprecated/index'
10+
911
Columns.InspectorControls = Edit
1012

1113
Columns.addStyles = addStyles

src/block-components/columns/style.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
3333
responsive: 'all',
3434
valueCallback: value => {
3535
// Substitute with using format to work with preset controls
36-
if ( value.startsWith( 'var' ) ) {
36+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
3737
return value
3838
}
3939
return value + 'px'
@@ -46,7 +46,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
4646
attrName: 'columnGap',
4747
responsive: 'all',
4848
valueCallback: value => {
49-
if ( value.startsWith( 'var' ) ) {
49+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
5050
return value
5151
}
5252
return value + 'px'
@@ -91,7 +91,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
9191
attrName: 'rowGap',
9292
responsive: 'all',
9393
valueCallback: value => {
94-
if ( value.startsWith( 'var' ) ) {
94+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
9595
return value
9696
}
9797
return value + 'px'
@@ -104,7 +104,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
104104
attrName: 'rowGap',
105105
responsive: 'all',
106106
valueCallback: value => {
107-
if ( value.startsWith( 'var' ) ) {
107+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
108108
return value
109109
}
110110
return value + 'px'

src/block/carousel/deprecated.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
33
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor, deprecateBlockHeight,
4+
deprecateColumnAndRowGap,
45
} from '~stackable/block-components'
56
import { Save } from './save'
67
import { attributes } from './schema'
@@ -9,11 +10,13 @@ import { withVersion } from '~stackable/higher-order'
910

1011
const deprecated = [
1112
{
12-
// Support the change of type for block height
13+
// Support the change of type for block height and gaps
1314
attributes: attributes( '3.15.2' ),
1415
save: withVersion( '3.15.2' )( Save ),
1516
isEligible: attributes => {
16-
return deprecateBlockHeight.isEligible( attributes )
17+
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
18+
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
19+
return hasNumberBlockHeight || hasNumberGaps
1720
},
1821
migrate: attributes => {
1922
let newAttributes = { ...attributes }
@@ -25,6 +28,7 @@ const deprecated = [
2528
newAttributes = deprecateContainerBackgroundColorOpacity.migrate( newAttributes )
2629
newAttributes = deprecateBlockBackgroundColorOpacity.migrate( newAttributes )
2730
newAttributes = deprecateBlockHeight.migrate( newAttributes )
31+
newAttributes = deprecateColumnAndRowGap.migrate( '%s' )( newAttributes )
2832

2933
return newAttributes
3034
},

src/block/columns/deprecated.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { semverCompare } from '~stackable/util'
1717
import {
1818
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1919
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor,
20-
deprecateBlockHeight,
20+
deprecateBlockHeight, deprecateColumnAndRowGap,
2121
} from '~stackable/block-components'
2222

2323
// Version 3.6.2 Deprecations, we now don't need the stk--has-column-order class.
@@ -38,13 +38,14 @@ addFilter( 'stackable.columns.save.contentClassNames', 'stackable/3.8.0', ( clas
3838

3939
const deprecated = [
4040
{
41-
// Support the change of type for block height
41+
// Support the change of type for block height and gaps
4242
attributes: attributes( '3.15.2' ),
4343
save: withVersion( '3.15.2' )( Save ),
4444
isEligible: attributes => {
4545
const hasColumnFit = !! attributes.columnFit
4646
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
47-
return hasColumnFit || hasNumberBlockHeight
47+
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
48+
return hasColumnFit || hasNumberBlockHeight || hasNumberGaps
4849
},
4950
migrate: attributes => {
5051
let newAttributes = {
@@ -61,6 +62,7 @@ const deprecated = [
6162
newAttributes = deprecateShadowColor.migrate( 'topSeparator%s' )( newAttributes )
6263
newAttributes = deprecateShadowColor.migrate( 'bottomSeparator%s' )( newAttributes )
6364
newAttributes = deprecateBlockHeight.migrate( newAttributes )
65+
newAttributes = deprecateColumnAndRowGap.migrate( '%s' )( newAttributes )
6466

6567
return newAttributes
6668
},

src/block/feature-grid/deprecated.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1414
getResponsiveClasses, getSeparatorClasses,
1515
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor,
16-
deprecateBlockHeight,
16+
deprecateBlockHeight, deprecateColumnAndRowGap,
1717
} from '~stackable/block-components'
1818

1919
/**
@@ -62,13 +62,14 @@ addFilter( 'stackable.feature-grid.save.blockClassNames', 'stackable/3.1.0', ( o
6262

6363
const deprecated = [
6464
{
65-
// Support the change of type for block height
65+
// Support the change of type for block height and gaps
6666
attributes: attributes( '3.15.2' ),
6767
save: withVersion( '3.15.2' )( Save ),
6868
isEligible: attributes => {
6969
const hasColumnFit = !! attributes.columnFit
7070
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
71-
return hasColumnFit || hasNumberBlockHeight
71+
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
72+
return hasColumnFit || hasNumberBlockHeight || hasNumberGaps
7273
},
7374
migrate: attributes => {
7475
let newAttributes = {
@@ -85,6 +86,7 @@ const deprecated = [
8586
newAttributes = deprecateShadowColor.migrate( 'topSeparator%s' )( newAttributes )
8687
newAttributes = deprecateShadowColor.migrate( 'bottomSeparator%s' )( newAttributes )
8788
newAttributes = deprecateBlockHeight.migrate( newAttributes )
89+
newAttributes = deprecateColumnAndRowGap.migrate( '%s' )( newAttributes )
8890

8991
return newAttributes
9092
},

src/block/feature/deprecated.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
deprecateContainerBackgroundColorOpacity,
1515
getAlignmentClasses, getContentAlignmentClasses, getRowClasses,
1616
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor,
17-
deprecateBlockHeight,
17+
deprecateBlockHeight, deprecateColumnAndRowGap,
1818
} from '~stackable/block-components'
1919

2020
/**
@@ -64,13 +64,14 @@ addFilter( 'stackable.feature.save.innerClassNames', 'stackable/3.8.0', ( output
6464

6565
const deprecated = [
6666
{
67-
// Support the change of type for block height
67+
// Support the change of type for block height and gaps
6868
attributes: attributes( '3.15.2' ),
6969
save: withVersion( '3.15.2' )( Save ),
7070
isEligible: attributes => {
7171
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
7272
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
73-
return isNotV4 || hasNumberBlockHeight
73+
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
74+
return isNotV4 || hasNumberBlockHeight || hasNumberGaps
7475
},
7576
migrate: attributes => {
7677
let newAttributes = {
@@ -96,6 +97,7 @@ const deprecated = [
9697
newAttributes = deprecateShadowColor.migrate( 'topSeparator%s' )( newAttributes )
9798
newAttributes = deprecateShadowColor.migrate( 'bottomSeparator%s' )( newAttributes )
9899
newAttributes = deprecateBlockHeight.migrate( newAttributes )
100+
newAttributes = deprecateColumnAndRowGap.migrate( '%s' )( newAttributes )
99101

100102
return newAttributes
101103
},

src/block/tab-content/deprecated.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
33
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateBlockHeight,
4+
deprecateColumnAndRowGap,
45
} from '~stackable/block-components'
56
import { Save } from './save'
67
import { attributes } from './schema'
@@ -9,11 +10,13 @@ import { withVersion } from '~stackable/higher-order'
910

1011
const deprecated = [
1112
{
12-
// Support the change of type for block height
13+
// Support the change of type for block height and gaps
1314
attributes: attributes( '3.15.2' ),
1415
save: withVersion( '3.15.2' )( Save ),
1516
isEligible: attributes => {
16-
return deprecateBlockHeight.isEligible( attributes )
17+
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
18+
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
19+
return hasNumberBlockHeight || hasNumberGaps
1720
},
1821
migrate: attributes => {
1922
let newAttributes = { ...attributes }
@@ -23,6 +26,7 @@ const deprecated = [
2326
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
2427
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
2528
newAttributes = deprecateBlockHeight.migrate( newAttributes )
29+
newAttributes = deprecateColumnAndRowGap.migrate( '%s' )( newAttributes )
2630

2731
return newAttributes
2832
},

0 commit comments

Comments
 (0)