Skip to content

Commit c86f5d7

Browse files
committed
fix: add the additional deprecation for handling shadow
1 parent 0cae007 commit c86f5d7

File tree

50 files changed

+2244
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2244
-7
lines changed

src/block-components/alignment/deprecated/index.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ export const deprecateInnerBlockRowGapAndContainerHeight = {
2121
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
2222

2323
const containerHeight = getAttribute( 'containerHeight' )
24+
const containerHeightTablet = getAttribute( 'containerHeightTablet' )
25+
const containerHeightMobile = getAttribute( 'containerHeightMobile' )
2426
const innerBlockRowGap = getAttribute( 'innerBlockRowGap' )
27+
const innerBlockRowGapTablet = getAttribute( 'innerBlockRowGapTablet' )
28+
const innerBlockRowGapMobile = getAttribute( 'innerBlockRowGapMobile' )
2529

26-
return typeof containerHeight === 'number' || typeof innerBlockRowGap === 'number'
30+
return typeof containerHeight === 'number' || typeof innerBlockRowGap === 'number' ||
31+
typeof containerHeightTablet === 'number' || typeof innerBlockRowGapTablet === 'number' ||
32+
typeof containerHeightMobile === 'number' || typeof innerBlockRowGapMobile === 'number'
2733
},
2834
migrate: attrNameTemplate => attributes => {
2935
const getAttrName = getAttrNameFunction( attrNameTemplate )
@@ -34,16 +40,36 @@ export const deprecateInnerBlockRowGapAndContainerHeight = {
3440
}
3541

3642
const containerHeight = getAttribute( 'containerHeight' )
43+
const containerHeightTablet = getAttribute( 'containerHeightTablet' )
44+
const containerHeightMobile = getAttribute( 'containerHeightMobile' )
3745
const innerBlockRowGap = getAttribute( 'innerBlockRowGap' )
46+
const innerBlockRowGapTablet = getAttribute( 'innerBlockRowGapTablet' )
47+
const innerBlockRowGapMobile = getAttribute( 'innerBlockRowGapMobile' )
3848

3949
if ( typeof containerHeight === 'number' ) {
4050
newAttributes[ getAttrName( 'containerHeight' ) ] = String( containerHeight )
4151
}
4252

53+
if ( typeof containerHeightTablet === 'number' ) {
54+
newAttributes[ getAttrName( 'containerHeightTablet' ) ] = String( containerHeightTablet )
55+
}
56+
57+
if ( typeof containerHeightMobile === 'number' ) {
58+
newAttributes[ getAttrName( 'containerHeightMobile' ) ] = String( containerHeightMobile )
59+
}
60+
4361
if ( typeof innerBlockRowGap === 'number' ) {
4462
newAttributes[ getAttrName( 'innerBlockRowGap' ) ] = String( innerBlockRowGap )
4563
}
4664

65+
if ( typeof innerBlockRowGapTablet === 'number' ) {
66+
newAttributes[ getAttrName( 'innerBlockRowGapTablet' ) ] = String( innerBlockRowGapTablet )
67+
}
68+
69+
if ( typeof innerBlockRowGapMobile === 'number' ) {
70+
newAttributes[ getAttrName( 'innerBlockRowGapMobile' ) ] = String( innerBlockRowGapMobile )
71+
}
72+
4773
return newAttributes
4874
},
4975
}

src/block-components/columns/deprecated/index.js

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,77 @@ export const deprecateColumnAndRowGap = {
3232
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
3333

3434
const columnSpacing = getAttribute( 'columnSpacing' )
35+
const columnSpacingTablet = getAttribute( 'columnSpacingTablet' )
36+
const columnSpacingMobile = getAttribute( 'columnSpacingMobile' )
37+
3538
const columnGap = getAttribute( 'columnGap' )
39+
const columnGapTablet = getAttribute( 'columnGapTablet' )
40+
const columnGapMobile = getAttribute( 'columnGapMobile' )
41+
3642
const rowGap = getAttribute( 'rowGap' )
43+
const rowGapTablet = getAttribute( 'rowGapTablet' )
44+
const rowGapMobile = getAttribute( 'rowGapMobile' )
3745

38-
return typeof columnSpacing === 'number' || typeof columnGap === 'number' || typeof rowGap === 'number'
46+
return (
47+
typeof columnSpacing === 'number' ||
48+
typeof columnSpacingTablet === 'number' ||
49+
typeof columnSpacingMobile === 'number' ||
50+
typeof columnGap === 'number' ||
51+
typeof columnGapTablet === 'number' ||
52+
typeof columnGapMobile === 'number' ||
53+
typeof rowGap === 'number' ||
54+
typeof rowGapTablet === 'number' ||
55+
typeof rowGapMobile === 'number'
56+
)
3957
},
58+
4059
migrate: attrNameTemplate => attributes => {
4160
const getAttrName = getAttrNameFunction( attrNameTemplate )
4261
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
4362

44-
const newAttributes = {
45-
...attributes,
46-
}
63+
const newAttributes = { ...attributes }
4764

4865
const columnSpacing = getAttribute( 'columnSpacing' )
66+
const columnSpacingTablet = getAttribute( 'columnSpacingTablet' )
67+
const columnSpacingMobile = getAttribute( 'columnSpacingMobile' )
68+
4969
const columnGap = getAttribute( 'columnGap' )
70+
const columnGapTablet = getAttribute( 'columnGapTablet' )
71+
const columnGapMobile = getAttribute( 'columnGapMobile' )
72+
5073
const rowGap = getAttribute( 'rowGap' )
74+
const rowGapTablet = getAttribute( 'rowGapTablet' )
75+
const rowGapMobile = getAttribute( 'rowGapMobile' )
5176

5277
if ( typeof columnSpacing === 'number' ) {
5378
newAttributes[ getAttrName( 'columnSpacing' ) ] = String( columnSpacing )
5479
}
80+
if ( typeof columnSpacingTablet === 'number' ) {
81+
newAttributes[ getAttrName( 'columnSpacingTablet' ) ] = String( columnSpacingTablet )
82+
}
83+
if ( typeof columnSpacingMobile === 'number' ) {
84+
newAttributes[ getAttrName( 'columnSpacingMobile' ) ] = String( columnSpacingMobile )
85+
}
5586

5687
if ( typeof columnGap === 'number' ) {
5788
newAttributes[ getAttrName( 'columnGap' ) ] = String( columnGap )
5889
}
90+
if ( typeof columnGapTablet === 'number' ) {
91+
newAttributes[ getAttrName( 'columnGapTablet' ) ] = String( columnGapTablet )
92+
}
93+
if ( typeof columnGapMobile === 'number' ) {
94+
newAttributes[ getAttrName( 'columnGapMobile' ) ] = String( columnGapMobile )
95+
}
5996

6097
if ( typeof rowGap === 'number' ) {
6198
newAttributes[ getAttrName( 'rowGap' ) ] = String( rowGap )
6299
}
100+
if ( typeof rowGapTablet === 'number' ) {
101+
newAttributes[ getAttrName( 'rowGapTablet' ) ] = String( rowGapTablet )
102+
}
103+
if ( typeof rowGapMobile === 'number' ) {
104+
newAttributes[ getAttrName( 'rowGapMobile' ) ] = String( rowGapMobile )
105+
}
63106

64107
return newAttributes
65108
},

src/block-components/helpers/size/deprecated.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ export const deprecateSizeControlHeight = {
2222
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
2323

2424
const height = getAttribute( 'height' )
25+
const heightTablet = getAttribute( 'heightTablet' )
26+
const heightMobile = getAttribute( 'heightMobile' )
2527

26-
return typeof height === 'number'
28+
return typeof height === 'number' ||
29+
typeof heightTablet === 'number' ||
30+
typeof heightMobile === 'number'
2731
},
2832
migrate: attrNameTemplate => attributes => {
2933
const getAttrName = getAttrNameFunction( attrNameTemplate )
@@ -34,11 +38,21 @@ export const deprecateSizeControlHeight = {
3438
}
3539

3640
const height = getAttribute( 'height' )
41+
const heightTablet = getAttribute( 'heightTablet' )
42+
const heightMobile = getAttribute( 'heightMobile' )
3743

3844
if ( typeof height === 'number' ) {
3945
newAttributes[ getAttrName( 'height' ) ] = String( height )
4046
}
4147

48+
if ( typeof heightTablet === 'number' ) {
49+
newAttributes[ getAttrName( 'heightTablet' ) ] = String( heightTablet )
50+
}
51+
52+
if ( typeof heightMobile === 'number' ) {
53+
newAttributes[ getAttrName( 'heightMobile' ) ] = String( heightMobile )
54+
}
55+
4256
return newAttributes
4357
},
4458
}

src/block-components/typography/deprecated.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,12 @@ export const deprecateTypographyFontSize = {
125125
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
126126

127127
const fontSize = getAttribute( 'fontSize' )
128+
const fontSizeTablet = getAttribute( 'fontSizeTablet' )
129+
const fontSizeMobile = getAttribute( 'fontSizeMobile' )
128130

129-
return typeof fontSize === 'number'
131+
return typeof fontSize === 'number' ||
132+
typeof fontSizeTablet === 'number' ||
133+
typeof fontSizeMobile === 'number'
130134
},
131135
migrate: attrNameTemplate => attributes => {
132136
const getAttrName = getAttrNameFunction( attrNameTemplate )
@@ -137,11 +141,21 @@ export const deprecateTypographyFontSize = {
137141
}
138142

139143
const fontSize = getAttribute( 'fontSize' )
144+
const fontSizeTablet = getAttribute( 'fontSizeTablet' )
145+
const fontSizeMobile = getAttribute( 'fontSizeMobile' )
140146

141147
if ( typeof fontSize === 'number' ) {
142148
newAttributes[ getAttrName( 'fontSize' ) ] = String( fontSize )
143149
}
144150

151+
if ( typeof fontSizeTablet === 'number' ) {
152+
newAttributes[ getAttrName( 'fontSizeTablet' ) ] = String( fontSizeTablet )
153+
}
154+
155+
if ( typeof fontSizeMobile === 'number' ) {
156+
newAttributes[ getAttrName( 'fontSizeMobile' ) ] = String( fontSizeMobile )
157+
}
158+
145159
return newAttributes
146160
},
147161
}

src/block/accordion/deprecated.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ import {
88
} from '~stackable/block-components'
99

1010
const deprecated = [
11+
{
12+
// Handle the migration of shadow attributes with the change of type in 3.15.3
13+
attributes: attributes( '3.16.2' ),
14+
save: withVersion( '3.16.2' )( Save ),
15+
isEligible: attributes => {
16+
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
17+
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
18+
19+
return hasBlockShadow || hasContainerShadow
20+
},
21+
migrate: attributes => {
22+
let newAttributes = { ...attributes }
23+
24+
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
25+
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
26+
newAttributes = deprecateContainerBackgroundColorOpacity.migrate( newAttributes )
27+
newAttributes = deprecateBlockBackgroundColorOpacity.migrate( newAttributes )
28+
newAttributes = deprecateBlockHeight.migrate( newAttributes )
29+
30+
return newAttributes
31+
},
32+
},
1133
{
1234
// Support the change of type for block height
1335
attributes: attributes( '3.15.3' ),
@@ -32,6 +54,14 @@ const deprecated = [
3254
attributes: attributes( '3.12.11' ),
3355
save: withVersion( '3.12.11' )( Save ),
3456
isEligible: attributes => {
57+
if ( (
58+
typeof attributes?.blockHeight === 'string' ||
59+
typeof attributes?.blockHeightTablet === 'string' ||
60+
typeof attributes?.blockHeightMobile === 'string' )
61+
) {
62+
return false
63+
}
64+
3565
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
3666
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
3767

src/block/blockquote/deprecated.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ import {
88
} from '~stackable/block-components'
99

1010
const deprecated = [
11+
{
12+
// Handle the migration of shadow attributes with the change of type in 3.15.3
13+
attributes: attributes( '3.16.2' ),
14+
save: withVersion( '3.16.2' )( Save ),
15+
isEligible: attributes => {
16+
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
17+
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
18+
19+
return hasBlockShadow || hasContainerShadow
20+
},
21+
migrate: attributes => {
22+
let newAttributes = {
23+
...attributes,
24+
version: 2,
25+
}
26+
27+
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
28+
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
29+
newAttributes = deprecateContainerBackgroundColorOpacity.migrate( newAttributes )
30+
newAttributes = deprecateBlockBackgroundColorOpacity.migrate( newAttributes )
31+
newAttributes = deprecateBlockHeight.migrate( newAttributes )
32+
33+
return newAttributes
34+
},
35+
},
1136
{
1237
// Support the change of type for block height
1338
attributes: attributes( '3.15.3' ),
@@ -36,6 +61,14 @@ const deprecated = [
3661
attributes: attributes( '3.12.11' ),
3762
save: withVersion( '3.12.11' )( Save ),
3863
isEligible: attributes => {
64+
if ( (
65+
typeof attributes?.blockHeight === 'string' ||
66+
typeof attributes?.blockHeightTablet === 'string' ||
67+
typeof attributes?.blockHeightMobile === 'string' )
68+
) {
69+
return false
70+
}
71+
3972
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
4073
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
4174

src/block/button-group/deprecated/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ import {
1010
} from '~stackable/block-components'
1111

1212
const deprecated = [
13+
{
14+
// Handle the migration of shadow attributes with the change of type in 3.15.3
15+
attributes: attributes( '3.16.2' ),
16+
save: withVersion( '3.16.2' )( Save ),
17+
isEligible: attributes => {
18+
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
19+
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
20+
21+
return hasBlockShadow || hasContainerShadow
22+
},
23+
migrate: attributes => {
24+
let newAttributes = { ...attributes }
25+
26+
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
27+
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
28+
newAttributes = deprecateContainerBackgroundColorOpacity.migrate( newAttributes )
29+
newAttributes = deprecateBlockBackgroundColorOpacity.migrate( newAttributes )
30+
newAttributes = deprecateBlockHeight.migrate( newAttributes )
31+
32+
return newAttributes
33+
},
34+
},
1335
{
1436
// Support the change of type for block height
1537
attributes: attributes( '3.15.3' ),
@@ -34,6 +56,14 @@ const deprecated = [
3456
attributes: attributes( '3.12.11' ),
3557
save: withVersion( '3.12.11' )( Save ),
3658
isEligible: attributes => {
59+
if ( (
60+
typeof attributes?.blockHeight === 'string' ||
61+
typeof attributes?.blockHeightTablet === 'string' ||
62+
typeof attributes?.blockHeightMobile === 'string' )
63+
) {
64+
return false
65+
}
66+
3767
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
3868
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
3969

src/block/button/deprecated.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ import {
1010
} from '~stackable/block-components'
1111

1212
const deprecated = [
13+
{
14+
// Handle the migration of shadow attributes with the change of type in 3.15.3
15+
attributes: attributes( '3.16.2' ),
16+
save: withVersion( '3.16.2' )( Save ),
17+
isEligible: attributes => {
18+
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
19+
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
20+
const hasButtonShadow = deprecateShadowColor.isEligible( 'button%s' )( attributes )
21+
22+
return hasBlockShadow || hasContainerShadow || hasButtonShadow
23+
},
24+
migrate: attributes => {
25+
let newAttributes = { ...attributes }
26+
27+
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
28+
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
29+
newAttributes = deprecateShadowColor.migrate( 'button%s' )( newAttributes )
30+
newAttributes = deprecateContainerBackgroundColorOpacity.migrate( newAttributes )
31+
newAttributes = deprecateBlockBackgroundColorOpacity.migrate( newAttributes )
32+
newAttributes = deprecateButtonGradientColor.migrate( 'button%s' )( newAttributes )
33+
newAttributes = deprecateTypographyFontSize.migrate( '%s' )( newAttributes )
34+
newAttributes = deprecateBlockHeight.migrate( newAttributes )
35+
36+
return newAttributes
37+
},
38+
},
1339
{
1440
// Support the change of type for fontSize
1541
attributes: attributes( '3.15.3' ),
@@ -39,6 +65,16 @@ const deprecated = [
3965
attributes: attributes( '3.12.11' ),
4066
save: withVersion( '3.12.11' )( Save ),
4167
isEligible: attributes => {
68+
if ( ( typeof attributes?.fontSize === 'string' ||
69+
typeof attributes?.fontSizeTablet === 'string' ||
70+
typeof attributes?.fontSizeMobile === 'string' ||
71+
typeof attributes?.blockHeight === 'string' ||
72+
typeof attributes?.blockHeightTablet === 'string' ||
73+
typeof attributes?.blockHeightMobile === 'string' )
74+
) {
75+
return false
76+
}
77+
4278
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
4379
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
4480
const hasButtonShadow = deprecateShadowColor.isEligible( 'button%s' )( attributes )

0 commit comments

Comments
 (0)