-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertDialog.stories.ts
More file actions
167 lines (157 loc) · 3.75 KB
/
Copy pathAlertDialog.stories.ts
File metadata and controls
167 lines (157 loc) · 3.75 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
import type { Meta, StoryObj } from '@storybook/vue3-vite';
import { ref } from 'vue';
import { N8nAlertDialog } from '@n8n/design-system/components/N8nAlertDialog';
import N8nButton from '@n8n/design-system/components/N8nButton/Button.vue';
const meta = {
title: 'Core/AlertDialog',
component: N8nAlertDialog,
parameters: {
docs: {
source: { type: 'dynamic' },
},
},
argTypes: {
size: {
control: { type: 'select' },
options: ['small', 'medium'],
},
actionVariant: {
control: { type: 'select' },
options: ['solid', 'destructive'],
},
},
} satisfies Meta<typeof N8nAlertDialog>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Basic = {
render: () => ({
components: {
N8nAlertDialog,
N8nButton,
},
setup() {
const isOpen = ref(false);
const handleConfirm = () => {
console.log('Confirmed!');
isOpen.value = false;
};
return { isOpen, handleConfirm };
},
template: `
<div style="display: flex; justify-content: center; padding: 40px;">
<N8nButton label="Save" @click="isOpen = true" />
<N8nAlertDialog
v-model:open="isOpen"
title="Save changes?"
description="Your changes will be saved to the server."
action-label="Save"
@action="handleConfirm"
/>
</div>
`,
}),
args: {
title: 'Save changes?',
},
} satisfies Story;
export const Destructive = {
render: () => ({
components: {
N8nAlertDialog,
N8nButton,
},
setup() {
const isOpen = ref(false);
const handleDelete = () => {
console.log('Deleted!');
isOpen.value = false;
};
return { isOpen, handleDelete };
},
template: `
<div style="display: flex; justify-content: center; padding: 40px;">
<N8nButton label="Delete" variant="danger" @click="isOpen = true" />
<N8nAlertDialog
v-model:open="isOpen"
title="Delete item?"
description="This action cannot be undone. This will permanently delete the item."
action-label="Delete"
action-variant="destructive"
@action="handleDelete"
/>
</div>
`,
}),
args: {
title: 'Delete item?',
},
} satisfies Story;
export const WithLoading = {
render: () => ({
components: {
N8nAlertDialog,
N8nButton,
},
setup() {
const loading = ref(false);
const isOpen = ref(false);
const handleAction = async () => {
loading.value = true;
await new Promise((resolve) => setTimeout(resolve, 2000));
loading.value = false;
isOpen.value = false;
};
return { loading, isOpen, handleAction };
},
template: `
<div style="display: flex; justify-content: center; padding: 40px;">
<N8nButton label="Start Process" @click="isOpen = true" />
<N8nAlertDialog
v-model:open="isOpen"
title="Process data?"
description="This operation may take a few seconds."
action-label="Process"
:loading="loading"
@action="handleAction"
/>
</div>
`,
}),
args: {
title: 'Process data?',
},
} satisfies Story;
export const Sizes = {
render: () => ({
components: {
N8nAlertDialog,
N8nButton,
},
setup() {
const isSmallOpen = ref(false);
const isMediumOpen = ref(false);
return { isSmallOpen, isMediumOpen };
},
template: `
<div style="display: flex; gap: 16px; justify-content: center; padding: 40px;">
<N8nButton label="Small" variant="outline" @click="isSmallOpen = true" />
<N8nAlertDialog
v-model:open="isSmallOpen"
title="Small Dialog"
description="This is a small alert dialog."
size="small"
/>
<N8nButton label="Medium" variant="outline" @click="isMediumOpen = true" />
<N8nAlertDialog
v-model:open="isMediumOpen"
title="Medium Dialog"
description="This is a medium alert dialog with more space for content."
size="medium"
/>
</div>
`,
}),
args: {
title: 'Small Dialog',
},
} satisfies Story;