Skip to content

Commit 2ac2d58

Browse files
committed
Merge branch 'develop' into feat/new-design-library
2 parents ce8013e + 17fa6e5 commit 2ac2d58

File tree

27 files changed

+425
-132
lines changed

27 files changed

+425
-132
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ export const deprecateInnerBlockRowGapAndContainerHeight = {
2929
const getAttrName = getAttrNameFunction( attrNameTemplate )
3030
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
3131

32+
const newAttributes = {
33+
...attributes,
34+
}
35+
3236
const containerHeight = getAttribute( 'containerHeight' )
3337
const innerBlockRowGap = getAttribute( 'innerBlockRowGap' )
3438

35-
const newAttributes = {
36-
...attributes,
37-
[ getAttrName( 'containerHeight' ) ]: String( containerHeight ),
38-
[ getAttrName( 'innerBlockRowGap' ) ]: String( innerBlockRowGap ),
39+
if ( typeof containerHeight === 'number' ) {
40+
newAttributes[ getAttrName( 'containerHeight' ) ] = String( containerHeight )
41+
}
42+
43+
if ( typeof innerBlockRowGap === 'number' ) {
44+
newAttributes[ getAttrName( 'innerBlockRowGap' ) ] = String( innerBlockRowGap )
3945
}
4046

4147
return newAttributes

src/block-components/alignment/edit.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ export const Edit = memo( props => {
8787
enableContentAlign = true,
8888
} = props
8989

90-
const blockHeightMarks = usePresetControls( 'blockHeights' )?.getPresetMarks() || null
91-
const spacingSizeMarks = usePresetControls( 'spacingSizes' )?.getPresetMarks() || null
90+
const blockHeightMarks = usePresetControls( 'blockHeights' )
91+
?.getPresetMarks( { addNonePreset: true } ) || null
92+
const spacingSizeMarks = usePresetControls( 'spacingSizes' )
93+
?.getPresetMarks( { addNonePreset: true } ) || null
9294

9395
const containerSize = props.hasContainerSize && <>
9496
<ControlSeparator />

src/block-components/button/deprecated.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,21 @@ export const deprecateButtonGradientColor = {
5454
const color2ParentHover = getAttribute( 'backgroundColor2ParentHover' ) || color1ParentHover
5555
const gradientDirectionParentHover = getAttribute( 'backgroundGradientDirectionParentHover' ) || getAttribute( 'backgroundGradientDirectionParentHover' ) === 0 ? getAttribute( 'backgroundGradientDirectionParentHover' ) : 90
5656

57-
if ( color1 && color2 ) {
57+
const isColor1Gradient = color1 && color1.includes( '-gradient' )
58+
const isColor2Gradient = color2 && color2.includes( '-gradient' )
59+
if ( color1 && color2 && ! isColor1Gradient && ! isColor2Gradient ) {
5860
newAttributes[ getAttrName( 'backgroundColor' ) ] = `linear-gradient(${ gradientDirection }deg, ${ color1 } 0%, ${ color2 } 100%)`
5961
}
60-
if ( color1Hover && color2Hover ) {
62+
63+
const isColor1HoverGradient = color1Hover && color1Hover.includes( '-gradient' )
64+
const isColor2HoverGradient = color2Hover && color2Hover.includes( '-gradient' )
65+
if ( color1Hover && color2Hover && ! isColor1HoverGradient && ! isColor2HoverGradient ) {
6166
newAttributes[ getAttrName( 'backgroundColorHover' ) ] = `linear-gradient(${ gradientDirectionHover }deg, ${ color1Hover } 0%, ${ color2Hover } 100%)`
6267
}
63-
if ( color1ParentHover && color2ParentHover ) {
68+
69+
const isColor1ParentHoverGradient = color1ParentHover && color1ParentHover.includes( '-gradient' )
70+
const isColor2ParentHoverGradient = color2ParentHover && color2ParentHover.includes( '-gradient' )
71+
if ( color1ParentHover && color2ParentHover && ! isColor1ParentHoverGradient && ! isColor2ParentHoverGradient ) {
6472
newAttributes[ getAttrName( 'backgroundColorParentHover' ) ] = `linear-gradient(${ gradientDirectionParentHover }deg, ${ color1ParentHover } 0%, ${ color2ParentHover } 100%)`
6573
}
6674
}

src/block-components/button/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ const SizeControls = props => {
188188

189189
const buttonPaddingPlaceholder = getPlaceholder( paddingPlaceholderName, { single: false } )
190190

191-
const presetMarks = usePresetControls( 'spacingSizes' )?.getPresetMarks() || null
191+
const presetMarks = usePresetControls( 'spacingSizes' )
192+
?.getPresetMarks( { addNonePreset: true } ) || null
192193

193194
return ( <>
194195
{ props.hasFullWidth && (

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,24 @@ export const deprecateColumnAndRowGap = {
4141
const getAttrName = getAttrNameFunction( attrNameTemplate )
4242
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
4343

44+
const newAttributes = {
45+
...attributes,
46+
}
47+
4448
const columnSpacing = getAttribute( 'columnSpacing' )
4549
const columnGap = getAttribute( 'columnGap' )
4650
const rowGap = getAttribute( 'rowGap' )
4751

48-
const newAttributes = {
49-
...attributes,
50-
[ getAttrName( 'columnSpacing' ) ]: String( columnSpacing ),
51-
[ getAttrName( 'columnGap' ) ]: String( columnGap ),
52-
[ getAttrName( 'rowGap' ) ]: String( rowGap ),
52+
if ( typeof columnSpacing === 'number' ) {
53+
newAttributes[ getAttrName( 'columnSpacing' ) ] = String( columnSpacing )
54+
}
55+
56+
if ( typeof columnGap === 'number' ) {
57+
newAttributes[ getAttrName( 'columnGap' ) ] = String( columnGap )
58+
}
59+
60+
if ( typeof rowGap === 'number' ) {
61+
newAttributes[ getAttrName( 'rowGap' ) ] = String( rowGap )
5362
}
5463

5564
return newAttributes

src/block-components/columns/edit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ export const Controls = props => {
125125
: deviceType === 'Tablet' ? ( attributes.columnArrangementTablet || defaultArrangement )
126126
: ( attributes.columnArrangementMobile || defaultArrangement )
127127

128-
const presetMarks = usePresetControls( 'spacingSizes' )?.getPresetMarks() || null
129-
128+
const presetMarks = usePresetControls( 'spacingSizes' )
129+
?.getPresetMarks( { addNonePreset: true } ) || null
130130
return (
131131
<>
132132
{ props.hasColumnsControl && <ColumnsControl /> }

src/block-components/helpers/borders/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export const BorderControls = props => {
7171

7272
applyFilters( 'stackable.block-component.helpers.borders', null, getAttribute, updateAttributes )
7373

74-
const presetMarks = usePresetControls( 'borderRadius' )?.getPresetMarks() || null
74+
const presetMarks = usePresetControls( 'borderRadius' )
75+
?.getPresetMarks( { addNonePreset: true } ) || null
7576

7677
return (
7778
<Fragment>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ export const deprecateSizeControlHeight = {
2929
const getAttrName = getAttrNameFunction( attrNameTemplate )
3030
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
3131

32-
const height = getAttribute( 'height' )
33-
3432
const newAttributes = {
3533
...attributes,
36-
[ getAttrName( 'height' ) ]: String( height ),
34+
}
35+
36+
const height = getAttribute( 'height' )
37+
38+
if ( typeof height === 'number' ) {
39+
newAttributes[ getAttrName( 'height' ) ] = String( height )
3740
}
3841

3942
return newAttributes

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const Layout = props => {
3232
labelVerticalAlign = __( 'Content Vertical Align', i18n ),
3333
} = props.labels
3434

35-
const presetMarks = usePresetControls( 'blockHeights' )?.getPresetMarks() || null
35+
const presetMarks = usePresetControls( 'blockHeights' )
36+
?.getPresetMarks( { addNonePreset: true } ) || null
3637

3738
return (
3839
<>
@@ -139,13 +140,8 @@ const Spacing = props => {
139140
}
140141

141142
// Add additional presets for setting margins and paddings to None
142-
const nonePreset = {
143-
name: __( 'None', i18n ),
144-
size: '0rem',
145-
slug: 'none',
146-
}
147143
const presetMarks = usePresetControls( 'spacingSizes' )
148-
?.getPresetMarks( { additionalPresets: [ nonePreset ] } ) || null
144+
?.getPresetMarks( { addNonePreset: true } ) || null
149145

150146
return (
151147
<>

src/block-components/typography/deprecated.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ export const deprecateTypographyGradientColor = {
5858
if ( getAttribute( 'textColorType' ) === 'gradient' && getAttribute( 'textColor2' ) ) {
5959
const textColor1 = getAttribute( 'textColor1' ) || getAttribute( 'textColor2' )
6060
const textColor2 = getAttribute( 'textColor2' ) || getAttribute( 'textColor1' )
61-
const textGradientDirection = getAttribute( 'textGradientDirection' ) || getAttribute( 'textGradientDirection' ) === 0 ? getAttribute( 'textGradientDirection' ) : 180
62-
newAttributes[ getAttrName( 'textColor1' ) ] = `linear-gradient(${ textGradientDirection }deg, ${ textColor1 } 0%, ${ textColor2 } 100%)`
61+
62+
const isTextColor1Gradient = textColor1 && textColor1.includes( '-gradient' )
63+
const isTextColor2Gradient = textColor2 && textColor2.includes( '-gradient' )
64+
65+
if ( ! isTextColor1Gradient && ! isTextColor2Gradient ) {
66+
const textGradientDirection = getAttribute( 'textGradientDirection' ) || getAttribute( 'textGradientDirection' ) === 0 ? getAttribute( 'textGradientDirection' ) : 180
67+
newAttributes[ getAttrName( 'textColor1' ) ] = `linear-gradient(${ textGradientDirection }deg, ${ textColor1 } 0%, ${ textColor2 } 100%)`
68+
}
6369
}
6470

6571
return newAttributes
@@ -124,11 +130,14 @@ export const deprecateTypographyFontSize = {
124130
const getAttrName = getAttrNameFunction( attrNameTemplate )
125131
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
126132

127-
const fontSize = getAttribute( 'fontSize' )
128-
129133
const newAttributes = {
130134
...attributes,
131-
[ getAttrName( 'fontSize' ) ]: String( fontSize ),
135+
}
136+
137+
const fontSize = getAttribute( 'fontSize' )
138+
139+
if ( typeof fontSize === 'number' ) {
140+
newAttributes[ getAttrName( 'fontSize' ) ] = String( fontSize )
132141
}
133142

134143
return newAttributes

0 commit comments

Comments
 (0)