Skip to content

Commit

Permalink
Storybook: Add stories for BlockVerticalAlignmentControl component
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshupathak95 committed Jan 2, 2025
1 parent 1673ed8 commit 436c679
Showing 1 changed file with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import {
BlockVerticalAlignmentControl,
BlockVerticalAlignmentToolbar,
} from '../';

const meta = {
title: 'BlockEditor/BlockVerticalAlignmentControl',
component: BlockVerticalAlignmentControl,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
'Controls for vertical alignment of content within a block.',
},
},
},
argTypes: {
value: {
control: { type: null },
description: 'Currently selected vertical alignment value.',
table: {
type: {
summary: 'string',
},
},
},
onChange: {
action: 'onChange',
control: { type: null },
description: 'Handles change in vertical alignment selection.',
table: {
type: {
summary: 'function',
},
},
},
controls: {
control: 'check',
description: 'Array of vertical alignment options to display.',
options: [ 'top', 'center', 'bottom' ],
table: {
type: { summary: 'array' },
defaultValue: { summary: "['top', 'center', 'bottom']" },
},
},
},
};

export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState();
return (
<BlockVerticalAlignmentControl
{ ...args }
onChange={ ( newValue ) => {
onChange( newValue );
setValue( newValue );
} }
value={ value }
/>
);
},
};

export const Toolbar = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState();
return (
<BlockVerticalAlignmentToolbar
{ ...args }
onChange={ ( newValue ) => {
onChange( newValue );
setValue( newValue );
} }
value={ value }
/>
);
},
};

0 comments on commit 436c679

Please sign in to comment.