This repository has been archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
stories.js
155 lines (149 loc) · 4.97 KB
/
stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import centered from '@storybook/addon-centered/react';
import { withKnobs, boolean, text, select } from '@storybook/addon-knobs';
import { Button } from '../Button';
import { PopoverContainer } from '../Popover';
import Menu, { Group, Item, PopoverMenu } from '.';
import BellIcon from '../../icons/bell.svg';
import CloseIcon from '../../icons/close.svg';
import FinishIcon from '../../icons/finish.svg';
import ChangeIcon from '../../icons/change.svg';
const defaultMenuItemText = 'A menu item';
const defaultAnotherMenuItemText = 'Another menu item';
storiesOf('Components|Menu', module)
.addDecorator(centered)
.addDecorator(withKnobs)
.add('empty', () => (
<Menu hidden={boolean('hidden', false)} />
))
.add('simple', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('placement', () => (
<div style={{ position: 'relative' }}>
<Button>Button</Button>
<Menu
hidden={boolean('hidden menu', false)}
placement={select('placement', ['left-top', 'right-top', 'right-bottom', 'left-bottom'], 'right-bottom')}
>
<Group title={text('group title', '')}>
<Item onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
</div>
));
const centeredWithPopoverContainer = (storyFn, ...args) => (
<div style={{ display: 'flex', width: '100vw', height: '100vh' }}>
<PopoverContainer>
{centered(storyFn, ...args)}
</PopoverContainer>
</div>
);
storiesOf('Components|Menu/PopoverMenu', module)
.addDecorator(withKnobs)
.addDecorator(centeredWithPopoverContainer)
.add('default', () => (
<PopoverMenu
// eslint-disable-next-line react/jsx-no-bind
trigger={({ pop }) => <Button onClick={pop}>More options...</Button>}
>
<Group>
<Item>Reload</Item>
<Item danger>Delete...</Item>
</Group>
</PopoverMenu>
))
.add('with overlay', () => (
<PopoverMenu
overlayed
// eslint-disable-next-line react/jsx-no-bind
trigger={({ pop }) => <Button onClick={pop}>More options...</Button>}
>
<Group>
<Item>Reload</Item>
<Item danger>Delete...</Item>
</Group>
</PopoverMenu>
));
storiesOf('Components|Menu/Group', module)
.addDecorator(centered)
.addDecorator(withKnobs)
.add('single', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item>{defaultMenuItemText}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('multiple', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group #1 title', '')}>
<Item>{defaultMenuItemText}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
<Group title={text('group #2 title', '')}>
<Item>Report</Item>
</Group>
</Menu>
))
.add('with title', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', 'Are you sure?')}>
<Item>{defaultMenuItemText}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
));
storiesOf('Components|Menu/Item', module)
.addDecorator(centered)
.addDecorator(withKnobs)
.add('simple', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('primary', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item primary onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('danger', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item danger onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('disabled', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item disabled onClick={action('clicked')}>{text('item text', defaultMenuItemText)}</Item>
<Item>{defaultAnotherMenuItemText}</Item>
</Group>
</Menu>
))
.add('with icon', () => (
<Menu hidden={boolean('hidden menu', false)}>
<Group title={text('group title', '')}>
<Item onClick={action('clicked')} icon={CloseIcon}>{text('item text', 'Simple')}</Item>
<Item primary onClick={action('clicked')} icon={ChangeIcon}>{text('item text', 'Primary')}</Item>
<Item danger onClick={action('clicked')} icon={FinishIcon}>{text('item text', 'Danger')}</Item>
<Item disabled onClick={action('clicked')} icon={BellIcon}>{text('item text', 'Disabled')}</Item>
</Group>
</Menu>
));