From 101bbd2b7a8dff0d9ca8b1260461ae97e3ce4f20 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Tue, 10 Dec 2024 15:36:56 +0530 Subject: [PATCH] Storybook: Add stories for HeadingLevelDropdown component (#67294) * Storybook: Add HeadingLevelDropdown Stories * Update HeadingLevelDropdown story to CSF 3 * Update control types * Update HeadingLevelDropdown story for improved usability Co-authored-by: Sukhendu2002 Co-authored-by: dcalhoun Co-authored-by: t-hamano --- .../stories/index.story.js | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 packages/block-editor/src/components/block-heading-level-dropdown/stories/index.story.js diff --git a/packages/block-editor/src/components/block-heading-level-dropdown/stories/index.story.js b/packages/block-editor/src/components/block-heading-level-dropdown/stories/index.story.js new file mode 100644 index 00000000000000..a8293258f7a001 --- /dev/null +++ b/packages/block-editor/src/components/block-heading-level-dropdown/stories/index.story.js @@ -0,0 +1,61 @@ +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +/** + * Internal dependencies + */ +import HeadingLevelDropdown from '../'; + +const meta = { + title: 'BlockEditor/HeadingLevelDropdown', + component: HeadingLevelDropdown, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'Dropdown for selecting a heading level (1 through 6) or paragraph (0).', + }, + }, + }, + argTypes: { + value: { + control: { type: null }, + description: 'The chosen heading level.', + }, + options: { + control: 'check', + options: [ 1, 2, 3, 4, 5, 6 ], + description: 'An array of supported heading levels.', + }, + onChange: { + action: 'onChange', + control: { type: null }, + description: 'Function called with the selected value changes.', + }, + }, +}; + +export default meta; + +export const Default = { + render: function Template( { onChange, ...args } ) { + const [ value, setValue ] = useState( args.value ); + + return ( + { + setValue( ...changeArgs ); + onChange( ...changeArgs ); + } } + /> + ); + }, + args: { + value: 2, + }, +};