Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook: Add Story for Block Patterns Setup Component #68516

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@ function BlockPatternSlide( { active, className, pattern, minHeight } ) {
);
}

/**
* BlockPatternSetup component displays a list of block patterns in a carousel or grid view.
*
* @param {Object} props Component props.
* @param {string} props.clientId The client ID of the block being edited.
* @param {string} props.blockName The name of the block being edited.
* @param {Function} props.filterPatternsFn Function to filter patterns.
* @param {Function} props.onBlockPatternSelect Function to call when a pattern is selected.
* @param {string} props.initialViewMode The initial view mode for the block pattern setup.
* @param {boolean} props.showTitles Whether to show pattern titles.
*
* @return {Element} The block pattern setup component.
*
* @example
* ```jsx
* <BlockPatternSetup
* clientId="clientId"
* blockName="core/paragraph"
* filterPatternsFn={ ( pattern ) => pattern.name === 'pattern-name' }
* onBlockPatternSelect={ ( ) => { } }
* initialViewMode="carousel"
* showTitles={ false }
* />
*/
const BlockPatternSetup = ( {
clientId,
blockName,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Internal dependencies
*/
import BlockPatternSetup from '..';

/**
* WordPress dependencies
*/
import { registerCoreBlocks } from '@wordpress/block-library';
import { createBlock } from '@wordpress/blocks';

registerCoreBlocks();
const block = createBlock( 'core/paragraph', {
content: 'Sample paragraph content',
} );

/**
* Storybook metadata
*/
const meta = {
title: 'Components/BlockPatternSetup',
component: BlockPatternSetup,
parameters: {
docs: {
canvas: {
sourceState: 'shown',
},
description: {
component:
'BlockPatternSetup component displays a list of block patterns in a carousel or grid view.',
},
},
},
argTypes: {
clientId: {
control: { type: null },
description: 'The client ID of the block being edited.',
table: {
type: {
summary: 'string',
},
},
},
blockName: {
control: {
type: 'text',
},
description: 'The name of the block being edited.',
table: {
type: {
summary: 'string',
},
},
},
filterPatternsFn: {
control: { type: null },
description: 'Function to filter patterns.',
table: {
type: {
summary: 'function',
},
},
},
onBlockPatternSelect: {
control: { type: null },
description: 'Function to call when a pattern is selected.',
table: {
type: {
summary: 'function',
},
},
},
initialViewMode: {
control: {
type: 'text',
},
description: 'The initial view mode for the block pattern setup.',
table: {
type: {
summary: 'string',
},
},
},
showTitles: {
control: {
type: 'boolean',
},
description: 'Whether to show titles for block patterns.',
table: {
type: {
summary: 'boolean',
},
},
},
},
};

export default meta;

/**
* Default story for the BlockPatternSetup component
*/
export const Default = {
args: {
clientId: block.clientId,
blockName: 'core/paragraph',
filterPatternsFn: null,
onBlockPatternSelect: () => {},
initialViewMode: 'carousel',
showTitles: true,
},
render: function Template( args ) {
return <BlockPatternSetup { ...args } />;
},
};
Loading