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 BlockAlignmentMatrixControl Component #67292

Open
wants to merge 4 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 @@ -41,13 +41,14 @@ const controls = (
/>
</BlockControls>
</>
}
);
```

### Props

| Name | Type | Default | Description |
| ---------- | ---------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `label` | `string` | `Change matrix alignment` | concise description of tool's functionality. |
| `onChange` | `function` | `noop` | the function to execute upon a user's change of the matrix state |
| `value` | `string` | `center` | describes the content alignment location and can be `top`, `right`, `bottom`, `left`, `topRight`, `bottomRight`, `bottomLeft`, `topLeft` |
| `label` | `string` | `Change matrix alignment` | Label for the control. |
| `onChange` | `function` | `noop` | Function to execute upon a user's change of the matrix state. |
| `value` | `string` | `center` | Describes the content alignment location and can be `center center`, `center left`, `center right`, `top center`, `top left`, `top right`, `bottom center`, `bottom left`, `bottom right`. |
| `isDisabled` | `boolean` | `false` | Disables the control. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import BlockAlignmentMatrixControl from '../';

const meta = {
title: 'BlockEditor/BlockAlignmentMatrixControl',
component: BlockAlignmentMatrixControl,
parameters: {
docs: {
canvas: { sourceState: 'shown' },
description: {
component:
'Renders a control for selecting block alignment using a matrix of alignment options.',
},
},
},
argTypes: {
label: {
control: 'text',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'Change matrix alignment' },
},
description: 'Label for the control.',
},
onChange: {
action: 'onChange',
control: { type: null },
table: {
type: { summary: 'function' },
defaultValue: { summary: '() => {}' },
},
description:
"Function to execute upon a user's change of the matrix state.",
},
isDisabled: {
control: 'boolean',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
description: 'Disables the control.',
},
value: {
control: 'text',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'center center' },
},
description: 'Value of the control.',
},
},
};

export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState();

return (
<BlockAlignmentMatrixControl
{ ...args }
value={ value }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setValue( ...changeArgs );
} }
/>
);
},
};
Loading