-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block Editor: Add documentation for SpacingSizesControl component (#6…
…8581) * Block Editor: Add documentation for SpacingSizesControl component * Refactor `SpacingSizesControl` to use individual side values * Simplify component example and documentation - Removed unnecessary props and wrappers - Added proper state management with useState hook - Ensured consistent documentation between the component and README - Replaced SpacerBlock with Example component - Added proper imports for SpacingSizesControl and useState - Removed unnecessary View wrapper and optional props - Updated README to match the new implementation * Consolidate README and update import examples - Removed redundant description section in README - Consolidated component description into a single paragraph - Updated import examples to use `__experimentalSpacingSizesControl` alias - Removed screenshot reference - Standardized prop descriptions Co-authored-by: Infinite-Null <[email protected]> Co-authored-by: stokesman <[email protected]> Co-authored-by: glendaviesnz <[email protected]> Co-authored-by: mburridge <[email protected]>
- Loading branch information
1 parent
bf32d27
commit 73b8e2c
Showing
2 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
packages/block-editor/src/components/spacing-sizes-control/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Spacing Sizes Control | ||
|
||
The SpacingSizesControl component provides a flexible user interface for controlling spacing values in blocks, allowing users to modify values for different sides. It supports three viewing modes: | ||
|
||
1. Single: Control one side at a time. | ||
2. Axial: Control horizontal and vertical sides together. | ||
3. Custom: Control each side separately. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor'; | ||
import { useState } from '@wordpress/element'; | ||
|
||
function Example() { | ||
const [ sides, setSides ] = useState( { | ||
top: '0px', | ||
right: '0px', | ||
bottom: '0px', | ||
left: '0px', | ||
} ); | ||
|
||
return ( | ||
<SpacingSizesControl | ||
values={ sides } | ||
onChange={ setSides } | ||
label="Sides" | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
## Props | ||
|
||
### `inputProps` | ||
|
||
- Type: `Object` | ||
- Required: No | ||
- Description: Additional props to pass to the input controls. | ||
|
||
### `label` | ||
|
||
- Type: `String` | ||
- Required: Yes | ||
- Description: Label for the control. | ||
|
||
### `minimumCustomValue` | ||
|
||
- Type: `Number` | ||
- Default: 0 | ||
- Description: Minimum value allowed for custom input. | ||
|
||
### `onChange` | ||
|
||
- Type: `Function` | ||
- Required: Yes | ||
- Description: Callback function called when spacing values change. Receives an object containing the updated values. | ||
|
||
### `onMouseOut` | ||
|
||
- Type: `Function` | ||
- Required: No | ||
- Description: Callback function called when mouse leaves the control. | ||
|
||
### `onMouseOver` | ||
|
||
- Type: `Function` | ||
- Required: No | ||
- Description: Callback function called when mouse enters the control. | ||
|
||
### `showSideInLabel` | ||
|
||
- Type: `Boolean` | ||
- Default: true | ||
- Description: Whether to show the side (top, right, etc.) in the control label. | ||
|
||
### `sides` | ||
|
||
- Type: `Array` | ||
- Default: ALL_SIDES (top, right, bottom, left) | ||
- Description: Array of sides that can be controlled. | ||
|
||
### `useSelect` | ||
|
||
- Type: `Boolean` | ||
- Required: No | ||
- Description: Whether to use a select control for predefined values. | ||
|
||
### `values` | ||
|
||
- Type: `Object` | ||
- Required: No | ||
- Description: Object containing the current spacing values for each side. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters