@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,780 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
|
|
2
|
+
import { Stack } from '@mantine/core';
|
|
3
|
+
import { Inline, Popover, ConfirmationPopover, Title, Text, Button, TextInput, Switch, ThemeIcon } from '@appdirect/design-system';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Popover> = {
|
|
7
|
+
title: 'Design System/Overlays/Popover',
|
|
8
|
+
component: Popover,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: 'Popover component for displaying contextual content with flexible positioning and action buttons.',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
tags: ['autodocs', 'code-connected'],
|
|
18
|
+
argTypes: {
|
|
19
|
+
position: {
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: ['top', 'left', 'right', 'bottom'],
|
|
22
|
+
description: 'Popover position relative to target',
|
|
23
|
+
},
|
|
24
|
+
title: {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'Popover title',
|
|
27
|
+
},
|
|
28
|
+
width: {
|
|
29
|
+
control: 'number',
|
|
30
|
+
description: 'Popover width',
|
|
31
|
+
},
|
|
32
|
+
withArrow: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Whether to show arrow',
|
|
35
|
+
},
|
|
36
|
+
closeOnClickOutside: {
|
|
37
|
+
control: 'boolean',
|
|
38
|
+
description: 'Whether popover can be closed by clicking outside',
|
|
39
|
+
},
|
|
40
|
+
closeOnEscape: {
|
|
41
|
+
control: 'boolean',
|
|
42
|
+
description: 'Whether popover can be closed by pressing Escape',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default meta;
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
49
|
+
|
|
50
|
+
export const Default: Story = {
|
|
51
|
+
render: () => (
|
|
52
|
+
<Popover
|
|
53
|
+
trigger={<Button>Show Popover</Button>}
|
|
54
|
+
title="Information"
|
|
55
|
+
>
|
|
56
|
+
<Text size="sm">This is a basic popover with some helpful information.</Text>
|
|
57
|
+
</Popover>
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Positions: Story = {
|
|
62
|
+
render: () => (
|
|
63
|
+
<Stack gap="xl" align="center">
|
|
64
|
+
<Inline gap="xl">
|
|
65
|
+
<Popover
|
|
66
|
+
trigger={<Button variant="outline" size="sm">Top</Button>}
|
|
67
|
+
title="Top Popover"
|
|
68
|
+
position="top"
|
|
69
|
+
>
|
|
70
|
+
<Text size="sm">This popover appears above the trigger.</Text>
|
|
71
|
+
</Popover>
|
|
72
|
+
|
|
73
|
+
<Popover
|
|
74
|
+
trigger={<Button variant="outline" size="sm">Bottom</Button>}
|
|
75
|
+
title="Bottom Popover"
|
|
76
|
+
position="bottom"
|
|
77
|
+
>
|
|
78
|
+
<Text size="sm">This popover appears below the trigger.</Text>
|
|
79
|
+
</Popover>
|
|
80
|
+
</Inline>
|
|
81
|
+
|
|
82
|
+
<Inline gap="xl">
|
|
83
|
+
<Popover
|
|
84
|
+
trigger={<Button variant="outline" size="sm">Left</Button>}
|
|
85
|
+
title="Left Popover"
|
|
86
|
+
position="left"
|
|
87
|
+
>
|
|
88
|
+
<Text size="sm">This popover appears to the left of the trigger.</Text>
|
|
89
|
+
</Popover>
|
|
90
|
+
|
|
91
|
+
<Popover
|
|
92
|
+
trigger={<Button variant="outline" size="sm">Right</Button>}
|
|
93
|
+
title="Right Popover"
|
|
94
|
+
position="right"
|
|
95
|
+
>
|
|
96
|
+
<Text size="sm">This popover appears to the right of the trigger.</Text>
|
|
97
|
+
</Popover>
|
|
98
|
+
</Inline>
|
|
99
|
+
</Stack>
|
|
100
|
+
),
|
|
101
|
+
parameters: {
|
|
102
|
+
docs: {
|
|
103
|
+
description: {
|
|
104
|
+
story: 'Different positioning options for the Popover component.',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const WithActions: Story = {
|
|
111
|
+
render: () => {
|
|
112
|
+
const [loading, setLoading] = useState(false);
|
|
113
|
+
|
|
114
|
+
const handleSave = () => {
|
|
115
|
+
setLoading(true);
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
setLoading(false);
|
|
118
|
+
console.log('Saved!');
|
|
119
|
+
}, 2000);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Popover
|
|
124
|
+
trigger={<Button>Actions Popover</Button>}
|
|
125
|
+
title="Confirm Action"
|
|
126
|
+
actions={[
|
|
127
|
+
{
|
|
128
|
+
id: 'save',
|
|
129
|
+
label: 'Save Changes',
|
|
130
|
+
variant: 'primary',
|
|
131
|
+
onClick: handleSave,
|
|
132
|
+
loading: loading,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 'cancel',
|
|
136
|
+
label: 'Cancel',
|
|
137
|
+
variant: 'outline',
|
|
138
|
+
closeOnClick: true,
|
|
139
|
+
},
|
|
140
|
+
]}
|
|
141
|
+
>
|
|
142
|
+
<Text size="sm">Are you sure you want to save these changes?</Text>
|
|
143
|
+
</Popover>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
parameters: {
|
|
147
|
+
docs: {
|
|
148
|
+
description: {
|
|
149
|
+
story: 'Popover with action buttons including loading states.',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const WithTertiaryActions: Story = {
|
|
156
|
+
render: () => (
|
|
157
|
+
<Popover
|
|
158
|
+
trigger={<Button>Complex Actions</Button>}
|
|
159
|
+
title="File Actions"
|
|
160
|
+
actions={[
|
|
161
|
+
{
|
|
162
|
+
id: 'save',
|
|
163
|
+
label: 'Save',
|
|
164
|
+
variant: 'primary',
|
|
165
|
+
closeOnClick: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'cancel',
|
|
169
|
+
label: 'Cancel',
|
|
170
|
+
variant: 'outline',
|
|
171
|
+
closeOnClick: true,
|
|
172
|
+
},
|
|
173
|
+
]}
|
|
174
|
+
tertiaryActions={[
|
|
175
|
+
{
|
|
176
|
+
id: 'more',
|
|
177
|
+
label: 'More Options',
|
|
178
|
+
variant: 'default',
|
|
179
|
+
onClick: () => alert('More options clicked'),
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: 'help',
|
|
183
|
+
label: 'Help',
|
|
184
|
+
variant: 'outline',
|
|
185
|
+
onClick: () => alert('Help clicked'),
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
>
|
|
189
|
+
<Text size="sm">
|
|
190
|
+
This popover demonstrates the action layout: primary actions on the left,
|
|
191
|
+
tertiary actions on the right.
|
|
192
|
+
</Text>
|
|
193
|
+
</Popover>
|
|
194
|
+
),
|
|
195
|
+
parameters: {
|
|
196
|
+
docs: {
|
|
197
|
+
description: {
|
|
198
|
+
story: 'Popover with both primary actions (left) and tertiary actions (right).',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const FormPopover: Story = {
|
|
205
|
+
render: () => {
|
|
206
|
+
const [formData, setFormData] = useState({
|
|
207
|
+
name: '',
|
|
208
|
+
email: '',
|
|
209
|
+
notifications: false,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const handleSubmit = () => {
|
|
213
|
+
console.log('Form data:', formData);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<Popover
|
|
218
|
+
trigger={<Button>Quick Form</Button>}
|
|
219
|
+
title="Quick Settings"
|
|
220
|
+
width={300}
|
|
221
|
+
actions={[
|
|
222
|
+
{
|
|
223
|
+
id: 'apply',
|
|
224
|
+
label: 'Apply',
|
|
225
|
+
variant: 'primary',
|
|
226
|
+
onClick: handleSubmit,
|
|
227
|
+
disabled: !formData.name.trim(),
|
|
228
|
+
closeOnClick: true,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: 'cancel',
|
|
232
|
+
label: 'Cancel',
|
|
233
|
+
variant: 'outline',
|
|
234
|
+
closeOnClick: true,
|
|
235
|
+
},
|
|
236
|
+
]}
|
|
237
|
+
>
|
|
238
|
+
<Stack gap="sm">
|
|
239
|
+
<TextInput
|
|
240
|
+
label="Name"
|
|
241
|
+
placeholder="Enter name..."
|
|
242
|
+
value={formData.name}
|
|
243
|
+
onChange={(e) => setFormData(prev => ({ ...prev, name: e.target.value }))}
|
|
244
|
+
size="sm"
|
|
245
|
+
/>
|
|
246
|
+
<TextInput
|
|
247
|
+
label="Email"
|
|
248
|
+
placeholder="Enter email..."
|
|
249
|
+
value={formData.email}
|
|
250
|
+
onChange={(e) => setFormData(prev => ({ ...prev, email: e.target.value }))}
|
|
251
|
+
size="sm"
|
|
252
|
+
/>
|
|
253
|
+
<Switch
|
|
254
|
+
label="Enable notifications"
|
|
255
|
+
checked={formData.notifications}
|
|
256
|
+
onChange={(e) => setFormData(prev => ({ ...prev, notifications: e.target.checked }))}
|
|
257
|
+
/>
|
|
258
|
+
</Stack>
|
|
259
|
+
</Popover>
|
|
260
|
+
);
|
|
261
|
+
},
|
|
262
|
+
parameters: {
|
|
263
|
+
docs: {
|
|
264
|
+
description: {
|
|
265
|
+
story: 'Popover containing a form with validation and state management.',
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export const ConfirmationPopovers: Story = {
|
|
272
|
+
render: () => (
|
|
273
|
+
<Inline gap="lg">
|
|
274
|
+
<ConfirmationPopover
|
|
275
|
+
trigger={<Button variant="outline">Basic Confirmation</Button>}
|
|
276
|
+
title="Confirm Action"
|
|
277
|
+
onConfirm={() => console.log('Confirmed!')}
|
|
278
|
+
onCancel={() => console.log('Cancelled!')}
|
|
279
|
+
>
|
|
280
|
+
<Text size="sm">Are you sure you want to perform this action?</Text>
|
|
281
|
+
</ConfirmationPopover>
|
|
282
|
+
|
|
283
|
+
<ConfirmationPopover
|
|
284
|
+
trigger={<Button color="red" variant="outline">Delete Item</Button>}
|
|
285
|
+
title="Delete Item"
|
|
286
|
+
confirmLabel="Delete"
|
|
287
|
+
confirmVariant="danger"
|
|
288
|
+
onConfirm={() => console.log('Item deleted!')}
|
|
289
|
+
onCancel={() => console.log('Delete cancelled!')}
|
|
290
|
+
>
|
|
291
|
+
<Text size="sm">This action cannot be undone. Are you sure you want to delete this item?</Text>
|
|
292
|
+
</ConfirmationPopover>
|
|
293
|
+
|
|
294
|
+
<ConfirmationPopover
|
|
295
|
+
trigger={<Button variant="outline">Custom Confirmation</Button>}
|
|
296
|
+
title="Custom Action"
|
|
297
|
+
confirmLabel="Yes, Continue"
|
|
298
|
+
cancelLabel="No, Go Back"
|
|
299
|
+
confirmVariant="primary"
|
|
300
|
+
onConfirm={() => console.log('Custom action confirmed!')}
|
|
301
|
+
onCancel={() => console.log('Custom action cancelled!')}
|
|
302
|
+
tertiaryActions={[
|
|
303
|
+
{
|
|
304
|
+
id: 'more-info',
|
|
305
|
+
label: 'More Info',
|
|
306
|
+
variant: 'default',
|
|
307
|
+
onClick: () => alert('More information about this action...'),
|
|
308
|
+
},
|
|
309
|
+
]}
|
|
310
|
+
>
|
|
311
|
+
<Text size="sm">
|
|
312
|
+
This is a custom confirmation popover with different button labels and tertiary actions.
|
|
313
|
+
</Text>
|
|
314
|
+
</ConfirmationPopover>
|
|
315
|
+
</Inline>
|
|
316
|
+
),
|
|
317
|
+
parameters: {
|
|
318
|
+
docs: {
|
|
319
|
+
description: {
|
|
320
|
+
story: 'Pre-configured ConfirmationPopover variants for common confirmation patterns.',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const DifferentTriggers: Story = {
|
|
327
|
+
render: () => (
|
|
328
|
+
<Stack gap="lg" w={500}>
|
|
329
|
+
<div>
|
|
330
|
+
<Text size="sm" fw={500} mb="sm">Button Triggers:</Text>
|
|
331
|
+
<Inline gap="sm">
|
|
332
|
+
<Popover
|
|
333
|
+
trigger={<Button variant="primary" size="sm">Primary</Button>}
|
|
334
|
+
title="Primary Button"
|
|
335
|
+
>
|
|
336
|
+
<Text size="sm">Popover triggered by a primary button.</Text>
|
|
337
|
+
</Popover>
|
|
338
|
+
|
|
339
|
+
<Popover
|
|
340
|
+
trigger={<Button variant="outline" size="sm">Outline</Button>}
|
|
341
|
+
title="Outline Button"
|
|
342
|
+
>
|
|
343
|
+
<Text size="sm">Popover triggered by an outline button.</Text>
|
|
344
|
+
</Popover>
|
|
345
|
+
</Inline>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<div>
|
|
349
|
+
<Text size="sm" fw={500} mb="sm">Icon Triggers:</Text>
|
|
350
|
+
<Inline gap="sm">
|
|
351
|
+
<Popover
|
|
352
|
+
trigger={
|
|
353
|
+
<ThemeIcon variant="info" size="sm" style={{ cursor: 'pointer' }}>
|
|
354
|
+
<span>ℹ</span>
|
|
355
|
+
</ThemeIcon>
|
|
356
|
+
}
|
|
357
|
+
title="Information"
|
|
358
|
+
position="top"
|
|
359
|
+
>
|
|
360
|
+
<Text size="sm">This is helpful information about the feature.</Text>
|
|
361
|
+
</Popover>
|
|
362
|
+
|
|
363
|
+
<Popover
|
|
364
|
+
trigger={
|
|
365
|
+
<ThemeIcon variant="default" size="sm" style={{ cursor: 'pointer' }}>
|
|
366
|
+
<span>⚙</span>
|
|
367
|
+
</ThemeIcon>
|
|
368
|
+
}
|
|
369
|
+
title="Settings"
|
|
370
|
+
position="bottom"
|
|
371
|
+
>
|
|
372
|
+
<Text size="sm">Quick settings and configuration options.</Text>
|
|
373
|
+
</Popover>
|
|
374
|
+
|
|
375
|
+
<Popover
|
|
376
|
+
trigger={
|
|
377
|
+
<ThemeIcon variant="warning" size="sm" style={{ cursor: 'pointer' }}>
|
|
378
|
+
<span>⚠</span>
|
|
379
|
+
</ThemeIcon>
|
|
380
|
+
}
|
|
381
|
+
title="Warning"
|
|
382
|
+
position="right"
|
|
383
|
+
>
|
|
384
|
+
<Text size="sm">Important warning information to consider.</Text>
|
|
385
|
+
</Popover>
|
|
386
|
+
</Inline>
|
|
387
|
+
</div>
|
|
388
|
+
|
|
389
|
+
<div>
|
|
390
|
+
<Text size="sm" fw={500} mb="sm">Text Triggers:</Text>
|
|
391
|
+
<Inline gap="sm">
|
|
392
|
+
<Popover
|
|
393
|
+
trigger={
|
|
394
|
+
<Text
|
|
395
|
+
size="sm"
|
|
396
|
+
style={{
|
|
397
|
+
textDecoration: 'underline dotted',
|
|
398
|
+
cursor: 'help',
|
|
399
|
+
color: 'var(--mantine-color-blue-6)'
|
|
400
|
+
}}
|
|
401
|
+
>
|
|
402
|
+
Hover for details
|
|
403
|
+
</Text>
|
|
404
|
+
}
|
|
405
|
+
title="Details"
|
|
406
|
+
>
|
|
407
|
+
<Text size="sm">Additional details about this item or feature.</Text>
|
|
408
|
+
</Popover>
|
|
409
|
+
|
|
410
|
+
<Popover
|
|
411
|
+
trigger={
|
|
412
|
+
<Text
|
|
413
|
+
size="sm"
|
|
414
|
+
fw={500}
|
|
415
|
+
style={{
|
|
416
|
+
borderBottom: '1px dotted var(--mantine-color-gray-5)',
|
|
417
|
+
cursor: 'help'
|
|
418
|
+
}}
|
|
419
|
+
>
|
|
420
|
+
API
|
|
421
|
+
</Text>
|
|
422
|
+
}
|
|
423
|
+
title="API Information"
|
|
424
|
+
>
|
|
425
|
+
<Text size="sm">Application Programming Interface - details about our API.</Text>
|
|
426
|
+
</Popover>
|
|
427
|
+
</Inline>
|
|
428
|
+
</div>
|
|
429
|
+
</Stack>
|
|
430
|
+
),
|
|
431
|
+
parameters: {
|
|
432
|
+
docs: {
|
|
433
|
+
description: {
|
|
434
|
+
story: 'Popover attached to different types of trigger elements.',
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
export const ControlledPopover: Story = {
|
|
441
|
+
render: () => {
|
|
442
|
+
const [opened, setOpened] = useState(false);
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<Stack gap="md" align="center">
|
|
446
|
+
<Inline gap="sm">
|
|
447
|
+
<Button
|
|
448
|
+
variant="outline"
|
|
449
|
+
size="sm"
|
|
450
|
+
onClick={() => setOpened(true)}
|
|
451
|
+
>
|
|
452
|
+
Open Popover
|
|
453
|
+
</Button>
|
|
454
|
+
<Button
|
|
455
|
+
variant="outline"
|
|
456
|
+
size="sm"
|
|
457
|
+
onClick={() => setOpened(false)}
|
|
458
|
+
>
|
|
459
|
+
Close Popover
|
|
460
|
+
</Button>
|
|
461
|
+
</Inline>
|
|
462
|
+
|
|
463
|
+
<Popover
|
|
464
|
+
trigger={<Button>Controlled Popover</Button>}
|
|
465
|
+
title="Controlled State"
|
|
466
|
+
opened={opened}
|
|
467
|
+
onChange={setOpened}
|
|
468
|
+
onClose={() => setOpened(false)}
|
|
469
|
+
actions={[
|
|
470
|
+
{
|
|
471
|
+
id: 'action',
|
|
472
|
+
label: 'Action',
|
|
473
|
+
variant: 'primary',
|
|
474
|
+
onClick: () => {
|
|
475
|
+
console.log('Action clicked');
|
|
476
|
+
setOpened(false);
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: 'keep-open',
|
|
481
|
+
label: 'Keep Open',
|
|
482
|
+
variant: 'outline',
|
|
483
|
+
onClick: () => console.log('Popover stays open'),
|
|
484
|
+
},
|
|
485
|
+
]}
|
|
486
|
+
>
|
|
487
|
+
<Text size="sm">
|
|
488
|
+
This popover's state is controlled externally. Use the buttons above to control it.
|
|
489
|
+
</Text>
|
|
490
|
+
</Popover>
|
|
491
|
+
|
|
492
|
+
<Text size="sm" c="dimmed">
|
|
493
|
+
Popover is currently: {opened ? 'Open' : 'Closed'}
|
|
494
|
+
</Text>
|
|
495
|
+
</Stack>
|
|
496
|
+
);
|
|
497
|
+
},
|
|
498
|
+
parameters: {
|
|
499
|
+
docs: {
|
|
500
|
+
description: {
|
|
501
|
+
story: 'Popover with controlled open/close state.',
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
export const ContextualPopovers: Story = {
|
|
508
|
+
render: () => (
|
|
509
|
+
<Stack gap="lg" w={600}>
|
|
510
|
+
<div>
|
|
511
|
+
<Text size="sm" fw={500} mb="sm">Help & Information:</Text>
|
|
512
|
+
<Inline gap="md" align="center">
|
|
513
|
+
<Text size="sm">Password</Text>
|
|
514
|
+
<Popover
|
|
515
|
+
trigger={
|
|
516
|
+
<ThemeIcon variant="info" size="xs" style={{ cursor: 'pointer' }}>
|
|
517
|
+
<span style={{ fontSize: '10px' }}>?</span>
|
|
518
|
+
</ThemeIcon>
|
|
519
|
+
}
|
|
520
|
+
title="Password Requirements"
|
|
521
|
+
width={250}
|
|
522
|
+
position="right"
|
|
523
|
+
>
|
|
524
|
+
<Stack gap="xs">
|
|
525
|
+
<Text size="xs">• At least 8 characters long</Text>
|
|
526
|
+
<Text size="xs">• Contains uppercase and lowercase letters</Text>
|
|
527
|
+
<Text size="xs">• Contains at least one number</Text>
|
|
528
|
+
<Text size="xs">• Contains at least one special character</Text>
|
|
529
|
+
</Stack>
|
|
530
|
+
</Popover>
|
|
531
|
+
</Inline>
|
|
532
|
+
</div>
|
|
533
|
+
|
|
534
|
+
<div>
|
|
535
|
+
<Text size="sm" fw={500} mb="sm">Quick Actions:</Text>
|
|
536
|
+
<Inline gap="sm">
|
|
537
|
+
<Popover
|
|
538
|
+
trigger={
|
|
539
|
+
<div style={{
|
|
540
|
+
padding: '8px 12px',
|
|
541
|
+
border: '1px solid var(--mantine-color-gray-3)',
|
|
542
|
+
borderRadius: '6px',
|
|
543
|
+
cursor: 'pointer',
|
|
544
|
+
backgroundColor: 'white',
|
|
545
|
+
display: 'flex',
|
|
546
|
+
alignItems: 'center',
|
|
547
|
+
gap: '8px'
|
|
548
|
+
}}>
|
|
549
|
+
<span>📄</span>
|
|
550
|
+
<Text size="sm">document.pdf</Text>
|
|
551
|
+
<span style={{ fontSize: '12px', color: 'var(--mantine-color-gray-6)' }}>▼</span>
|
|
552
|
+
</div>
|
|
553
|
+
}
|
|
554
|
+
title="File Actions"
|
|
555
|
+
actions={[
|
|
556
|
+
{
|
|
557
|
+
id: 'download',
|
|
558
|
+
label: 'Download',
|
|
559
|
+
variant: 'primary',
|
|
560
|
+
closeOnClick: true,
|
|
561
|
+
},
|
|
562
|
+
]}
|
|
563
|
+
tertiaryActions={[
|
|
564
|
+
{
|
|
565
|
+
id: 'share',
|
|
566
|
+
label: 'Share',
|
|
567
|
+
variant: 'outline',
|
|
568
|
+
closeOnClick: true,
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
id: 'delete',
|
|
572
|
+
label: 'Delete',
|
|
573
|
+
variant: 'outline',
|
|
574
|
+
closeOnClick: true,
|
|
575
|
+
},
|
|
576
|
+
]}
|
|
577
|
+
>
|
|
578
|
+
<Text size="sm">Choose an action for this file.</Text>
|
|
579
|
+
</Popover>
|
|
580
|
+
</Inline>
|
|
581
|
+
</div>
|
|
582
|
+
|
|
583
|
+
<div>
|
|
584
|
+
<Text size="sm" fw={500} mb="sm">Status Information:</Text>
|
|
585
|
+
<Inline gap="md">
|
|
586
|
+
<Popover
|
|
587
|
+
trigger={
|
|
588
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px', cursor: 'pointer' }}>
|
|
589
|
+
<div style={{
|
|
590
|
+
width: 8,
|
|
591
|
+
height: 8,
|
|
592
|
+
borderRadius: '50%',
|
|
593
|
+
backgroundColor: 'var(--mantine-color-green-6)'
|
|
594
|
+
}} />
|
|
595
|
+
<Text size="sm">System Online</Text>
|
|
596
|
+
</div>
|
|
597
|
+
}
|
|
598
|
+
title="System Status"
|
|
599
|
+
position="top"
|
|
600
|
+
>
|
|
601
|
+
<Stack gap="xs">
|
|
602
|
+
<Inline gap="xs" justify="space-between">
|
|
603
|
+
<Text size="xs">API Server</Text>
|
|
604
|
+
<Text size="xs" c="green">Online</Text>
|
|
605
|
+
</Inline>
|
|
606
|
+
<Inline gap="xs" justify="space-between">
|
|
607
|
+
<Text size="xs">Database</Text>
|
|
608
|
+
<Text size="xs" c="green">Online</Text>
|
|
609
|
+
</Inline>
|
|
610
|
+
<Inline gap="xs" justify="space-between">
|
|
611
|
+
<Text size="xs">Cache</Text>
|
|
612
|
+
<Text size="xs" c="green">Online</Text>
|
|
613
|
+
</Inline>
|
|
614
|
+
<Inline gap="xs" justify="space-between">
|
|
615
|
+
<Text size="xs">Last Check</Text>
|
|
616
|
+
<Text size="xs" c="dimmed">2 min ago</Text>
|
|
617
|
+
</Inline>
|
|
618
|
+
</Stack>
|
|
619
|
+
</Popover>
|
|
620
|
+
</Inline>
|
|
621
|
+
</div>
|
|
622
|
+
</Stack>
|
|
623
|
+
),
|
|
624
|
+
parameters: {
|
|
625
|
+
docs: {
|
|
626
|
+
description: {
|
|
627
|
+
story: 'Real-world examples of contextual popover usage.',
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
export const UseCases: Story = {
|
|
634
|
+
render: () => (
|
|
635
|
+
<Stack gap="xl" w={700}>
|
|
636
|
+
<Title order={3} size="md" fw={500} mb="xs">Common Use Cases</Title>
|
|
637
|
+
|
|
638
|
+
<div>
|
|
639
|
+
<Text size="sm" fw={500} mb="sm">1. Form Field Help:</Text>
|
|
640
|
+
<Inline gap="xs" align="center">
|
|
641
|
+
<TextInput
|
|
642
|
+
label="API Key"
|
|
643
|
+
placeholder="Enter your API key..."
|
|
644
|
+
style={{ flex: 1 }}
|
|
645
|
+
/>
|
|
646
|
+
<Popover
|
|
647
|
+
trigger={
|
|
648
|
+
<ThemeIcon variant="info" size="sm" style={{ cursor: 'pointer' }}>
|
|
649
|
+
<span>?</span>
|
|
650
|
+
</ThemeIcon>
|
|
651
|
+
}
|
|
652
|
+
title="API Key Help"
|
|
653
|
+
width={250}
|
|
654
|
+
position="right"
|
|
655
|
+
>
|
|
656
|
+
<Text size="sm">
|
|
657
|
+
You can find your API key in your account settings under the "Developers" section.
|
|
658
|
+
</Text>
|
|
659
|
+
</Popover>
|
|
660
|
+
</Inline>
|
|
661
|
+
</div>
|
|
662
|
+
|
|
663
|
+
<div>
|
|
664
|
+
<Text size="sm" fw={500} mb="sm">2. Quick Confirmations:</Text>
|
|
665
|
+
<Inline gap="sm">
|
|
666
|
+
<ConfirmationPopover
|
|
667
|
+
trigger={<Button variant="outline" size="sm">Archive Item</Button>}
|
|
668
|
+
title="Archive Item"
|
|
669
|
+
confirmLabel="Archive"
|
|
670
|
+
onConfirm={() => console.log('Item archived')}
|
|
671
|
+
>
|
|
672
|
+
<Text size="sm">This item will be moved to the archive.</Text>
|
|
673
|
+
</ConfirmationPopover>
|
|
674
|
+
|
|
675
|
+
<ConfirmationPopover
|
|
676
|
+
trigger={<Button color="red" variant="outline" size="sm">Delete</Button>}
|
|
677
|
+
title="Delete Item"
|
|
678
|
+
confirmLabel="Delete"
|
|
679
|
+
confirmVariant="danger"
|
|
680
|
+
onConfirm={() => console.log('Item deleted')}
|
|
681
|
+
>
|
|
682
|
+
<Text size="sm">This action cannot be undone.</Text>
|
|
683
|
+
</ConfirmationPopover>
|
|
684
|
+
</Inline>
|
|
685
|
+
</div>
|
|
686
|
+
|
|
687
|
+
<div>
|
|
688
|
+
<Text size="sm" fw={500} mb="sm">3. Feature Previews:</Text>
|
|
689
|
+
<Inline gap="sm">
|
|
690
|
+
<Popover
|
|
691
|
+
trigger={<Button variant="outline" size="sm">Preview Feature</Button>}
|
|
692
|
+
title="New Dashboard"
|
|
693
|
+
width={300}
|
|
694
|
+
actions={[
|
|
695
|
+
{
|
|
696
|
+
id: 'enable',
|
|
697
|
+
label: 'Enable Beta',
|
|
698
|
+
variant: 'primary',
|
|
699
|
+
closeOnClick: true,
|
|
700
|
+
},
|
|
701
|
+
]}
|
|
702
|
+
>
|
|
703
|
+
<Stack gap="sm">
|
|
704
|
+
<Text size="sm">
|
|
705
|
+
Try our new dashboard with improved analytics and better performance.
|
|
706
|
+
</Text>
|
|
707
|
+
<div style={{
|
|
708
|
+
width: '100%',
|
|
709
|
+
height: 80,
|
|
710
|
+
backgroundColor: 'var(--mantine-color-gray-1)',
|
|
711
|
+
borderRadius: '4px',
|
|
712
|
+
display: 'flex',
|
|
713
|
+
alignItems: 'center',
|
|
714
|
+
justifyContent: 'center'
|
|
715
|
+
}}>
|
|
716
|
+
<Text size="xs" c="dimmed">Dashboard Preview</Text>
|
|
717
|
+
</div>
|
|
718
|
+
</Stack>
|
|
719
|
+
</Popover>
|
|
720
|
+
</Inline>
|
|
721
|
+
</div>
|
|
722
|
+
|
|
723
|
+
<div>
|
|
724
|
+
<Text size="sm" fw={500} mb="sm">4. Settings Shortcuts:</Text>
|
|
725
|
+
<Inline gap="sm">
|
|
726
|
+
<Popover
|
|
727
|
+
trigger={
|
|
728
|
+
<ThemeIcon variant="default" size="md" style={{ cursor: 'pointer' }}>
|
|
729
|
+
<span>⚙</span>
|
|
730
|
+
</ThemeIcon>
|
|
731
|
+
}
|
|
732
|
+
title="Quick Settings"
|
|
733
|
+
width={250}
|
|
734
|
+
actions={[
|
|
735
|
+
{
|
|
736
|
+
id: 'save',
|
|
737
|
+
label: 'Save',
|
|
738
|
+
variant: 'primary',
|
|
739
|
+
closeOnClick: true,
|
|
740
|
+
},
|
|
741
|
+
]}
|
|
742
|
+
>
|
|
743
|
+
<Stack gap="sm">
|
|
744
|
+
<Switch label="Dark mode" />
|
|
745
|
+
<Switch label="Email notifications" defaultChecked />
|
|
746
|
+
<Switch label="Auto-save" defaultChecked />
|
|
747
|
+
</Stack>
|
|
748
|
+
</Popover>
|
|
749
|
+
</Inline>
|
|
750
|
+
</div>
|
|
751
|
+
</Stack>
|
|
752
|
+
),
|
|
753
|
+
parameters: {
|
|
754
|
+
docs: {
|
|
755
|
+
description: {
|
|
756
|
+
story: 'Real-world examples of Popover usage in different application contexts.',
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
export const Interactive: Story = {
|
|
763
|
+
args: {
|
|
764
|
+
title: 'Interactive Popover',
|
|
765
|
+
position: 'bottom',
|
|
766
|
+
width: 'auto',
|
|
767
|
+
withArrow: true,
|
|
768
|
+
closeOnClickOutside: true,
|
|
769
|
+
closeOnEscape: true,
|
|
770
|
+
trigger: <Button>Interactive Popover</Button>,
|
|
771
|
+
children: 'Use the controls below to interact with the Popover and see different combinations.',
|
|
772
|
+
},
|
|
773
|
+
parameters: {
|
|
774
|
+
docs: {
|
|
775
|
+
description: {
|
|
776
|
+
story: 'Use the controls below to interact with the Popover and see different combinations.',
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
},
|
|
780
|
+
};
|