From 53ed8035e051d25fbfcbdb06c8a93a8d37e3a040 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Tue, 10 Dec 2024 15:28:34 +0530 Subject: [PATCH] Storybook: Add WritingModeControl story (#67343) * Storybook: Add WritingModeControl story * Enhance WritingModeControl usability and simplify structure * Simplify WritingModeControl story implementation Co-authored-by: Sukhendu2002 Co-authored-by: t-hamano --- .../stories/index.story.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 packages/block-editor/src/components/writing-mode-control/stories/index.story.js diff --git a/packages/block-editor/src/components/writing-mode-control/stories/index.story.js b/packages/block-editor/src/components/writing-mode-control/stories/index.story.js new file mode 100644 index 00000000000000..ea4bd65a37a000 --- /dev/null +++ b/packages/block-editor/src/components/writing-mode-control/stories/index.story.js @@ -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 ( + { + onChange( ...changeArgs ); + setValue( ...changeArgs ); + } } + value={ value } + /> + ); + }, +};