From e29541d0ccbd96a7192299cfa581fed9d0bab039 Mon Sep 17 00:00:00 2001 From: Sainath Poojary <53347682+SainathPoojary@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:06:25 +0530 Subject: [PATCH] Storybook: Add stories for BlockTitle Component (#67234) * Doc: Add Storybook for BlockTitle * Refactor: Simplify Storybook for BlockTitle and add type summaries to controls * Refactor: Updated descriptions to match the JSDoc * Refactor: Remove comment from BlockTitle story * Storybook: Refactor BlockTitle story to use ExperimentalBlockEditorProvider - Replaced BlockEditorProvider with ExperimentalBlockEditorProvider. - Simplified blocks array to include a single paragraph block. - Removed unnecessary client ID mappings and control options. - Cleaned up redundant comments and controls. * Storybook: Set clientId control to null for BlockTitle Co-authored-by: SainathPoojary Co-authored-by: t-hamano Co-authored-by: swissspidy --- .../block-title/stories/index.story.js | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 packages/block-editor/src/components/block-title/stories/index.story.js diff --git a/packages/block-editor/src/components/block-title/stories/index.story.js b/packages/block-editor/src/components/block-title/stories/index.story.js new file mode 100644 index 00000000000000..dc66fc721e5158 --- /dev/null +++ b/packages/block-editor/src/components/block-title/stories/index.story.js @@ -0,0 +1,76 @@ +/** + * WordPress dependencies + */ +import { registerCoreBlocks } from '@wordpress/block-library'; +import { createBlock } from '@wordpress/blocks'; + +/** + * Internal dependencies + */ +import { ExperimentalBlockEditorProvider } from '../../provider'; +import BlockTitle from '../'; + +// Register core blocks for the story environment +registerCoreBlocks(); + +// Sample blocks for testing +const blocks = [ createBlock( 'core/paragraph' ) ]; + +const meta = { + title: 'BlockEditor/BlockTitle', + component: BlockTitle, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + "Renders the block's configured title as a string, or empty if the title cannot be determined.", + }, + }, + }, + decorators: [ + ( Story ) => ( + + + + ), + ], + argTypes: { + clientId: { + control: { type: null }, + description: 'Client ID of block.', + table: { + type: { + summary: 'string', + }, + }, + }, + maximumLength: { + control: { type: 'number' }, + description: + 'The maximum length that the block title string may be before truncated.', + table: { + type: { + summary: 'number', + }, + }, + }, + context: { + control: { type: 'text' }, + description: 'The context to pass to `getBlockLabel`.', + table: { + type: { + summary: 'string', + }, + }, + }, + }, +}; + +export default meta; + +export const Default = { + args: { + clientId: blocks[ 0 ].clientId, + }, +};