@appdirect/design-system 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +24 -34
- package/dist/ComplexComponents/PageContentHeader/index.ts +0 -2
- package/dist/contracts/PageContentHeader.json +10 -5
- package/dist/contracts/index.json +1 -1
- package/dist/index.ts +3 -4
- package/dist/stories/Buttons/ActionIcon.stories.tsx +159 -0
- package/dist/stories/Buttons/Button.stories.tsx +145 -0
- package/dist/stories/Buttons/CloseButton.stories.tsx +121 -0
- package/dist/stories/Combobox/AutocompleteClearable.stories.tsx +554 -0
- package/dist/stories/Combobox/Combobox.stories.tsx +106 -0
- package/dist/stories/Combobox/Multiselect.stories.tsx +664 -0
- package/dist/stories/Combobox/SearchableSelect.stories.tsx +640 -0
- package/dist/stories/Combobox/Select.stories.tsx +311 -0
- package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +822 -0
- package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +502 -0
- package/dist/stories/ComplexComponents/KeyInsight/KeyInsights.stories.tsx +386 -0
- package/dist/stories/ComplexComponents/NameValue/NameValue.stories.tsx +405 -0
- package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +527 -0
- package/dist/stories/ComplexComponents/Placeholder/Placeholder.stories.tsx +76 -0
- package/dist/stories/ComplexComponents/Slat/Slat.stories.tsx +79 -0
- package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +479 -0
- package/dist/stories/DataDisplay/Alert.stories.tsx +296 -0
- package/dist/stories/DataDisplay/Avatar.stories.tsx +251 -0
- package/dist/stories/DataDisplay/Badge.stories.tsx +176 -0
- package/dist/stories/DataDisplay/Card.stories.tsx +406 -0
- package/dist/stories/DataDisplay/Chip.stories.tsx +495 -0
- package/dist/stories/DataDisplay/Indicator.stories.tsx +571 -0
- package/dist/stories/DataDisplay/List.stories.tsx +376 -0
- package/dist/stories/DataDisplay/Pill.stories.tsx +506 -0
- package/dist/stories/DataDisplay/Progress.stories.tsx +352 -0
- package/dist/stories/DataDisplay/Table.stories.tsx +346 -0
- package/dist/stories/DataDisplay/ThemeIcon.stories.tsx +125 -0
- package/dist/stories/Inputs/Checkbox.stories.tsx +263 -0
- package/dist/stories/Inputs/ColorInput.stories.tsx +434 -0
- package/dist/stories/Inputs/DropZone.stories.tsx +401 -0
- package/dist/stories/Inputs/FileInput.stories.tsx +383 -0
- package/dist/stories/Inputs/NumberInput.stories.tsx +342 -0
- package/dist/stories/Inputs/Radio.stories.tsx +437 -0
- package/dist/stories/Inputs/RadioGroup.stories.tsx +526 -0
- package/dist/stories/Inputs/SegmentedControl.stories.tsx +60 -0
- package/dist/stories/Inputs/Slider.stories.tsx +22 -0
- package/dist/stories/Inputs/SliderWithLabel.stories.tsx +37 -0
- package/dist/stories/Inputs/Switch.stories.tsx +361 -0
- package/dist/stories/Inputs/TextArea.stories.tsx +355 -0
- package/dist/stories/Inputs/TextInput.stories.tsx +266 -0
- package/dist/stories/Misc/Divider.stories.tsx +581 -0
- package/dist/stories/Misc/Paper.stories.tsx +557 -0
- package/dist/stories/Navigation/Breadcrumb.stories.tsx +489 -0
- package/dist/stories/Navigation/NavLink.stories.tsx +601 -0
- package/dist/stories/Navigation/Stepper.stories.tsx +413 -0
- package/dist/stories/Navigation/Tabs.stories.tsx +528 -0
- package/dist/stories/Overlays/Drawer.stories.tsx +802 -0
- package/dist/stories/Overlays/Menu.stories.tsx +941 -0
- package/dist/stories/Overlays/Modal.stories.tsx +249 -0
- package/dist/stories/Overlays/Popover.stories.tsx +780 -0
- package/dist/stories/Overlays/Tooltip.stories.tsx +52 -0
- package/dist/stories/Typography/Code.stories.tsx +368 -0
- package/dist/stories/Typography/Kbd.stories.tsx +514 -0
- package/dist/stories/Typography/Text.stories.tsx +117 -0
- package/dist/stories/Typography/Title.stories.tsx +112 -0
- package/dist/stories/index.json +1435 -0
- package/package.json +5 -3
- package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +0 -65
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
|
|
2
|
+
import { Stack } from '@mantine/core';
|
|
3
|
+
import { Inline, Menu, Title, Text, Button, ThemeIcon } from '@appdirect/design-system';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Design System/Overlays/Menu',
|
|
8
|
+
component: Menu,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: 'Menu component for displaying dropdown menus with structured sections and consistent styling.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
tags: ['autodocs', 'code-connected'],
|
|
18
|
+
argTypes: {
|
|
19
|
+
width: {
|
|
20
|
+
control: 'number',
|
|
21
|
+
description: 'Menu width',
|
|
22
|
+
},
|
|
23
|
+
shadow: {
|
|
24
|
+
control: 'select',
|
|
25
|
+
options: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
26
|
+
description: 'Menu shadow',
|
|
27
|
+
},
|
|
28
|
+
position: {
|
|
29
|
+
control: 'select',
|
|
30
|
+
options: [
|
|
31
|
+
'bottom', 'bottom-start', 'bottom-end',
|
|
32
|
+
'top', 'top-start', 'top-end',
|
|
33
|
+
'left', 'left-start', 'left-end',
|
|
34
|
+
'right', 'right-start', 'right-end'
|
|
35
|
+
],
|
|
36
|
+
description: 'Menu position',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
} satisfies Meta;
|
|
40
|
+
|
|
41
|
+
export default meta;
|
|
42
|
+
type Story = StoryObj<typeof meta>;
|
|
43
|
+
|
|
44
|
+
export const Default: Story = {
|
|
45
|
+
render: () => (
|
|
46
|
+
<Menu
|
|
47
|
+
trigger={<Button>Open Menu</Button>}
|
|
48
|
+
sections={[
|
|
49
|
+
{
|
|
50
|
+
items: [
|
|
51
|
+
{
|
|
52
|
+
id: 'edit',
|
|
53
|
+
label: 'Edit',
|
|
54
|
+
leftSection: <span>✎</span>,
|
|
55
|
+
onClick: () => console.log('Edit clicked'),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'copy',
|
|
59
|
+
label: 'Copy',
|
|
60
|
+
leftSection: <span>⧉</span>,
|
|
61
|
+
onClick: () => console.log('Copy clicked'),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'delete',
|
|
65
|
+
label: 'Delete',
|
|
66
|
+
leftSection: <span>🗑</span>,
|
|
67
|
+
color: 'red',
|
|
68
|
+
onClick: () => console.log('Delete clicked'),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const WithSections: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<Menu
|
|
80
|
+
trigger={<Button variant="outline">Menu with Sections</Button>}
|
|
81
|
+
sections={[
|
|
82
|
+
{
|
|
83
|
+
title: 'Actions',
|
|
84
|
+
items: [
|
|
85
|
+
{
|
|
86
|
+
id: 'new',
|
|
87
|
+
label: 'New Item',
|
|
88
|
+
leftSection: <span>+</span>,
|
|
89
|
+
onClick: () => console.log('New item'),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'edit',
|
|
93
|
+
label: 'Edit',
|
|
94
|
+
leftSection: <span>✎</span>,
|
|
95
|
+
onClick: () => console.log('Edit'),
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'duplicate',
|
|
99
|
+
label: 'Duplicate',
|
|
100
|
+
leftSection: <span>⧉</span>,
|
|
101
|
+
onClick: () => console.log('Duplicate'),
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: 'View',
|
|
107
|
+
items: [
|
|
108
|
+
{
|
|
109
|
+
id: 'details',
|
|
110
|
+
label: 'View Details',
|
|
111
|
+
leftSection: <span>👁</span>,
|
|
112
|
+
onClick: () => console.log('View details'),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 'history',
|
|
116
|
+
label: 'View History',
|
|
117
|
+
leftSection: <span>📜</span>,
|
|
118
|
+
onClick: () => console.log('View history'),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
title: 'Danger Zone',
|
|
124
|
+
items: [
|
|
125
|
+
{
|
|
126
|
+
id: 'archive',
|
|
127
|
+
label: 'Archive',
|
|
128
|
+
leftSection: <span>📦</span>,
|
|
129
|
+
onClick: () => console.log('Archive'),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'delete',
|
|
133
|
+
label: 'Delete',
|
|
134
|
+
leftSection: <span>🗑</span>,
|
|
135
|
+
color: 'red',
|
|
136
|
+
onClick: () => console.log('Delete'),
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
]}
|
|
141
|
+
/>
|
|
142
|
+
),
|
|
143
|
+
parameters: {
|
|
144
|
+
docs: {
|
|
145
|
+
description: {
|
|
146
|
+
story: 'Menu with multiple labeled sections and dividers.',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const WithShortcuts: Story = {
|
|
153
|
+
render: () => (
|
|
154
|
+
<Menu
|
|
155
|
+
trigger={<Button variant="outline">Menu with Shortcuts</Button>}
|
|
156
|
+
sections={[
|
|
157
|
+
{
|
|
158
|
+
title: 'File',
|
|
159
|
+
items: [
|
|
160
|
+
{
|
|
161
|
+
id: 'new',
|
|
162
|
+
label: 'New',
|
|
163
|
+
leftSection: <span>📄</span>,
|
|
164
|
+
rightSection: '⌘N',
|
|
165
|
+
onClick: () => console.log('New file'),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'open',
|
|
169
|
+
label: 'Open',
|
|
170
|
+
leftSection: <span>📂</span>,
|
|
171
|
+
rightSection: '⌘O',
|
|
172
|
+
onClick: () => console.log('Open file'),
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 'save',
|
|
176
|
+
label: 'Save',
|
|
177
|
+
leftSection: <span>💾</span>,
|
|
178
|
+
rightSection: '⌘S',
|
|
179
|
+
onClick: () => console.log('Save file'),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
title: 'Edit',
|
|
185
|
+
items: [
|
|
186
|
+
{
|
|
187
|
+
id: 'undo',
|
|
188
|
+
label: 'Undo',
|
|
189
|
+
leftSection: <span>↶</span>,
|
|
190
|
+
rightSection: '⌘Z',
|
|
191
|
+
onClick: () => console.log('Undo'),
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: 'redo',
|
|
195
|
+
label: 'Redo',
|
|
196
|
+
leftSection: <span>↷</span>,
|
|
197
|
+
rightSection: '⌘⇧Z',
|
|
198
|
+
onClick: () => console.log('Redo'),
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'find',
|
|
202
|
+
label: 'Find',
|
|
203
|
+
leftSection: <span>🔍</span>,
|
|
204
|
+
rightSection: '⌘F',
|
|
205
|
+
onClick: () => console.log('Find'),
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
]}
|
|
210
|
+
/>
|
|
211
|
+
),
|
|
212
|
+
parameters: {
|
|
213
|
+
docs: {
|
|
214
|
+
description: {
|
|
215
|
+
story: 'Menu with keyboard shortcuts displayed in the right section.',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const Positions: Story = {
|
|
222
|
+
render: () => (
|
|
223
|
+
<Stack gap="xl" align="center">
|
|
224
|
+
<Inline gap="lg">
|
|
225
|
+
<Menu
|
|
226
|
+
trigger={<Button variant="outline" size="sm">Bottom Start</Button>}
|
|
227
|
+
position="bottom-start"
|
|
228
|
+
sections={[
|
|
229
|
+
{
|
|
230
|
+
items: [
|
|
231
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
232
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
]}
|
|
236
|
+
/>
|
|
237
|
+
<Menu
|
|
238
|
+
trigger={<Button variant="outline" size="sm">Bottom</Button>}
|
|
239
|
+
position="bottom"
|
|
240
|
+
sections={[
|
|
241
|
+
{
|
|
242
|
+
items: [
|
|
243
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
244
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
]}
|
|
248
|
+
/>
|
|
249
|
+
<Menu
|
|
250
|
+
trigger={<Button variant="outline" size="sm">Bottom End</Button>}
|
|
251
|
+
position="bottom-end"
|
|
252
|
+
sections={[
|
|
253
|
+
{
|
|
254
|
+
items: [
|
|
255
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
256
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
</Inline>
|
|
262
|
+
|
|
263
|
+
<Inline gap="lg">
|
|
264
|
+
<Menu
|
|
265
|
+
trigger={<Button variant="outline" size="sm">Top Start</Button>}
|
|
266
|
+
position="top-start"
|
|
267
|
+
sections={[
|
|
268
|
+
{
|
|
269
|
+
items: [
|
|
270
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
271
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
]}
|
|
275
|
+
/>
|
|
276
|
+
<Menu
|
|
277
|
+
trigger={<Button variant="outline" size="sm">Top</Button>}
|
|
278
|
+
position="top"
|
|
279
|
+
sections={[
|
|
280
|
+
{
|
|
281
|
+
items: [
|
|
282
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
283
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
]}
|
|
287
|
+
/>
|
|
288
|
+
<Menu
|
|
289
|
+
trigger={<Button variant="outline" size="sm">Top End</Button>}
|
|
290
|
+
position="top-end"
|
|
291
|
+
sections={[
|
|
292
|
+
{
|
|
293
|
+
items: [
|
|
294
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
295
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
296
|
+
],
|
|
297
|
+
},
|
|
298
|
+
]}
|
|
299
|
+
/>
|
|
300
|
+
</Inline>
|
|
301
|
+
|
|
302
|
+
<Inline gap="lg">
|
|
303
|
+
<Menu
|
|
304
|
+
trigger={<Button variant="outline" size="sm">Left</Button>}
|
|
305
|
+
position="left"
|
|
306
|
+
sections={[
|
|
307
|
+
{
|
|
308
|
+
items: [
|
|
309
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
310
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
]}
|
|
314
|
+
/>
|
|
315
|
+
<Menu
|
|
316
|
+
trigger={<Button variant="outline" size="sm">Right</Button>}
|
|
317
|
+
position="right"
|
|
318
|
+
sections={[
|
|
319
|
+
{
|
|
320
|
+
items: [
|
|
321
|
+
{ id: 'item1', label: 'Item 1', onClick: () => console.log('Item 1') },
|
|
322
|
+
{ id: 'item2', label: 'Item 2', onClick: () => console.log('Item 2') },
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
]}
|
|
326
|
+
/>
|
|
327
|
+
</Inline>
|
|
328
|
+
</Stack>
|
|
329
|
+
),
|
|
330
|
+
parameters: {
|
|
331
|
+
docs: {
|
|
332
|
+
description: {
|
|
333
|
+
story: 'Different positioning options for the Menu component.',
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export const WithDisabledItems: Story = {
|
|
340
|
+
render: () => (
|
|
341
|
+
<Menu
|
|
342
|
+
trigger={<Button variant="outline">Menu with Disabled Items</Button>}
|
|
343
|
+
sections={[
|
|
344
|
+
{
|
|
345
|
+
title: 'Available Actions',
|
|
346
|
+
items: [
|
|
347
|
+
{
|
|
348
|
+
id: 'view',
|
|
349
|
+
label: 'View',
|
|
350
|
+
leftSection: <span>👁</span>,
|
|
351
|
+
onClick: () => console.log('View'),
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: 'edit',
|
|
355
|
+
label: 'Edit',
|
|
356
|
+
leftSection: <span>✎</span>,
|
|
357
|
+
onClick: () => console.log('Edit'),
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
title: 'Restricted Actions',
|
|
363
|
+
items: [
|
|
364
|
+
{
|
|
365
|
+
id: 'share',
|
|
366
|
+
label: 'Share (Premium only)',
|
|
367
|
+
leftSection: <span>↗</span>,
|
|
368
|
+
disabled: true,
|
|
369
|
+
onClick: () => console.log('Share'),
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
id: 'export',
|
|
373
|
+
label: 'Export (No permission)',
|
|
374
|
+
leftSection: <span>⬇</span>,
|
|
375
|
+
disabled: true,
|
|
376
|
+
onClick: () => console.log('Export'),
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
id: 'delete',
|
|
380
|
+
label: 'Delete (Read-only)',
|
|
381
|
+
leftSection: <span>🗑</span>,
|
|
382
|
+
color: 'red',
|
|
383
|
+
disabled: true,
|
|
384
|
+
onClick: () => console.log('Delete'),
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
},
|
|
388
|
+
]}
|
|
389
|
+
/>
|
|
390
|
+
),
|
|
391
|
+
parameters: {
|
|
392
|
+
docs: {
|
|
393
|
+
description: {
|
|
394
|
+
story: 'Menu with disabled items that cannot be clicked.',
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export const DifferentTriggers: Story = {
|
|
401
|
+
render: () => (
|
|
402
|
+
<Inline gap="lg">
|
|
403
|
+
<Menu
|
|
404
|
+
trigger={<Button variant="primary">Primary Button</Button>}
|
|
405
|
+
sections={[
|
|
406
|
+
{
|
|
407
|
+
items: [
|
|
408
|
+
{ id: 'action1', label: 'Action 1', onClick: () => console.log('Action 1') },
|
|
409
|
+
{ id: 'action2', label: 'Action 2', onClick: () => console.log('Action 2') },
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
]}
|
|
413
|
+
/>
|
|
414
|
+
|
|
415
|
+
<Menu
|
|
416
|
+
trigger={<Button variant="outline">Outline Button</Button>}
|
|
417
|
+
sections={[
|
|
418
|
+
{
|
|
419
|
+
items: [
|
|
420
|
+
{ id: 'action1', label: 'Action 1', onClick: () => console.log('Action 1') },
|
|
421
|
+
{ id: 'action2', label: 'Action 2', onClick: () => console.log('Action 2') },
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
]}
|
|
425
|
+
/>
|
|
426
|
+
|
|
427
|
+
<Menu
|
|
428
|
+
trigger={
|
|
429
|
+
<ThemeIcon variant="default" size="md" style={{ cursor: 'pointer' }}>
|
|
430
|
+
<span>⋯</span>
|
|
431
|
+
</ThemeIcon>
|
|
432
|
+
}
|
|
433
|
+
sections={[
|
|
434
|
+
{
|
|
435
|
+
items: [
|
|
436
|
+
{ id: 'action1', label: 'Action 1', onClick: () => console.log('Action 1') },
|
|
437
|
+
{ id: 'action2', label: 'Action 2', onClick: () => console.log('Action 2') },
|
|
438
|
+
],
|
|
439
|
+
},
|
|
440
|
+
]}
|
|
441
|
+
/>
|
|
442
|
+
|
|
443
|
+
<Menu
|
|
444
|
+
trigger={
|
|
445
|
+
<div style={{
|
|
446
|
+
padding: '8px 12px',
|
|
447
|
+
border: '1px solid var(--mantine-color-gray-3)',
|
|
448
|
+
borderRadius: '4px',
|
|
449
|
+
cursor: 'pointer',
|
|
450
|
+
backgroundColor: 'white'
|
|
451
|
+
}}>
|
|
452
|
+
<Text size="sm">Custom Trigger</Text>
|
|
453
|
+
</div>
|
|
454
|
+
}
|
|
455
|
+
sections={[
|
|
456
|
+
{
|
|
457
|
+
items: [
|
|
458
|
+
{ id: 'action1', label: 'Action 1', onClick: () => console.log('Action 1') },
|
|
459
|
+
{ id: 'action2', label: 'Action 2', onClick: () => console.log('Action 2') },
|
|
460
|
+
],
|
|
461
|
+
},
|
|
462
|
+
]}
|
|
463
|
+
/>
|
|
464
|
+
</Inline>
|
|
465
|
+
),
|
|
466
|
+
parameters: {
|
|
467
|
+
docs: {
|
|
468
|
+
description: {
|
|
469
|
+
story: 'Menu with different types of trigger elements.',
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
export const ControlledMenu: Story = {
|
|
476
|
+
render: () => {
|
|
477
|
+
const [opened, setOpened] = useState(false);
|
|
478
|
+
|
|
479
|
+
return (
|
|
480
|
+
<Stack gap="md" align="center">
|
|
481
|
+
<Inline gap="sm">
|
|
482
|
+
<Button
|
|
483
|
+
variant="outline"
|
|
484
|
+
size="sm"
|
|
485
|
+
onClick={() => setOpened(true)}
|
|
486
|
+
>
|
|
487
|
+
Open Menu
|
|
488
|
+
</Button>
|
|
489
|
+
<Button
|
|
490
|
+
variant="outline"
|
|
491
|
+
size="sm"
|
|
492
|
+
onClick={() => setOpened(false)}
|
|
493
|
+
>
|
|
494
|
+
Close Menu
|
|
495
|
+
</Button>
|
|
496
|
+
</Inline>
|
|
497
|
+
|
|
498
|
+
<Menu
|
|
499
|
+
trigger={<Button>Controlled Menu</Button>}
|
|
500
|
+
opened={opened}
|
|
501
|
+
onChange={setOpened}
|
|
502
|
+
sections={[
|
|
503
|
+
{
|
|
504
|
+
title: 'Controlled Actions',
|
|
505
|
+
items: [
|
|
506
|
+
{
|
|
507
|
+
id: 'action1',
|
|
508
|
+
label: 'Action 1',
|
|
509
|
+
onClick: () => {
|
|
510
|
+
console.log('Action 1');
|
|
511
|
+
setOpened(false);
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
id: 'action2',
|
|
516
|
+
label: 'Action 2',
|
|
517
|
+
onClick: () => {
|
|
518
|
+
console.log('Action 2');
|
|
519
|
+
setOpened(false);
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: 'keep-open',
|
|
524
|
+
label: 'Keep Menu Open',
|
|
525
|
+
onClick: () => console.log('Menu stays open'),
|
|
526
|
+
},
|
|
527
|
+
],
|
|
528
|
+
},
|
|
529
|
+
]}
|
|
530
|
+
/>
|
|
531
|
+
|
|
532
|
+
<Text size="sm" c="dimmed">
|
|
533
|
+
Menu is currently: {opened ? 'Open' : 'Closed'}
|
|
534
|
+
</Text>
|
|
535
|
+
</Stack>
|
|
536
|
+
);
|
|
537
|
+
},
|
|
538
|
+
parameters: {
|
|
539
|
+
docs: {
|
|
540
|
+
description: {
|
|
541
|
+
story: 'Menu with controlled open/close state.',
|
|
542
|
+
},
|
|
543
|
+
},
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export const ContextMenus: Story = {
|
|
548
|
+
render: () => (
|
|
549
|
+
<Stack gap="lg" w={500}>
|
|
550
|
+
<div>
|
|
551
|
+
<Text size="sm" fw={500} mb="sm">User Actions:</Text>
|
|
552
|
+
<Inline gap="sm">
|
|
553
|
+
<Menu
|
|
554
|
+
trigger={<Button variant="outline" size="sm">John Doe</Button>}
|
|
555
|
+
sections={[
|
|
556
|
+
{
|
|
557
|
+
title: 'Profile',
|
|
558
|
+
items: [
|
|
559
|
+
{
|
|
560
|
+
id: 'view-profile',
|
|
561
|
+
label: 'View Profile',
|
|
562
|
+
leftSection: <span>👤</span>,
|
|
563
|
+
onClick: () => console.log('View profile'),
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: 'edit-profile',
|
|
567
|
+
label: 'Edit Profile',
|
|
568
|
+
leftSection: <span>✎</span>,
|
|
569
|
+
onClick: () => console.log('Edit profile'),
|
|
570
|
+
},
|
|
571
|
+
],
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
title: 'Communication',
|
|
575
|
+
items: [
|
|
576
|
+
{
|
|
577
|
+
id: 'send-message',
|
|
578
|
+
label: 'Send Message',
|
|
579
|
+
leftSection: <span>💬</span>,
|
|
580
|
+
onClick: () => console.log('Send message'),
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
id: 'video-call',
|
|
584
|
+
label: 'Video Call',
|
|
585
|
+
leftSection: <span>📹</span>,
|
|
586
|
+
onClick: () => console.log('Video call'),
|
|
587
|
+
},
|
|
588
|
+
],
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
title: 'Admin',
|
|
592
|
+
items: [
|
|
593
|
+
{
|
|
594
|
+
id: 'block-user',
|
|
595
|
+
label: 'Block User',
|
|
596
|
+
leftSection: <span>🚫</span>,
|
|
597
|
+
color: 'red',
|
|
598
|
+
onClick: () => console.log('Block user'),
|
|
599
|
+
},
|
|
600
|
+
],
|
|
601
|
+
},
|
|
602
|
+
]}
|
|
603
|
+
/>
|
|
604
|
+
</Inline>
|
|
605
|
+
</div>
|
|
606
|
+
|
|
607
|
+
<div>
|
|
608
|
+
<Text size="sm" fw={500} mb="sm">File Actions:</Text>
|
|
609
|
+
<Inline gap="sm">
|
|
610
|
+
<Menu
|
|
611
|
+
trigger={
|
|
612
|
+
<div style={{
|
|
613
|
+
padding: '12px',
|
|
614
|
+
border: '1px solid var(--mantine-color-gray-3)',
|
|
615
|
+
borderRadius: '8px',
|
|
616
|
+
cursor: 'pointer',
|
|
617
|
+
backgroundColor: 'white',
|
|
618
|
+
display: 'flex',
|
|
619
|
+
alignItems: 'center',
|
|
620
|
+
gap: '8px'
|
|
621
|
+
}}>
|
|
622
|
+
<span>📄</span>
|
|
623
|
+
<Text size="sm">document.pdf</Text>
|
|
624
|
+
</div>
|
|
625
|
+
}
|
|
626
|
+
sections={[
|
|
627
|
+
{
|
|
628
|
+
title: 'File Actions',
|
|
629
|
+
items: [
|
|
630
|
+
{
|
|
631
|
+
id: 'open',
|
|
632
|
+
label: 'Open',
|
|
633
|
+
leftSection: <span>👁</span>,
|
|
634
|
+
onClick: () => console.log('Open file'),
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
id: 'download',
|
|
638
|
+
label: 'Download',
|
|
639
|
+
leftSection: <span>⬇</span>,
|
|
640
|
+
onClick: () => console.log('Download file'),
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
id: 'share',
|
|
644
|
+
label: 'Share',
|
|
645
|
+
leftSection: <span>↗</span>,
|
|
646
|
+
onClick: () => console.log('Share file'),
|
|
647
|
+
},
|
|
648
|
+
],
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
title: 'Edit',
|
|
652
|
+
items: [
|
|
653
|
+
{
|
|
654
|
+
id: 'rename',
|
|
655
|
+
label: 'Rename',
|
|
656
|
+
leftSection: <span>✎</span>,
|
|
657
|
+
onClick: () => console.log('Rename file'),
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
id: 'move',
|
|
661
|
+
label: 'Move',
|
|
662
|
+
leftSection: <span>📁</span>,
|
|
663
|
+
onClick: () => console.log('Move file'),
|
|
664
|
+
},
|
|
665
|
+
],
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
title: 'Danger Zone',
|
|
669
|
+
items: [
|
|
670
|
+
{
|
|
671
|
+
id: 'delete',
|
|
672
|
+
label: 'Delete',
|
|
673
|
+
leftSection: <span>🗑</span>,
|
|
674
|
+
color: 'red',
|
|
675
|
+
onClick: () => console.log('Delete file'),
|
|
676
|
+
},
|
|
677
|
+
],
|
|
678
|
+
},
|
|
679
|
+
]}
|
|
680
|
+
/>
|
|
681
|
+
</Inline>
|
|
682
|
+
</div>
|
|
683
|
+
|
|
684
|
+
<div>
|
|
685
|
+
<Text size="sm" fw={500} mb="sm">Settings Menu:</Text>
|
|
686
|
+
<Inline gap="sm">
|
|
687
|
+
<Menu
|
|
688
|
+
trigger={
|
|
689
|
+
<ThemeIcon variant="default" size="lg" style={{ cursor: 'pointer' }}>
|
|
690
|
+
<span>⚙</span>
|
|
691
|
+
</ThemeIcon>
|
|
692
|
+
}
|
|
693
|
+
sections={[
|
|
694
|
+
{
|
|
695
|
+
title: 'Preferences',
|
|
696
|
+
items: [
|
|
697
|
+
{
|
|
698
|
+
id: 'general',
|
|
699
|
+
label: 'General',
|
|
700
|
+
leftSection: <span>⚙</span>,
|
|
701
|
+
onClick: () => console.log('General settings'),
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
id: 'notifications',
|
|
705
|
+
label: 'Notifications',
|
|
706
|
+
leftSection: <span>🔔</span>,
|
|
707
|
+
onClick: () => console.log('Notification settings'),
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
id: 'privacy',
|
|
711
|
+
label: 'Privacy',
|
|
712
|
+
leftSection: <span>🔒</span>,
|
|
713
|
+
onClick: () => console.log('Privacy settings'),
|
|
714
|
+
},
|
|
715
|
+
],
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
title: 'Account',
|
|
719
|
+
items: [
|
|
720
|
+
{
|
|
721
|
+
id: 'profile',
|
|
722
|
+
label: 'Profile',
|
|
723
|
+
leftSection: <span>👤</span>,
|
|
724
|
+
onClick: () => console.log('Profile settings'),
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
id: 'billing',
|
|
728
|
+
label: 'Billing',
|
|
729
|
+
leftSection: <span>💳</span>,
|
|
730
|
+
onClick: () => console.log('Billing settings'),
|
|
731
|
+
},
|
|
732
|
+
],
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
title: 'Support',
|
|
736
|
+
items: [
|
|
737
|
+
{
|
|
738
|
+
id: 'help',
|
|
739
|
+
label: 'Help Center',
|
|
740
|
+
leftSection: <span>❓</span>,
|
|
741
|
+
onClick: () => console.log('Help center'),
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
id: 'contact',
|
|
745
|
+
label: 'Contact Support',
|
|
746
|
+
leftSection: <span>📧</span>,
|
|
747
|
+
onClick: () => console.log('Contact support'),
|
|
748
|
+
},
|
|
749
|
+
],
|
|
750
|
+
},
|
|
751
|
+
]}
|
|
752
|
+
/>
|
|
753
|
+
</Inline>
|
|
754
|
+
</div>
|
|
755
|
+
</Stack>
|
|
756
|
+
),
|
|
757
|
+
parameters: {
|
|
758
|
+
docs: {
|
|
759
|
+
description: {
|
|
760
|
+
story: 'Real-world examples of context menus for different use cases.',
|
|
761
|
+
},
|
|
762
|
+
},
|
|
763
|
+
},
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
export const UseCases: Story = {
|
|
767
|
+
render: () => (
|
|
768
|
+
<Stack gap="lg" w={600}>
|
|
769
|
+
<Title order={3} size="md" fw={500} mb="xs">Common Use Cases</Title>
|
|
770
|
+
|
|
771
|
+
<div>
|
|
772
|
+
<Text size="sm" fw={500} mb="sm">1. Action Menus:</Text>
|
|
773
|
+
<Inline gap="sm">
|
|
774
|
+
<Menu
|
|
775
|
+
trigger={<Button variant="primary" size="sm">Actions</Button>}
|
|
776
|
+
sections={[
|
|
777
|
+
{
|
|
778
|
+
items: [
|
|
779
|
+
{ id: 'create', label: 'Create New', leftSection: <span>+</span> },
|
|
780
|
+
{ id: 'import', label: 'Import', leftSection: <span>⬆</span> },
|
|
781
|
+
{ id: 'export', label: 'Export', leftSection: <span>⬇</span> },
|
|
782
|
+
],
|
|
783
|
+
},
|
|
784
|
+
]}
|
|
785
|
+
/>
|
|
786
|
+
</Inline>
|
|
787
|
+
</div>
|
|
788
|
+
|
|
789
|
+
<div>
|
|
790
|
+
<Text size="sm" fw={500} mb="sm">2. Dropdown Navigation:</Text>
|
|
791
|
+
<Inline gap="sm">
|
|
792
|
+
<Menu
|
|
793
|
+
trigger={<Button variant="outline" size="sm">Products ▼</Button>}
|
|
794
|
+
sections={[
|
|
795
|
+
{
|
|
796
|
+
title: 'Categories',
|
|
797
|
+
items: [
|
|
798
|
+
{ id: 'electronics', label: 'Electronics', onClick: () => console.log('Electronics') },
|
|
799
|
+
{ id: 'clothing', label: 'Clothing', onClick: () => console.log('Clothing') },
|
|
800
|
+
{ id: 'books', label: 'Books', onClick: () => console.log('Books') },
|
|
801
|
+
],
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
title: 'Featured',
|
|
805
|
+
items: [
|
|
806
|
+
{ id: 'new-arrivals', label: 'New Arrivals', onClick: () => console.log('New Arrivals') },
|
|
807
|
+
{ id: 'bestsellers', label: 'Best Sellers', onClick: () => console.log('Best Sellers') },
|
|
808
|
+
{ id: 'sale', label: 'Sale Items', color: 'red', onClick: () => console.log('Sale') },
|
|
809
|
+
],
|
|
810
|
+
},
|
|
811
|
+
]}
|
|
812
|
+
/>
|
|
813
|
+
</Inline>
|
|
814
|
+
</div>
|
|
815
|
+
|
|
816
|
+
<div>
|
|
817
|
+
<Text size="sm" fw={500} mb="sm">3. User Account Menu:</Text>
|
|
818
|
+
<Inline gap="sm">
|
|
819
|
+
<Menu
|
|
820
|
+
trigger={
|
|
821
|
+
<div style={{
|
|
822
|
+
display: 'flex',
|
|
823
|
+
alignItems: 'center',
|
|
824
|
+
gap: '8px',
|
|
825
|
+
padding: '6px 12px',
|
|
826
|
+
border: '1px solid var(--mantine-color-gray-3)',
|
|
827
|
+
borderRadius: '20px',
|
|
828
|
+
cursor: 'pointer',
|
|
829
|
+
backgroundColor: 'white'
|
|
830
|
+
}}>
|
|
831
|
+
<div style={{
|
|
832
|
+
width: 24,
|
|
833
|
+
height: 24,
|
|
834
|
+
borderRadius: '50%',
|
|
835
|
+
backgroundColor: 'var(--mantine-color-blue-6)',
|
|
836
|
+
display: 'flex',
|
|
837
|
+
alignItems: 'center',
|
|
838
|
+
justifyContent: 'center',
|
|
839
|
+
color: 'white',
|
|
840
|
+
fontSize: '12px'
|
|
841
|
+
}}>
|
|
842
|
+
JD
|
|
843
|
+
</div>
|
|
844
|
+
<Text size="sm">John Doe</Text>
|
|
845
|
+
<span style={{ fontSize: '10px' }}>▼</span>
|
|
846
|
+
</div>
|
|
847
|
+
}
|
|
848
|
+
sections={[
|
|
849
|
+
{
|
|
850
|
+
title: 'Account',
|
|
851
|
+
items: [
|
|
852
|
+
{ id: 'profile', label: 'My Profile', leftSection: <span>👤</span> },
|
|
853
|
+
{ id: 'settings', label: 'Settings', leftSection: <span>⚙</span> },
|
|
854
|
+
{ id: 'billing', label: 'Billing', leftSection: <span>💳</span> },
|
|
855
|
+
],
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
title: 'Support',
|
|
859
|
+
items: [
|
|
860
|
+
{ id: 'help', label: 'Help', leftSection: <span>❓</span> },
|
|
861
|
+
{ id: 'feedback', label: 'Feedback', leftSection: <span>💬</span> },
|
|
862
|
+
],
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
items: [
|
|
866
|
+
{ id: 'logout', label: 'Sign Out', leftSection: <span>🚪</span>, color: 'red' },
|
|
867
|
+
],
|
|
868
|
+
},
|
|
869
|
+
]}
|
|
870
|
+
/>
|
|
871
|
+
</Inline>
|
|
872
|
+
</div>
|
|
873
|
+
|
|
874
|
+
<div>
|
|
875
|
+
<Text size="sm" fw={500} mb="sm">4. More Options Menu:</Text>
|
|
876
|
+
<Inline gap="sm">
|
|
877
|
+
<Menu
|
|
878
|
+
trigger={
|
|
879
|
+
<ThemeIcon variant="default" size="sm" style={{ cursor: 'pointer' }}>
|
|
880
|
+
<span>⋯</span>
|
|
881
|
+
</ThemeIcon>
|
|
882
|
+
}
|
|
883
|
+
sections={[
|
|
884
|
+
{
|
|
885
|
+
items: [
|
|
886
|
+
{ id: 'share', label: 'Share', leftSection: <span>↗</span> },
|
|
887
|
+
{ id: 'bookmark', label: 'Bookmark', leftSection: <span>🔖</span> },
|
|
888
|
+
{ id: 'report', label: 'Report', leftSection: <span>🚩</span>, color: 'red' },
|
|
889
|
+
],
|
|
890
|
+
},
|
|
891
|
+
]}
|
|
892
|
+
/>
|
|
893
|
+
</Inline>
|
|
894
|
+
</div>
|
|
895
|
+
</Stack>
|
|
896
|
+
),
|
|
897
|
+
parameters: {
|
|
898
|
+
docs: {
|
|
899
|
+
description: {
|
|
900
|
+
story: 'Real-world examples of Menu usage in different application contexts.',
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
export const Interactive: Story = {
|
|
907
|
+
render: () => (
|
|
908
|
+
<Menu
|
|
909
|
+
width={200}
|
|
910
|
+
shadow="md"
|
|
911
|
+
position="bottom-start"
|
|
912
|
+
trigger={<Button>Interactive Menu</Button>}
|
|
913
|
+
sections={[
|
|
914
|
+
{
|
|
915
|
+
title: 'Interactive Section',
|
|
916
|
+
items: [
|
|
917
|
+
{
|
|
918
|
+
id: 'item1',
|
|
919
|
+
label: 'Item 1',
|
|
920
|
+
leftSection: <span>1️⃣</span>,
|
|
921
|
+
onClick: () => console.log('Item 1 clicked'),
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
id: 'item2',
|
|
925
|
+
label: 'Item 2',
|
|
926
|
+
leftSection: <span>2️⃣</span>,
|
|
927
|
+
onClick: () => console.log('Item 2 clicked'),
|
|
928
|
+
},
|
|
929
|
+
],
|
|
930
|
+
},
|
|
931
|
+
]}
|
|
932
|
+
/>
|
|
933
|
+
),
|
|
934
|
+
parameters: {
|
|
935
|
+
docs: {
|
|
936
|
+
description: {
|
|
937
|
+
story: 'Use the controls below to interact with the Menu and see different combinations.',
|
|
938
|
+
},
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
};
|