From 49159ab9f8b71caec1892084c7fb9c11234e7400 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Mon, 13 Jan 2025 15:58:41 +0530 Subject: [PATCH 1/2] Storybook: Add Story for Block Manager --- .../block-manager/stories/index.story.js | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 packages/block-editor/src/components/block-manager/stories/index.story.js diff --git a/packages/block-editor/src/components/block-manager/stories/index.story.js b/packages/block-editor/src/components/block-manager/stories/index.story.js new file mode 100644 index 00000000000000..5e47f348694cc1 --- /dev/null +++ b/packages/block-editor/src/components/block-manager/stories/index.story.js @@ -0,0 +1,97 @@ +/** + * Internal dependencies + */ +import BlockManager from '..'; + +/** + * WordPress dependencies + */ +import { useState } from '@wordpress/element'; + +const meta = { + title: 'BlockEditor/BlockManager', + component: BlockManager, + tags: [ 'status-private' ], + parameters: { + docs: { + canvas: { + sourceState: 'shown', + }, + description: { + component: + 'The BlockSwitcher component is used to switch between different block types.', + }, + }, + }, + argTypes: { + blockTypes: { + control: { + type: null, + }, + description: 'An array of blocks.', + table: { + type: { summary: 'Array' }, + }, + }, + selectedBlockTypes: { + control: { + type: null, + }, + description: 'An array of selected blocks.', + table: { + type: { summary: 'Array' }, + }, + }, + onChange: { + action: 'onChange', + control: { + type: null, + }, + description: + 'Function to be called when the selected blocks change.', + table: { + type: { + summary: 'Function', + }, + }, + }, + }, +}; + +export default meta; + +export const Default = { + args: { + blockTypes: [ + { + name: 'core/paragraph', + title: 'Paragraph', + }, + { + name: 'core/heading', + title: 'Heading', + }, + ], + selectedBlockTypes: [ + { + name: 'core/heading', + title: 'Heading', + }, + ], + }, + render: function Template( { onChange, ...args } ) { + const [ selectedBlockTypes, setSelectedBlockTypes ] = useState( + args.selectedBlockTypes + ); + return ( + { + setSelectedBlockTypes( newSelectedBlockTypes ); + onChange( newSelectedBlockTypes ); + } } + selectedBlockTypes={ selectedBlockTypes } + /> + ); + }, +}; From 846ba05515c454492b5fc0ee6e7ea5143b317292 Mon Sep 17 00:00:00 2001 From: Rishit Gupta <74411873+Rishit30G@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:19:21 +0530 Subject: [PATCH 2/2] Update description --- .../src/components/block-manager/stories/index.story.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/block-manager/stories/index.story.js b/packages/block-editor/src/components/block-manager/stories/index.story.js index 5e47f348694cc1..8b0055e69462db 100644 --- a/packages/block-editor/src/components/block-manager/stories/index.story.js +++ b/packages/block-editor/src/components/block-manager/stories/index.story.js @@ -19,7 +19,7 @@ const meta = { }, description: { component: - 'The BlockSwitcher component is used to switch between different block types.', + 'The `BlockManager` component displays a list of blocks with quick navigation.', }, }, },