-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Added story for BlockVariationTransforms.
- Loading branch information
1 parent
e5dca54
commit 5d4da48
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/block-editor/src/components/block-variation-transforms/stories/index.story.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '', | ||
}; |