-
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.
MenuItem: Add Storybook stories (#53613)
* 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> * Update changelog * Update packages/components/src/menu-item/README.md Co-authored-by: Lena Morita <lena@jaguchi.com> --------- Co-authored-by: Lena Morita <lena@jaguchi.com>
- Loading branch information
Showing
6 changed files
with
93 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
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
1bc4205
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 1bc4205.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5969736936
📝 Reported issues:
/test/e2e/specs/editor/various/multi-block-selection.spec.js