Skip to content

Commit 0b671a4

Browse files
committed
fix: add inner column spacing presets
1 parent 1e35989 commit 0b671a4

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

src/block-components/columns/attributes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ export const addAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
55

66
attrObject.add( {
77
attributes: {
8-
columnSpacing: {
9-
stkResponsive: true,
10-
stkUnits: 'px',
11-
type: 'number',
12-
default: '',
13-
},
148
columnWrapDesktop: { // Only applies to desktops
159
type: 'boolean',
1610
default: false,
@@ -32,6 +26,12 @@ export const addAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
3226
type: 'string',
3327
default: '',
3428
},
29+
columnSpacing: {
30+
stkResponsive: true,
31+
stkUnits: 'px',
32+
type: 'string',
33+
default: '',
34+
},
3535
},
3636
attrNameTemplate,
3737
versionAdded: '3.15.3',

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export const deprecatedAddAttributes = ( attrObject, attrNameTemplate = '%s' ) =
1313
type: 'number',
1414
default: '',
1515
},
16+
columnSpacing: {
17+
stkResponsive: true,
18+
stkUnits: 'px',
19+
type: 'number',
20+
default: '',
21+
},
1622
},
1723
attrNameTemplate,
1824
versionAdded: '3.0.0',
@@ -25,20 +31,23 @@ export const deprecateColumnAndRowGap = {
2531
const getAttrName = getAttrNameFunction( attrNameTemplate )
2632
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
2733

34+
const columnSpacing = getAttribute( 'columnSpacing' )
2835
const columnGap = getAttribute( 'columnGap' )
2936
const rowGap = getAttribute( 'rowGap' )
3037

31-
return typeof columnGap === 'number' || typeof rowGap === 'number'
38+
return typeof columnSpacing === 'number' || typeof columnGap === 'number' || typeof rowGap === 'number'
3239
},
3340
migrate: attrNameTemplate => attributes => {
3441
const getAttrName = getAttrNameFunction( attrNameTemplate )
3542
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
3643

44+
const columnSpacing = getAttribute( 'columnSpacing' )
3745
const columnGap = getAttribute( 'columnGap' )
3846
const rowGap = getAttribute( 'rowGap' )
3947

4048
const newAttributes = {
4149
...attributes,
50+
[ getAttrName( 'columnSpacing' ) ]: String( columnSpacing ),
4251
[ getAttrName( 'columnGap' ) ]: String( columnGap ),
4352
[ getAttrName( 'rowGap' ) ]: String( rowGap ),
4453
}

src/block-components/columns/edit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export const Controls = props => {
270270
// Add a working video
271271
description: __( 'Sets column paddings, the space inside the block between the block elements and the column container border', i18n ),
272272
} }
273+
marks={ presetMarks }
273274
/>
274275
<AdvancedRangeControl
275276
label={ __( 'Column Gap', i18n ) }

src/block-components/columns/style.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
2020
selector: '.%s-column',
2121
styleRule: '--stk-columns-spacing',
2222
attrName: 'columnSpacing',
23-
hasUnits: 'px',
2423
responsive: 'all',
24+
valueCallback: value => {
25+
// Substitute with using format to work with preset controls
26+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
27+
return value
28+
}
29+
return value + 'px'
30+
},
2531
} ] )
2632

2733
blockStyleGenerator.addBlockStyles( 'columnGap', [ {

0 commit comments

Comments
 (0)