-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate default stories for MenuItem
Add more stories for menu-item Update MenuItem import index.story.tsx Update packages/components/src/menu-item/index.tsx Co-authored-by: Lena Morita <lena@jaguchi.com>
- Loading branch information
Showing
5 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,80 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { link, more, check } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import MenuGroup from '../../menu-group'; | ||
import MenuItem from '..'; | ||
import Shortcut from '../../shortcut'; | ||
|
||
const meta: Meta< typeof MenuItem > = { | ||
component: MenuItem, | ||
title: 'Components/MenuItem', | ||
argTypes: { | ||
children: { control: { type: null } }, | ||
icon: { | ||
control: { type: 'select' }, | ||
options: [ 'check', 'link', 'more' ], | ||
mapping: { | ||
check, | ||
link, | ||
more, | ||
}, | ||
}, | ||
}, | ||
parameters: { | ||
controls: { | ||
expanded: true, | ||
}, | ||
docs: { canvas: { sourceState: 'shown' } }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const Template: StoryFn< typeof MenuItem > = ( props ) => { | ||
return ( | ||
<MenuGroup> | ||
<MenuItem { ...props }>Menu Item 1</MenuItem> | ||
</MenuGroup> | ||
); | ||
}; | ||
|
||
export const Default: StoryFn< typeof MenuItem > = Template.bind( {} ); | ||
|
||
/** | ||
* When the `role` prop is either `"menuitemcheckbox"` or `"menuitemradio"`, the | ||
* `isSelected` prop should be used so screen readers can tell which item is currently selected. | ||
*/ | ||
export const IsSelected = Template.bind( {} ); | ||
IsSelected.args = { | ||
...Default.args, | ||
isSelected: true, | ||
role: 'menuitemcheckbox', | ||
}; | ||
|
||
export const WithIcon = Template.bind( {} ); | ||
WithIcon.args = { | ||
...Default.args, | ||
icon: link, | ||
iconPosition: 'left', | ||
}; | ||
|
||
export const WithInfo = Template.bind( {} ); | ||
WithInfo.args = { | ||
...Default.args, | ||
info: 'Menu Item description', | ||
}; | ||
|
||
export const WithSuffix = Template.bind( {} ); | ||
WithSuffix.args = { | ||
...Default.args, | ||
suffix: <Shortcut shortcut="Ctrl+M"></Shortcut>, | ||
}; |
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
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