-
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.
- Loading branch information
1 parent
e5dca54
commit 4bf02a2
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
packages/block-editor/src/components/block-edit/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,76 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockEdit from '../index'; | ||
|
||
const meta = { | ||
title: 'BlockEditor/BlockEdit', | ||
component: BlockEdit, | ||
parameters: { | ||
docs: { | ||
canvas: { sourceState: 'shown' }, | ||
description: { | ||
component: | ||
'Component for editing a block within the block editor.', | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
name: { | ||
control: 'text', | ||
description: 'The name of the block.', | ||
}, | ||
isSelected: { | ||
control: 'boolean', | ||
description: 'Whether the block is selected.', | ||
}, | ||
clientId: { | ||
control: 'text', | ||
description: 'The client ID of the block.', | ||
}, | ||
attributes: { | ||
control: 'object', | ||
description: 'The attributes of the block.', | ||
}, | ||
__unstableLayoutClassNames: { | ||
control: 'text', | ||
description: 'Layout class names for the block.', | ||
}, | ||
onReplace: { | ||
action: 'onReplace', | ||
control: { type: null }, | ||
description: 'Function called when the block is replaced.', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
render: function Template( { onReplace, ...args } ) { | ||
const [ attributes, setAttributes ] = useState( args.attributes || {} ); | ||
|
||
return ( | ||
<BlockEdit | ||
{ ...args } | ||
attributes={ attributes } | ||
onReplace={ ( ...replaceArgs ) => { | ||
setAttributes( ...replaceArgs ); | ||
onReplace( ...replaceArgs ); | ||
} } | ||
/> | ||
); | ||
}, | ||
args: { | ||
name: 'core/paragraph', | ||
isSelected: false, | ||
clientId: 'example-client-id', | ||
attributes: {}, | ||
__unstableLayoutClassNames: '', | ||
}, | ||
}; |