-
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 index.story.js for button block appender component
- Loading branch information
1 parent
b80c1e9
commit df1c0e5
Showing
1 changed file
with
135 additions
and
0 deletions.
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
packages/block-editor/src/components/button-block-appender/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,135 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import ButtonBlockAppender from '../'; | ||
|
||
const meta = { | ||
title: 'BlockEditor/ButtonBlockAppender', | ||
component: ButtonBlockAppender, | ||
parameters: { | ||
docs: { | ||
canvas: { sourceState: 'shown' }, | ||
description: { | ||
component: __( | ||
'A block appender button that allows users to add new blocks.' | ||
), | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
rootClientId: { | ||
control: { type: 'text' }, | ||
description: __( | ||
'The root client ID where new blocks will be inserted' | ||
), | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
}, | ||
className: { | ||
control: { type: 'text' }, | ||
description: __( | ||
'Additional CSS class name to be added to the button' | ||
), | ||
table: { | ||
type: { summary: 'string' }, | ||
}, | ||
}, | ||
onFocus: { | ||
action: 'onFocus', | ||
description: __( 'Callback function when button receives focus' ), | ||
table: { | ||
type: { summary: 'function' }, | ||
}, | ||
}, | ||
tabIndex: { | ||
control: { type: 'number' }, | ||
description: __( 'Tab index for the button' ), | ||
table: { | ||
type: { summary: 'number' }, | ||
}, | ||
}, | ||
onSelect: { | ||
action: 'onSelect', | ||
description: __( 'Callback function when a block is selected' ), | ||
table: { | ||
type: { summary: 'function' }, | ||
}, | ||
}, | ||
}, | ||
args: { | ||
rootClientId: '', | ||
className: '', | ||
tabIndex: 0, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
render: function Template( args ) { | ||
return <ButtonBlockAppender { ...args } />; | ||
}, | ||
}; | ||
|
||
export const WithCustomClassName = { | ||
render: function Template( args ) { | ||
return ( | ||
<ButtonBlockAppender | ||
{ ...args } | ||
className="custom-appender-class" | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const WithRootClientId = { | ||
render: function Template( args ) { | ||
return ( | ||
<ButtonBlockAppender | ||
{ ...args } | ||
rootClientId="test-root-client-id" | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const WithCustomTabIndex = { | ||
render: function Template( args ) { | ||
return <ButtonBlockAppender { ...args } tabIndex={ -1 } />; | ||
}, | ||
}; | ||
|
||
export const WithCallbacks = { | ||
render: function Template( args ) { | ||
const handleFocus = () => { | ||
// eslint-disable-next-line no-console | ||
console.log( 'Button focused' ); | ||
}; | ||
|
||
const handleSelect = ( block ) => { | ||
// eslint-disable-next-line no-console | ||
console.log( 'Block selected:', block ); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<p> | ||
{ __( | ||
'Open browser console to see focus and select events.' | ||
) } | ||
</p> | ||
<ButtonBlockAppender | ||
{ ...args } | ||
onFocus={ handleFocus } | ||
onSelect={ handleSelect } | ||
/> | ||
</div> | ||
); | ||
}, | ||
}; |