Skip to content

Commit 5238261

Browse files
committed
Merge branch 'feat/size-control-steps' into feat/new-design-library
2 parents 11a204e + 218c7b6 commit 5238261

File tree

97 files changed

+3838
-259
lines changed

Some content is hidden

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

97 files changed

+3838
-259
lines changed

e2e/tests/global-settings.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,26 @@ test.describe( 'Global Settings', () => {
8585
await page.getByLabel( 'Stackable Settings' ).click()
8686
await page.getByRole( 'button', { name: 'Global Typography' } ).click()
8787

88-
// Set Global Typography Styles of Heading 2 to have a font-size of 32
88+
// Set Global Typography Styles of Heading 2 to have a text-transform uppercase
8989
await page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).locator( '.components-base-control__field > .ugb-button-icon-control__wrapper > .components-button' ).click()
90-
await page.locator( '.stk-popover .components-base-control:nth-of-type(2)', { hasText: /Size/ } ).getByRole( 'textbox' ).fill( '32' )
90+
await page.locator( '.stk-popover .components-base-control:nth-of-type(4)', { hasText: /Transform/ } ).getByRole( 'listbox' ).selectOption( 'uppercase' )
9191
await page.locator( '.ugb-global-settings-typography-control' ).nth( 1 ).locator( '.components-base-control__field > .ugb-button-icon-control__wrapper > .components-button' ).click()
9292

93-
// Verify if the Heading 2 in Global Typography Styles has correct font size
94-
await expect( page.getByRole( 'heading', { name: 'Heading 2' } ) ).toHaveCSS( 'font-size', '32px' )
93+
// Verify if the Heading 2 in Global Typography Styles has correct text-transform
94+
await expect( page.getByRole( 'heading', { name: 'Heading 2' } ) ).toHaveCSS( 'text-transform', 'uppercase' )
9595

9696
// Open Block Settings
9797
await page.getByLabel( 'Settings', { exact: true } ).click()
9898

99-
// Check if the added Stackable Heading Block has a font-size of 32
99+
// Check if the added Stackable Heading Block has a text-transform uppercase
100100
editor.insertBlock( {
101101
name: 'stackable/heading',
102102
attributes: {
103103
text: 'test',
104104
},
105105
} )
106106

107-
await expect( editor.canvas.locator( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ).toHaveCSS( 'font-size', '32px' )
107+
await expect( editor.canvas.locator( '[data-type="stackable/heading"] > .stk-block-heading > h2[role="textbox"]' ) ).toHaveCSS( 'text-transform', 'uppercase' )
108108

109109
// Reset Global Typography Styles
110110
await page.getByLabel( 'Stackable Settings' ).click()

plugin.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Author: Gambit Technologies, Inc
77
* Author URI: http://gambit.ph
88
* Text Domain: stackable-ultimate-gutenberg-blocks
9-
* Version: 3.15.3
9+
* Version: 3.16.0
1010
*
1111
* @package Stackable
1212
*/
@@ -24,7 +24,7 @@
2424

2525
defined( 'STACKABLE_SHOW_PRO_NOTICES' ) || define( 'STACKABLE_SHOW_PRO_NOTICES', true );
2626
defined( 'STACKABLE_BUILD' ) || define( 'STACKABLE_BUILD', 'free' );
27-
defined( 'STACKABLE_VERSION' ) || define( 'STACKABLE_VERSION', '3.15.3' );
27+
defined( 'STACKABLE_VERSION' ) || define( 'STACKABLE_VERSION', '3.16.0' );
2828
defined( 'STACKABLE_FILE' ) || define( 'STACKABLE_FILE', __FILE__ );
2929
defined( 'STACKABLE_I18N' ) || define( 'STACKABLE_I18N', 'stackable-ultimate-gutenberg-blocks' ); // Plugin slug.
3030
defined( 'STACKABLE_DESIGN_LIBRARY_URL' ) || define( 'STACKABLE_DESIGN_LIBRARY_URL', 'https://storage.googleapis.com/stackable-plugin-assets' ); // Design Library CDN URL
@@ -235,6 +235,7 @@ function is_frontend() {
235235
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/spacing-and-borders/index.php' );
236236
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/buttons-and-icons/index.php' );
237237
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/color-schemes/index.php' );
238+
require_once( plugin_dir_path( __FILE__ ) . 'src/plugins/global-settings/preset-controls/index.php' );
238239
require_once( plugin_dir_path( __FILE__ ) . 'src/custom-block-styles.php' );
239240
require_once( plugin_dir_path( __FILE__ ) . 'src/css-optimize.php' );
240241
require_once( plugin_dir_path( __FILE__ ) . 'src/compatibility/index.php' );

src/block-components/block-div/deprecated.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { deprecationBackgrounColorOpacity, deprecateShadowColor } from '../helpers'
1+
import {
2+
deprecationBackgrounColorOpacity, deprecateShadowColor, deprecateSizeControlHeight,
3+
} from '../helpers'
24

35
import { addFilter } from '@wordpress/hooks'
46
import { semverCompare } from '~stackable/util'
@@ -38,3 +40,12 @@ export const deprecateBlockShadowColor = {
3840
return deprecateShadowColor.migrate( 'block%s' )( attributes )
3941
},
4042
}
43+
44+
export const deprecateBlockHeight = {
45+
isEligible: attributes => {
46+
return deprecateSizeControlHeight.isEligible( 'block%s' )( attributes )
47+
},
48+
migrate: attributes => {
49+
return deprecateSizeControlHeight.migrate( 'block%s' )( attributes )
50+
},
51+
}

src/block-components/block-div/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { CustomAttributes } from '../custom-attributes'
1818
import { version as VERSION } from 'stackable'
1919

2020
export { useUniqueId }
21-
export { deprecateBlockBackgroundColorOpacity, deprecateBlockShadowColor } from './deprecated'
21+
export {
22+
deprecateBlockBackgroundColorOpacity, deprecateBlockShadowColor, deprecateBlockHeight,
23+
} from './deprecated'
2224

2325
export const BlockDiv = memo( props => {
2426
const {

src/block-components/button/edit.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
AdvancedSelectControl,
1313
} from '~stackable/components'
1414
import { i18n } from 'stackable'
15-
import { useBlockAttributesContext, useBlockLayoutDefaults } from '~stackable/hooks'
15+
import {
16+
useBlockAttributesContext, useBlockLayoutDefaults, usePresetControls,
17+
} from '~stackable/hooks'
1618

1719
/**
1820
* WordPress dependencies
@@ -185,6 +187,9 @@ const SizeControls = props => {
185187
const { getPlaceholder } = useBlockLayoutDefaults()
186188

187189
const buttonPaddingPlaceholder = getPlaceholder( paddingPlaceholderName, { single: false } )
190+
191+
const presetMarks = usePresetControls( 'spacingSizes' )?.getPresetMarks() || null
192+
188193
return ( <>
189194
{ props.hasFullWidth && (
190195
<AdvancedToggleControl
@@ -228,6 +233,7 @@ const SizeControls = props => {
228233
title: __( 'Button padding', i18n ),
229234
description: __( 'Adjusts the space between the button text and button borders', i18n ),
230235
} }
236+
marks={ presetMarks }
231237
/>
232238
</> )
233239
}
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
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: {
4-
columnSpacing: {
5-
stkResponsive: true,
6-
stkUnits: 'px',
7-
type: 'number',
8-
default: '',
8+
columnWrapDesktop: { // Only applies to desktops
9+
type: 'boolean',
10+
default: false,
911
},
12+
},
13+
versionAdded: '3.0.0',
14+
versionDeprecated: '',
15+
} )
16+
17+
attrObject.add( {
18+
attributes: {
1019
columnGap: {
1120
stkResponsive: true,
12-
type: 'number',
21+
type: 'string',
1322
default: '',
1423
},
1524
rowGap: {
1625
stkResponsive: true,
17-
type: 'number',
26+
type: 'string',
1827
default: '',
1928
},
20-
columnWrapDesktop: { // Only applies to desktops
21-
type: 'boolean',
22-
default: false,
29+
columnSpacing: {
30+
stkResponsive: true,
31+
stkUnits: 'px',
32+
type: 'string',
33+
default: '',
2334
},
2435
},
25-
versionAdded: '3.0.0',
36+
attrNameTemplate,
37+
versionAdded: '3.15.3',
2638
versionDeprecated: '',
2739
} )
2840
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
columnSpacing: {
17+
stkResponsive: true,
18+
stkUnits: 'px',
19+
type: 'number',
20+
default: '',
21+
},
22+
},
23+
attrNameTemplate,
24+
versionAdded: '3.0.0',
25+
versionDeprecated: '3.15.3',
26+
} )
27+
}
28+
29+
export const deprecateColumnAndRowGap = {
30+
isEligible: attrNameTemplate => attributes => {
31+
const getAttrName = getAttrNameFunction( attrNameTemplate )
32+
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
33+
34+
const columnSpacing = getAttribute( 'columnSpacing' )
35+
const columnGap = getAttribute( 'columnGap' )
36+
const rowGap = getAttribute( 'rowGap' )
37+
38+
return typeof columnSpacing === 'number' || typeof columnGap === 'number' || typeof rowGap === 'number'
39+
},
40+
migrate: attrNameTemplate => attributes => {
41+
const getAttrName = getAttrNameFunction( attrNameTemplate )
42+
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
43+
44+
const columnSpacing = getAttribute( 'columnSpacing' )
45+
const columnGap = getAttribute( 'columnGap' )
46+
const rowGap = getAttribute( 'rowGap' )
47+
48+
const newAttributes = {
49+
...attributes,
50+
[ getAttrName( 'columnSpacing' ) ]: String( columnSpacing ),
51+
[ getAttrName( 'columnGap' ) ]: String( columnGap ),
52+
[ getAttrName( 'rowGap' ) ]: String( rowGap ),
53+
}
54+
55+
return newAttributes
56+
},
57+
}

src/block-components/columns/edit.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
useBlockSetAttributesContext,
2424
useDeviceType,
2525
useBlockLayoutDefaults,
26+
usePresetControls,
2627
} from '~stackable/hooks'
2728
import { range } from 'lodash'
2829

@@ -124,6 +125,8 @@ export const Controls = props => {
124125
: deviceType === 'Tablet' ? ( attributes.columnArrangementTablet || defaultArrangement )
125126
: ( attributes.columnArrangementMobile || defaultArrangement )
126127

128+
const presetMarks = usePresetControls( 'spacingSizes' )?.getPresetMarks() || null
129+
127130
return (
128131
<>
129132
{ props.hasColumnsControl && <ColumnsControl /> }
@@ -267,6 +270,7 @@ export const Controls = props => {
267270
// Add a working video
268271
description: __( 'Sets column paddings, the space inside the block between the block elements and the column container border', i18n ),
269272
} }
273+
marks={ presetMarks }
270274
/>
271275
<AdvancedRangeControl
272276
label={ __( 'Column Gap', i18n ) }
@@ -284,6 +288,7 @@ export const Controls = props => {
284288
video: 'column-gap',
285289
description: __( 'Sets the distance between two or more columns', i18n ),
286290
} }
291+
marks={ presetMarks }
287292
/>
288293
<AdvancedRangeControl
289294
label={ __( 'Row Gap', i18n ) }
@@ -296,6 +301,7 @@ export const Controls = props => {
296301
// TODO: Add a working video
297302
description: __( 'Sets the distance between two or more columns', i18n ),
298303
} }
304+
marks={ presetMarks }
299305
/>
300306
</>
301307
) }

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: 32 additions & 5 deletions
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', [ {
@@ -30,16 +36,27 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
3036
selector: '.%s-column',
3137
styleRule: '--stk-column-gap',
3238
attrName: 'columnGap',
33-
format: '%spx',
3439
responsive: 'all',
40+
valueCallback: value => {
41+
// Substitute with using format to work with preset controls
42+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
43+
return value
44+
}
45+
return value + 'px'
46+
},
3547
}, {
3648
...propsToPass,
3749
renderIn: 'edit',
3850
selector: '.%s-column > .block-editor-inner-blocks > .block-editor-block-list__layout',
3951
styleRule: '--stk-column-gap',
4052
attrName: 'columnGap',
41-
format: '%spx',
4253
responsive: 'all',
54+
valueCallback: value => {
55+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
56+
return value
57+
}
58+
return value + 'px'
59+
},
4360
} ] )
4461

4562
blockStyleGenerator.addBlockStyles( 'columnWrapDesktop', [ {
@@ -78,16 +95,26 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
7895
selector: '.%s-column',
7996
styleRule: 'rowGap',
8097
attrName: 'rowGap',
81-
format: '%spx',
8298
responsive: 'all',
99+
valueCallback: value => {
100+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
101+
return value
102+
}
103+
return value + 'px'
104+
},
83105
}, {
84106
...propsToPass,
85107
renderIn: 'edit',
86108
selector: '.%s-column > .block-editor-inner-blocks > .block-editor-block-list__layout',
87109
styleRule: 'rowGap',
88110
attrName: 'rowGap',
89-
format: '%spx',
90111
responsive: 'all',
112+
valueCallback: value => {
113+
if ( typeof value === 'string' && value.startsWith( 'var' ) ) {
114+
return value
115+
}
116+
return value + 'px'
117+
},
91118
} ] )
92119
}
93120

0 commit comments

Comments
 (0)