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 BlockDraggable #68269

Open
wants to merge 1 commit 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 @@ -3,14 +3,81 @@
*/
import BlockDraggableChip from '../draggable-chip';

export default { title: 'BlockEditor/BlockDraggable' };
/**
* WordPress dependencies
*/
import { paragraph } from '@wordpress/icons';

export default {
title: 'BlockEditor/BlockDraggable',
component: BlockDraggableChip,
parameters: {
docs: {
description: {
component:
'The `BlockDraggableChip` component allows to display a "chip" which contains the count of blocks.',
},
canvas: { sourceState: 'shown' },
},
},
argTypes: {
count: {
control: 'number',
description: 'The count of blocks.',
table: {
type: { summary: 'number' },
},
},
icon: {
control: 'select',
options: [ 'none', 'paragraph' ],
mapping: {
none: null,
paragraph,
},
description:
'The icon of the block. This can be any of [WordPress Dashicons](https://developer.wordpress.org/resource/dashicons/), or a custom `svg` element.',
table: {
type: { summary: 'string | object' },
},
},
isPattern: {
control: 'boolean',
description: 'Whether the block is a pattern.',
table: {
type: { summary: 'boolean' },
},
},
fadeWhenDisabled: {
control: 'boolean',
description: 'Whether the block should fade when disabled.',
table: {
type: { summary: 'boolean' },
},
},
},
};

export const _default = () => {
// Create a wrapper box for the absolutely-positioned child component.
const wrapperStyle = { margin: '24px 0', position: 'relative' };
return (
<div style={ wrapperStyle }>
<BlockDraggableChip count={ 2 } />
</div>
);
export const Default = {
args: {
count: 2,
fadeWhenDisabled: false,
icon: null,
isPattern: false,
},
render: ( props ) => {
// Create a wrapper box for the absolutely-positioned child component.
const wrapperStyle = { margin: '24px 0', position: 'relative' };
const count = props.count < 0 ? 0 : props.count;
return (
<div style={ wrapperStyle }>
<BlockDraggableChip
count={ count }
fadeWhenDisabled={ props.fadeWhenDisabled }
icon={ props.icon !== null ? props.icon : undefined }
isPattern={ props.isPattern }
/>
</div>
);
},
};
Loading