-
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.
Storybook: Add WritingModeControl story (#67343)
* Storybook: Add WritingModeControl story * Enhance WritingModeControl usability and simplify structure * Simplify WritingModeControl story implementation Co-authored-by: Sukhendu2002 <[email protected]> Co-authored-by: t-hamano <[email protected]>
- Loading branch information
1 parent
207dfe3
commit 53ed803
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/block-editor/src/components/writing-mode-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,56 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import WritingModeControl from '../'; | ||
|
||
const meta = { | ||
title: 'BlockEditor/WritingModeControl', | ||
component: WritingModeControl, | ||
parameters: { | ||
docs: { | ||
canvas: { sourceState: 'shown' }, | ||
description: { | ||
component: 'Control to facilitate writing mode selections.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
value: { | ||
control: { type: null }, | ||
description: 'Currently selected writing mode.', | ||
}, | ||
className: { | ||
control: 'text', | ||
description: 'Class name to add to the control.', | ||
}, | ||
onChange: { | ||
action: 'onChange', | ||
control: { type: null }, | ||
description: 'Handles change in the writing mode selection.', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
render: function Template( { onChange, ...args } ) { | ||
const [ value, setValue ] = useState(); | ||
|
||
return ( | ||
<WritingModeControl | ||
{ ...args } | ||
onChange={ ( ...changeArgs ) => { | ||
onChange( ...changeArgs ); | ||
setValue( ...changeArgs ); | ||
} } | ||
value={ value } | ||
/> | ||
); | ||
}, | ||
}; |