Skip to content

Commit 40bd38a

Browse files
committed
🎨 Add additional stories
1 parent 32c29ff commit 40bd38a

File tree

2 files changed

+62
-9
lines changed

2 files changed

+62
-9
lines changed

src/stories/ContextMenu.stories.tsx

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ const TRIGGER_ID = 'storybook-trigger';
99
const meta = {
1010
title: 'Context Menu',
1111
component: ContextMenu,
12-
decorators: [
13-
(Story) => (
14-
<StoryWrapper triggerId={TRIGGER_ID}>
15-
<Story />
16-
</StoryWrapper>
17-
),
18-
],
1912
parameters: {
2013
layout: 'centered',
2114
},
@@ -34,6 +27,43 @@ export const Default: Story = {
3427
<ContextMenu.Item onClick={fn()}>Item 3</ContextMenu.Item>,
3528
],
3629
},
30+
render: (args) => (
31+
<StoryWrapper triggerId={TRIGGER_ID}>
32+
<ContextMenu {...args} />
33+
</StoryWrapper>
34+
),
35+
};
36+
37+
export const WithoutExitAnimation: Story = {
38+
args: {
39+
animateExit: false,
40+
children: [
41+
<ContextMenu.Item onClick={fn()}>Item 1</ContextMenu.Item>,
42+
<ContextMenu.Item onClick={fn()}>Item 2</ContextMenu.Item>,
43+
<ContextMenu.Item onClick={fn()}>Item 3</ContextMenu.Item>,
44+
],
45+
},
46+
render: (args) => (
47+
<StoryWrapper triggerId={TRIGGER_ID}>
48+
<ContextMenu {...args} />
49+
</StoryWrapper>
50+
),
51+
};
52+
53+
export const ClickTrigger: Story = {
54+
args: {
55+
triggerEvent: 'click',
56+
children: [
57+
<ContextMenu.Item onClick={fn()}>Item 1</ContextMenu.Item>,
58+
<ContextMenu.Item onClick={fn()}>Item 2</ContextMenu.Item>,
59+
<ContextMenu.Item onClick={fn()}>Item 3</ContextMenu.Item>,
60+
],
61+
},
62+
render: (args) => (
63+
<StoryWrapper triggerId={TRIGGER_ID} triggerText="Left-click to trigger menu">
64+
<ContextMenu {...args} />
65+
</StoryWrapper>
66+
),
3767
};
3868

3969
export const DisabledItem: Story = {
@@ -46,6 +76,11 @@ export const DisabledItem: Story = {
4676
<ContextMenu.Item onClick={fn()}>Item 3</ContextMenu.Item>,
4777
],
4878
},
79+
render: (args) => (
80+
<StoryWrapper triggerId={TRIGGER_ID}>
81+
<ContextMenu {...args} />
82+
</StoryWrapper>
83+
),
4984
};
5085

5186
export const Separator: Story = {
@@ -57,6 +92,11 @@ export const Separator: Story = {
5792
<ContextMenu.Item onClick={fn()}>Item 3</ContextMenu.Item>,
5893
],
5994
},
95+
render: (args) => (
96+
<StoryWrapper triggerId={TRIGGER_ID}>
97+
<ContextMenu {...args} />
98+
</StoryWrapper>
99+
),
60100
};
61101

62102
export const SubMenu: Story = {
@@ -71,4 +111,9 @@ export const SubMenu: Story = {
71111
</ContextMenu.SubMenu>,
72112
],
73113
},
114+
render: (args) => (
115+
<StoryWrapper triggerId={TRIGGER_ID}>
116+
<ContextMenu {...args} />
117+
</StoryWrapper>
118+
),
74119
};

src/stories/components/StoryWrapper.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ import { ReactNode } from 'react';
22

33
import './styles.css';
44

5-
const StoryWrapper = ({ triggerId, children }: { triggerId: string; children: ReactNode }) => {
5+
const StoryWrapper = ({
6+
triggerId,
7+
children,
8+
triggerText = 'Right-click to trigger menu',
9+
}: {
10+
triggerId: string;
11+
children: ReactNode;
12+
triggerText?: string;
13+
}) => {
614
return (
715
<div className="story-wrapper">
8-
<p id={triggerId}>Right-click to trigger menu</p>
16+
<p id={triggerId}>{triggerText}</p>
917

1018
{children}
1119
</div>

0 commit comments

Comments
 (0)