feat: size and spacing steps#3452
Conversation
🤖 Pull request artifacts
|
…/Stackable into feat/size-control-steps
There was a problem hiding this comment.
Pull Request Overview
This PR enhances size and spacing controls by integrating preset controls, expanding unit support, deprecating old numeric attributes in favor of responsive string values, and refactoring style generators to use valueCallback.
- Added
usePresetControlshooks andmarksto various range controls for height, spacing, borders, columns, alignment, and buttons. - Deprecated numeric size/spacing attributes and introduced string-based attributes with migration helpers.
- Replaced
format: '%spx'withvalueCallbackin style files for consistent CSS variable handling and appendedpx.
Reviewed Changes
Copilot reviewed 102 out of 102 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/block-components/helpers/size/edit.js | Expanded units, added usePresetControls import and marks |
| src/block-components/helpers/size/deprecated.js | Defined deprecation helper for numeric height attribute |
| src/block-components/helpers/size/attributes.js | Invoked deprecation, added new string‐based height attribute |
| src/block-components/helpers/borders/style.js | Replaced format with valueCallback for all corner radii |
| src/block-components/helpers/borders/edit.js | Imported usePresetControls, added marks to BorderRadius |
| src/block-components/columns/style.js | Swapped format for valueCallback on spacing style rules |
| src/block-components/columns/index.js | Exported new deprecation helper deprecateColumnAndRowGap |
| src/block-components/columns/edit.js | Added usePresetControls import and marks to range controls |
| src/block-components/columns/deprecated/index.js | Defined deprecated attributes and migration for column/row gaps |
| src/block-components/columns/attributes.js | Invoked column/row gap deprecation, added new string‐type attrs |
| src/block-components/button/edit.js | Imported usePresetControls, added marks to button padding |
| src/block-components/block-div/index.js | Exported new deprecateBlockHeight helper |
| src/block-components/block-div/deprecated.js | Added deprecateBlockHeight migration |
| src/block-components/alignment/style.js | Replaced format with valueCallback on innerBlock gaps |
| src/block-components/alignment/index.js | Exported deprecateInnerBlockRowGapAndContainerHeight |
| src/block-components/alignment/edit.js | Added usePresetControls, injected marks into range controls |
| src/block-components/alignment/deprecated/index.js | Defined deprecation helper for inner block row gap |
| src/block-components/alignment/attributes.js | Invoked deprecation, added new string‐type innerBlockRowGap |
| plugin.php | Bumped plugin version to 3.16.0, required preset-controls |
| e2e/tests/global-settings.spec.ts | Updated test for text-transform instead of font-size |
| key: 'borderTopLeftRadius2', | ||
| attrNameTemplate, | ||
| format: '%spx', | ||
| valueCallback: value => { |
There was a problem hiding this comment.
This valueCallback logic is duplicated for each corner. Extract a shared helper function (e.g., appendPxOrVar) to reduce repetition and improve readability.
| valueCallback: value => { | ||
| // Substitute with using format to work with preset controls | ||
| if ( typeof value === 'string' && value.startsWith( 'var' ) ) { | ||
| return value | ||
| } | ||
| return value + 'px' | ||
| }, |
There was a problem hiding this comment.
The same valueCallback pattern is repeated across multiple style rules. Consider creating a utility to handle 'var' checks and 'px' suffixing to avoid duplication.
| valueCallback: value => { | |
| // Substitute with using format to work with preset controls | |
| if ( typeof value === 'string' && value.startsWith( 'var' ) ) { | |
| return value | |
| } | |
| return value + 'px' | |
| }, | |
| valueCallback: formatValue, |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
fixes #3474