-
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.
Add stories for BlockAlignmentControl and BlockAlignmentToolbar compo…
…nents
- Loading branch information
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...ck-editor/src/components/block-alignment-control/stories/block-alignment-toolbar.story.js
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,48 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { BlockAlignmentToolbar } from '../'; | ||
|
||
/** | ||
* The `BlockAlignmentToolbar` component is used to render block alignment options in the editor. The different alignment options it provides are `left`, `center`, `right`, `wide` and `full`. | ||
*/ | ||
const meta = { | ||
title: 'BlockEditor/BlockAlignmentToolbar', | ||
component: BlockAlignmentToolbar, | ||
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; | ||
|
||
const Template = ( { onChange, ...args } ) => { | ||
const [ value, setValue ] = useState(); | ||
return ( | ||
<BlockAlignmentToolbar | ||
{ ...args } | ||
onChange={ ( ...changeArgs ) => { | ||
onChange( ...changeArgs ); | ||
setValue( ...changeArgs ); | ||
} } | ||
value={ value } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind(); |
50 changes: 50 additions & 0 deletions
50
packages/block-editor/src/components/block-alignment-control/stories/index.story.js
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,50 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { BlockAlignmentControl } from '../'; | ||
|
||
/** | ||
* The `BlockAlignmentControl` component is used to render block alignment options in the editor. The different alignment options it provides are `left`, `center`, `right`, `wide` and `full`. | ||
* | ||
* If you want to use the block alignment control in a toolbar, you should use the `BlockAlignmentToolbar` component instead. | ||
*/ | ||
const meta = { | ||
title: 'BlockEditor/BlockAlignmentControl', | ||
component: BlockAlignmentControl, | ||
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; | ||
|
||
const Template = ( { onChange, ...args } ) => { | ||
const [ value, setValue ] = useState(); | ||
return ( | ||
<BlockAlignmentControl | ||
{ ...args } | ||
onChange={ ( ...changeArgs ) => { | ||
onChange( ...changeArgs ); | ||
setValue( ...changeArgs ); | ||
} } | ||
value={ value } | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind(); |