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 List #68777

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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 @@ -6,59 +6,147 @@ import blockLibraryStyles from '!!raw-loader!../../../../../block-library/build-
/**
* Internal dependencies
*/
import BlockPatternsList from '../';
import { ExperimentalBlockEditorProvider } from '../../provider';
import BlockPatternsList from '..';
import patterns from './fixtures';
import { ExperimentalBlockEditorProvider } from '../../provider';

/**
* WordPress dependencies
*/
import { registerCoreBlocks } from '@wordpress/block-library';
import { __ } from '@wordpress/i18n';
registerCoreBlocks();

const blockEditorSettings = {
styles: [ { css: blockLibraryStyles } ],
};

export default {
component: BlockPatternsList,
/**
* Storybook metadata
*/
const meta = {
title: 'BlockEditor/BlockPatternsList',
};

export const Default = {
render: function Template( props ) {
return (
<ExperimentalBlockEditorProvider settings={ blockEditorSettings }>
<BlockPatternsList { ...props } />
</ExperimentalBlockEditorProvider>
);
},
args: {
blockPatterns: patterns,
isDraggable: false,
label: 'Block patterns story',
showTitlesAsTooltip: false,
component: BlockPatternsList,
parameters: {
docs: {
canvas: {
sourceState: 'shown',
},
description: {
component:
'The `BlockPatternsList` component renders a list of block patterns.',
},
},
},
argTypes: {
blockPatterns: { description: 'The patterns to render.' },
blockPatterns: {
control: {
type: 'object',
},
description: 'The patterns to render.',
table: {
type: {
summary: 'object',
},
},
},
shownPatterns: {
contorl: { type: null },
description:
'Usually this component is used with `useAsyncList` for performance reasons and you should provide the returned list from that hook. Alternatively it should have the same value with `blockPatterns`.',
'Usually this component is used with `useAsyncList` for performance reasons and you should provide the returned list from that hook. Alternatively it should have the same value with `blockPatterns.`',
table: {
type: {
summary: 'object',
},
},
},
onClickPattern: {
control: { type: null },
description:
'Callback function to handle the click event on a pattern.',
table: {
type: {
summary: 'function',
},
},
},
onHover: {
control: {
type: null,
},
description:
'Callback function to handle the hover event on a pattern.',
table: {
type: {
summary: 'function',
},
},
},
onClickPattern: { type: 'function' },
onHover: { type: 'function' },
showTitlesAsTooltip: {
control: {
type: 'boolean',
},
description:
'Whether to render the title of each pattern as a tooltip. If enabled',
table: {
type: {
summary: 'boolean',
},
},
},
orientation: {
control: {
type: 'string',
},
description: 'Orientation for the underlying composite widget.',
table: {
defaultValue: { summary: 'both' },
type: { summary: 'string' },
defaultValue: {
summary: 'both',
},
type: {
summary: 'string',
},
},
},
category: {
control: {
type: 'string',
},
description: 'The currently selected pattern category.',
table: {
type: {
summary: 'string',
},
},
},
category: { description: 'The currently selected pattern category.' },
isDraggable: {
control: {
type: 'boolean',
},
description: 'Whether the pattern list item should be draggable.',
table: {
type: {
summary: 'boolean',
},
},
},
},
parameters: {
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
};

export default meta;

export const Default = {
args: {
blockPatterns: patterns,
isDraggable: false,
label: __( 'Block patterns story' ),
showTitlesAsTooltip: false,
},
render: function Template( args ) {
return (
<ExperimentalBlockEditorProvider settings={ blockEditorSettings }>
<BlockPatternsList { ...args } />
</ExperimentalBlockEditorProvider>
);
},
};
Loading