Skip to content

Commit

Permalink
Storybook: Add Story for Block Styles Component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishit30G committed Jan 13, 2025
1 parent d039f91 commit 6a18b3c
Showing 1 changed file with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Internal dependencies
*/
import BlockStyles from '..';

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

registerCoreBlocks();

const blockEditorState = [ createBlock( 'core/paragraph' ) ];

dispatch( 'core/block-editor' ).resetBlocks( blockEditorState );

const meta = {
title: 'BlockEditor/BlockStyles',
component: BlockStyles,
parameters: {
docs: {
canvas: {
sourceState: 'shown',
},
description: {
component:
'The `BlockStyles` component renders a list of block styles for a given block.',
},
},
},
argTypes: {
clientId: {
control: {
type: 'text',
},
description: 'The block client ID.',
table: {
type: {
summary: 'string',
},
},
},
onSwitch: {
control: {
type: 'function',
},
description: 'Callback to switch the block style.',
table: {
type: {
summary: 'function',
},
},
defaultValue: 'noop',
},
onHoverClassName: {
control: {
type: 'function',
},
description: 'Callback to set the hover class name.',
table: {
type: {
summary: 'function',
},
},
defaultValue: 'noop',
},
},
};

export default meta;

export const Default = {
args: {
clientId: blockEditorState[ 0 ].clientId,
onSwitch: () => {},
onHoverClassName: () => {},
},
render: function Template( args ) {
return <BlockStyles { ...args } />;
},
};

0 comments on commit 6a18b3c

Please sign in to comment.