diff --git a/packages/block-editor/src/components/block-alignment-control/README.md b/packages/block-editor/src/components/block-alignment-control/README.md index 22b5df9af9bd42..117defe36c8a26 100644 --- a/packages/block-editor/src/components/block-alignment-control/README.md +++ b/packages/block-editor/src/components/block-alignment-control/README.md @@ -38,6 +38,20 @@ The current value of the alignment setting. You may only choose from the `Option A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: `left`, `center`, `right`, `wide`, `full`) as the only argument. +### `controls` + +- **Type:** `Array` +- **Default:** [ `none`, `left`, `center`, `right`, `wide`, `full` ] + +An array of available alignment controls. + +### `isCollapsed` + +- **Type:** `Boolean` +- **Default:** `true` + +Whether the toolbar should be collapsed. Default is true. + ## Related components Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree. diff --git a/packages/block-editor/src/components/block-alignment-control/stories/block-alignment-toolbar.story.js b/packages/block-editor/src/components/block-alignment-control/stories/block-alignment-toolbar.story.js new file mode 100644 index 00000000000000..d1553763b1d3e5 --- /dev/null +++ b/packages/block-editor/src/components/block-alignment-control/stories/block-alignment-toolbar.story.js @@ -0,0 +1,64 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import { BlockAlignmentToolbar } from '../'; + +export default { + title: 'BlockEditor/BlockAlignmentToolbar', + component: BlockAlignmentToolbar, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'A control for selecting block alignment options in the toolbar. The different alignment options it provides are `left`, `center`, `right`, `wide` and `full`', + }, + }, + }, + argTypes: { + value: { + control: { type: null }, + description: 'The current value of the alignment setting.', + }, + onChange: { + action: 'onChange', + control: { type: null }, + description: + "A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie:`left`, `center`, `right`, `wide`, and `full`) as the only argument.", + }, + controls: { + control: { type: null }, + description: 'An array of available alignment controls.', + }, + isCollapsed: { + control: 'boolean', + description: 'Whether the toolbar should be collapsed.', + }, + }, +}; + +export const Default = { + render: function Template( { onChange, ...args } ) { + const [ value, setValue ] = useState(); + return ( + { + onChange( ...changeArgs ); + setValue( ...changeArgs ); + } } + value={ value } + /> + ); + }, +}; + +Default.args = { + defaultValue: 'undefined', + panelId: 'panel-id', +}; diff --git a/packages/block-editor/src/components/block-alignment-control/stories/index.story.js b/packages/block-editor/src/components/block-alignment-control/stories/index.story.js new file mode 100644 index 00000000000000..1d79d85843282a --- /dev/null +++ b/packages/block-editor/src/components/block-alignment-control/stories/index.story.js @@ -0,0 +1,54 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import { BlockAlignmentControl } from '../'; + +const meta = { + title: 'BlockEditor/BlockAlignmentControl', + component: BlockAlignmentControl, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'A control for selecting block alignment options in the editor. The different alignment options it provides are `left`, `center`, `right`, `wide` and `full`', + }, + }, + }, + argTypes: { + value: { + control: { type: null }, + defaultValue: 'undefined', + description: 'The current value of the alignment setting.', + }, + onChange: { + action: 'onChange', + control: { type: null }, + description: + "A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie:`left`, `center`, `right`, `wide`, and `full`) as the only argument.", + }, + }, +}; + +export default meta; + +export const Default = { + render: function Template( { onChange, ...args } ) { + const [ value, setValue ] = useState(); + return ( + { + onChange( ...changeArgs ); + setValue( ...changeArgs ); + } } + value={ value } + /> + ); + }, +};