-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from lifeomic/csf3-m
Update M- Components to Storybook CSF3
- Loading branch information
Showing
3 changed files
with
102 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,66 @@ | ||
import React from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
|
||
import { Menu } from './Menu'; | ||
import { IconButton } from '../IconButton'; | ||
import { MoreHorizontal } from '@lifeomic/chromicons'; | ||
import { MenuItem } from './MenuItem'; | ||
import { MenuGroupHeading } from './MenuGroupHeading'; | ||
|
||
export default { | ||
title: 'Components/Menu/Menu', | ||
const meta: Meta<typeof Menu> = { | ||
component: Menu, | ||
argTypes: {}, | ||
} as ComponentMeta<typeof Menu>; | ||
|
||
const Template: ComponentStory<typeof Menu> = (args) => <Menu {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
'aria-label': 'Chroma menu options', | ||
anchorElement: ( | ||
<IconButton aria-label="Click to open menu" icon={MoreHorizontal} /> | ||
), | ||
items: [<MenuItem key="1">Menu body</MenuItem>], | ||
args: { | ||
'aria-label': 'Chroma menu options', | ||
anchorElement: ( | ||
<IconButton aria-label="Click to open menu" icon={MoreHorizontal} /> | ||
), | ||
items: [ | ||
<MenuItem key="2">Option 1</MenuItem>, | ||
<MenuItem key="3">Option 2</MenuItem>, | ||
<MenuItem key="5">Option 3</MenuItem>, | ||
<MenuItem key="6">Option 4</MenuItem>, | ||
], | ||
}, | ||
decorators: [(story) => <div style={{ height: '250px' }}>{story()}</div>], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof Menu>; | ||
|
||
export const GroupHeadings = Template.bind({}); | ||
GroupHeadings.args = { | ||
'aria-label': 'Chroma menu options', | ||
anchorElement: ( | ||
<IconButton aria-label="Click to open menu" icon={MoreHorizontal} /> | ||
), | ||
items: [ | ||
<MenuGroupHeading key="1">First Section</MenuGroupHeading>, | ||
<MenuItem key="2">Option 1</MenuItem>, | ||
<MenuItem key="3">Option 2</MenuItem>, | ||
<MenuGroupHeading key="4">Second Section</MenuGroupHeading>, | ||
<MenuItem key="5">Option 3</MenuItem>, | ||
<MenuItem key="6">Option 4</MenuItem>, | ||
], | ||
export const Default: Story = {}; | ||
|
||
export const GroupHeadings: Story = { | ||
args: { | ||
items: [ | ||
<MenuGroupHeading key="1">First Section</MenuGroupHeading>, | ||
<MenuItem key="2">Option 1</MenuItem>, | ||
<MenuItem key="3">Option 2</MenuItem>, | ||
<MenuGroupHeading key="4">Second Section</MenuGroupHeading>, | ||
<MenuItem key="5">Option 3</MenuItem>, | ||
<MenuItem key="6">Option 4</MenuItem>, | ||
], | ||
}, | ||
}; | ||
|
||
export const Title: Story = { | ||
args: { | ||
title: 'Title', | ||
}, | ||
}; | ||
|
||
export const Placement: Story = { | ||
args: { | ||
placement: 'top-end', | ||
}, | ||
}; | ||
|
||
export const Gutter: Story = { | ||
args: { | ||
gutter: 50, | ||
}, | ||
}; | ||
|
||
export const Placement = Template.bind({}); | ||
Placement.args = { | ||
'aria-label': 'Chroma menu options', | ||
anchorElement: ( | ||
<IconButton aria-label="Click to open menu" icon={MoreHorizontal} /> | ||
), | ||
items: [<MenuItem key="1">Menu body</MenuItem>], | ||
placement: 'top-end', | ||
export const UsePortal: Story = { | ||
args: { | ||
usePortal: true, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,34 +1,30 @@ | ||
import React from 'react'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
|
||
import { MenuItem } from './MenuItem'; | ||
import { HelpCircle } from '@lifeomic/chromicons'; | ||
|
||
export default { | ||
title: 'Components/Menu/MenuItem', | ||
const meta: Meta<typeof MenuItem> = { | ||
component: MenuItem, | ||
args: { | ||
text: 'Menu Item', | ||
}, | ||
argTypes: { | ||
onClick: { action: 'clicked' }, | ||
}, | ||
} as ComponentMeta<typeof MenuItem>; | ||
|
||
const Template: ComponentStory<typeof MenuItem> = (args) => ( | ||
<MenuItem {...args} /> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
text: 'Menu Item', | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof MenuItem>; | ||
|
||
export const SecondaryText = Template.bind({}); | ||
SecondaryText.args = { | ||
text: 'Menu Item', | ||
secondaryText: 'This is secondary text', | ||
export const Default: Story = {}; | ||
|
||
export const SecondaryText: Story = { | ||
args: { | ||
secondaryText: 'This is secondary text', | ||
}, | ||
}; | ||
|
||
export const Icon = Template.bind({}); | ||
Icon.args = { | ||
text: 'Menu Item', | ||
icon: HelpCircle, | ||
export const Icon: Story = { | ||
args: { | ||
icon: HelpCircle, | ||
}, | ||
}; |
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