-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollapsiblePanel.stories.ts
More file actions
296 lines (279 loc) · 9.21 KB
/
Copy pathCollapsiblePanel.stories.ts
File metadata and controls
296 lines (279 loc) · 9.21 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import type { StoryFn } from '@storybook/vue3-vite';
import { ref } from 'vue';
import N8nCollapsiblePanel from './CollapsiblePanel.vue';
import N8nHeaderAction from '../N8nHeaderAction';
import N8nInput from '../N8nInput';
import N8nInputLabel from '../N8nInputLabel';
import N8nOption from '../N8nOption';
import N8nSelect from '../N8nSelect';
export default {
title: 'Core/CollapsiblePanel',
component: N8nCollapsiblePanel,
argTypes: {
modelValue: {
control: 'boolean',
},
title: {
control: 'text',
},
showActionsOnHover: {
control: 'boolean',
},
},
parameters: {
backgrounds: { default: 'white' },
},
decorators: [
() => ({
template: '<div style="width: 60%; margin: 0 auto; padding-top: 20px;"><story /></div>',
}),
],
};
const Template: StoryFn = (args, { argTypes }) => ({
setup: () => {
const isOpen = ref(args.modelValue);
return { args, isOpen };
},
props: Object.keys(argTypes),
components: {
N8nCollapsiblePanel,
N8nInput,
N8nInputLabel,
},
template: `
<N8nCollapsiblePanel v-bind="args" v-model="isOpen">
<div>
<N8nInputLabel label="Value" :bold="false" size="small" />
<N8nInput placeholder="Enter a value" size="small" />
</div>
</N8nCollapsiblePanel>
`,
});
const DefaultWithActions: StoryFn = (args, { argTypes }) => ({
setup: () => {
const isOpen = ref(args.modelValue);
return { args, isOpen };
},
props: Object.keys(argTypes),
components: {
N8nCollapsiblePanel,
N8nHeaderAction,
N8nInput,
N8nInputLabel,
},
template: `
<N8nCollapsiblePanel v-bind="args" v-model="isOpen">
<template #actions>
<N8nHeaderAction
icon="trash-2"
label="Delete"
danger
@click="() => console.log('delete')"
/>
<N8nHeaderAction
icon="grip-vertical"
label="Drag to reorder"
@click="() => console.log('drag')"
/>
</template>
<div>
<N8nInputLabel label="Value" :bold="false" size="small" />
<N8nInput placeholder="Enter a value" size="small" />
</div>
</N8nCollapsiblePanel>
`,
});
export const Default = DefaultWithActions.bind({});
Default.args = {
title: 'Query Parameter 1',
modelValue: true,
showActionsOnHover: true,
};
export const Collapsed = DefaultWithActions.bind({});
Collapsed.args = {
...Default.args,
modelValue: false,
};
export const WithoutActions = Template.bind({});
WithoutActions.args = {
title: 'Query Parameter 1',
modelValue: true,
};
const AlwaysVisibleTemplate: StoryFn = (args, { argTypes }) => ({
setup: () => {
const isOpen = ref(args.modelValue);
return { args, isOpen };
},
props: Object.keys(argTypes),
components: {
N8nCollapsiblePanel,
N8nHeaderAction,
N8nInput,
N8nInputLabel,
},
template: `
<N8nCollapsiblePanel v-bind="args" v-model="isOpen">
<template #actions>
<N8nHeaderAction
icon="plus"
label="Add Parameter"
@click="() => console.log('add')"
/>
</template>
<div>
<N8nInputLabel label="Value" :bold="false" size="small" />
<N8nInput placeholder="Enter a value" size="small" />
</div>
</N8nCollapsiblePanel>
`,
});
export const AlwaysVisibleActions = AlwaysVisibleTemplate.bind({});
AlwaysVisibleActions.args = {
title: 'Parameters',
modelValue: true,
showActionsOnHover: false,
};
const MultipleTemplate: StoryFn = (args, { argTypes }) => ({
setup: () => {
const isOpen1 = ref(true);
const isOpen2 = ref(false);
const isOpen3 = ref(false);
return { args, isOpen1, isOpen2, isOpen3 };
},
props: Object.keys(argTypes),
components: {
N8nCollapsiblePanel,
N8nHeaderAction,
N8nInput,
N8nInputLabel,
},
template: `
<div>
<N8nCollapsiblePanel title="Query Parameter 1" v-model="isOpen1">
<template #actions>
<N8nHeaderAction icon="trash-2" label="Delete" danger @click="() => {}" />
<N8nHeaderAction icon="grip-vertical" label="Drag to reorder" @click="() => {}" />
</template>
<div>
<N8nInputLabel label="Name" :bold="false" size="small" />
<N8nInput placeholder="eg. page" model-value="page" size="small" />
<N8nInputLabel label="Value" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="1" model-value="1" size="small" />
</div>
</N8nCollapsiblePanel>
<N8nCollapsiblePanel title="Query Parameter 2" v-model="isOpen2">
<template #actions>
<N8nHeaderAction icon="trash-2" label="Delete" danger @click="() => {}" />
<N8nHeaderAction icon="grip-vertical" label="Drag to reorder" @click="() => {}" />
</template>
<div>
<N8nInputLabel label="Name" :bold="false" size="small" />
<N8nInput placeholder="eg. limit" model-value="limit" size="small" />
<N8nInputLabel label="Value" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="10" model-value="10" size="small" />
</div>
</N8nCollapsiblePanel>
<N8nCollapsiblePanel title="Query Parameter 3" v-model="isOpen3">
<template #actions>
<N8nHeaderAction icon="trash-2" label="Delete" danger @click="() => {}" />
<N8nHeaderAction icon="grip-vertical" label="Drag to reorder" @click="() => {}" />
</template>
<div>
<N8nInputLabel label="Name" :bold="false" size="small" />
<N8nInput placeholder="eg. sort" model-value="sort" size="small" />
<N8nInputLabel label="Value" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="asc" model-value="asc" size="small" />
</div>
</N8nCollapsiblePanel>
</div>
`,
});
export const MultipleItems = MultipleTemplate.bind({});
const NestedTemplate: StoryFn = (args, { argTypes }) => ({
setup: () => {
const isOpenPagination = ref(true);
const isOpenParameters = ref(true);
const isOpenParam1 = ref(true);
const isOpenParam2 = ref(false);
return { args, isOpenPagination, isOpenParameters, isOpenParam1, isOpenParam2 };
},
props: Object.keys(argTypes),
components: {
N8nCollapsiblePanel,
N8nHeaderAction,
N8nInput,
N8nInputLabel,
N8nSelect,
N8nOption,
},
template: `
<N8nCollapsiblePanel
title="Pagination"
v-model="isOpenPagination"
data-item-key="pagination"
>
<div>
<N8nInputLabel label="Pagination Mode" :bold="false" size="small" />
<N8nSelect model-value="updateParameter" placeholder="Select pagination mode" size="small">
<N8nOption value="updateParameter" label="Update a Parameter in Each Request" />
<N8nOption value="responseUrl" label="URL From a Response" />
<N8nOption value="responseData" label="Using a Response Data Key" />
</N8nSelect>
<N8nCollapsiblePanel
title="Parameters"
v-model="isOpenParameters"
:show-actions-on-hover="false"
style="margin-top: var(--spacing--xs);"
>
<template #actions>
<N8nHeaderAction icon="plus" label="Add Parameter" @click="() => {}" />
</template>
<div style="padding-left: var(--spacing--xs);">
<N8nCollapsiblePanel title="Query Parameter 1" v-model="isOpenParam1">
<template #actions>
<N8nHeaderAction icon="trash-2" label="Delete" danger @click="() => {}" />
<N8nHeaderAction icon="grip-vertical" label="Drag to reorder" @click="() => {}" />
</template>
<div>
<N8nInputLabel label="Type" :bold="false" size="small" />
<N8nSelect model-value="query" placeholder="Select type" size="small">
<N8nOption value="query" label="Query" />
<N8nOption value="header" label="Header" />
</N8nSelect>
<N8nInputLabel label="Name" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="eg. page" model-value="page" size="small" />
<N8nInputLabel label="Value" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="1" model-value="{{ $pageCount }}" size="small" />
</div>
</N8nCollapsiblePanel>
<N8nCollapsiblePanel title="Query Parameter 2" v-model="isOpenParam2">
<template #actions>
<N8nHeaderAction icon="trash-2" label="Delete" danger @click="() => {}" />
<N8nHeaderAction icon="grip-vertical" label="Drag to reorder" @click="() => {}" />
</template>
<div>
<N8nInputLabel label="Type" :bold="false" size="small" />
<N8nSelect model-value="header" placeholder="Select type" size="small">
<N8nOption value="query" label="Query" />
<N8nOption value="header" label="Header" />
</N8nSelect>
<N8nInputLabel label="Name" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="eg. limit" model-value="limit" size="small" />
<N8nInputLabel label="Value" :bold="false" size="small" style="margin-top: var(--spacing--xs);" />
<N8nInput placeholder="10" model-value="10" size="small" />
</div>
</N8nCollapsiblePanel>
</div>
</N8nCollapsiblePanel>
<div style="margin-top: var(--spacing--xs);">
<N8nInputLabel label="Pagination Complete When" :bold="false" size="small" />
<N8nSelect model-value="responseEmpty" placeholder="Select condition" size="small">
<N8nOption value="responseEmpty" label="Response Is Empty" />
<N8nOption value="other" label="Other Condition" />
</N8nSelect>
</div>
</div>
</N8nCollapsiblePanel>
`,
});
export const NestedCollections = NestedTemplate.bind({});