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 BlockVariationTransforms #68710

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
@@ -0,0 +1,59 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import __experimentalBlockVariationTransforms from '../index';

export default {
title: 'BlockEditor/BlockVariationTransforms',
component: __experimentalBlockVariationTransforms,
parameters: {
docs: {
description: {
component: __(
'The BlockVariationTransforms component allows users to transform a selected block into one of its variations that have the `transform` option set in the `scope` property.'
),
},
},
},
argTypes: {
blockClientId: {
control: 'text',
description: __(
'The client ID of the block to which the variations apply.'
),
},
},
};

const Template = ( args ) => {
const { blockClientId } = args;
const { updateBlockAttributes } = useDispatch( blockEditorStore );
const { selectedBlockClientId } = useSelect( ( select ) => {
const { getSelectedBlockClientId } = select( blockEditorStore );
return {
selectedBlockClientId: getSelectedBlockClientId(),
};
}, [] );

const clientId = blockClientId || selectedBlockClientId;

return (
<__experimentalBlockVariationTransforms
{ ...args }
blockClientId={ clientId }
updateBlockAttributes={ updateBlockAttributes }
/>
);
};

export const Default = Template.bind( {} );
Default.args = {
blockClientId: '',
};
Loading