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 stories for the TextAlignmentControl component #67371

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,69 @@ import { useState } from '@wordpress/element';
*/
import TextAlignmentControl from '../';

export default {
const meta = {
title: 'BlockEditor/TextAlignmentControl',
component: TextAlignmentControl,
t-hamano marked this conversation as resolved.
Show resolved Hide resolved
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component: 'Control to facilitate text alignment selections.',
},
},
},
argTypes: {
onChange: { action: 'onChange' },
className: { control: 'text' },
value: {
control: { type: null },
description: 'Currently selected text alignment value.',
table: {
type: {
summary: 'string',
},
},
},
onChange: {
action: 'onChange',
control: { type: null },
description: 'Handles change in text alignment selection.',
table: {
type: {
summary: 'function',
},
},
},
options: {
control: 'check',
description: 'Array of text alignment options to display.',
options: [ 'left', 'center', 'right', 'justify' ],
table: {
type: { summary: 'array' },
},
},
className: {
control: 'text',
description: 'Class name to add to the control.',
table: {
type: { summary: 'string' },
},
},
value: { control: false },
},
};

const Template = ( { onChange, ...args } ) => {
const [ value, setValue ] = useState();
return (
<TextAlignmentControl
{ ...args }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setValue( ...changeArgs );
} }
value={ value }
/>
);
};
export default meta;

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