-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandBar.stories.ts
More file actions
242 lines (227 loc) · 6.19 KB
/
Copy pathCommandBar.stories.ts
File metadata and controls
242 lines (227 loc) · 6.19 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
import type { StoryFn } from '@storybook/vue3-vite';
import { action } from 'storybook/actions';
import N8nCommandBar from './CommandBar.vue';
const sampleItems = [
// Ungrouped items (appear first)
{
id: 'recent-workflow-1',
title: 'Recent: Customer Sync',
icon: { html: '📋' },
handler: () => console.log('Opening recent workflow'),
},
{
id: 'recent-workflow-2',
title: 'Recent: Email Campaign',
icon: { html: '✉️' },
handler: () => console.log('Opening recent workflow'),
},
// Actions section
{
id: 'create-workflow',
title: 'Create new workflow',
icon: { html: '⚡' },
section: 'Actions',
handler: () => console.log('Creating new workflow'),
},
{
id: 'import-workflow',
title: 'Import workflow',
icon: { html: '📥' },
section: 'Actions',
keywords: ['upload', 'file'],
handler: () => console.log('Importing workflow'),
},
{
id: 'duplicate-workflow',
title: 'Duplicate current workflow',
icon: { html: '📋' },
section: 'Actions',
handler: () => console.log('Duplicating workflow'),
},
// Navigation section
{
id: 'workflows',
title: 'All Workflows',
icon: { html: '📁' },
section: 'Navigation',
handler: () => console.log('Opening workflows'),
},
{
id: 'executions',
title: 'Executions',
icon: { html: '🏃' },
section: 'Navigation',
handler: () => console.log('Opening executions'),
},
{
id: 'credentials',
title: 'Credentials',
icon: { html: '🔑' },
section: 'Navigation',
handler: () => console.log('Opening credentials'),
},
// Tools section
{
id: 'search-nodes',
title: 'Search nodes',
icon: { html: '🔍' },
keywords: ['node', 'add', 'integration'],
section: 'Tools',
},
{
id: 'test-webhook',
title: 'Test webhook',
icon: { html: '🌐' },
section: 'Tools',
handler: () => console.log('Testing webhook'),
},
// Settings section
{
id: 'settings',
title: 'Settings',
icon: {
html: '<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 4.754a3.246 3.246 0 1 0 0 6.492 3.246 3.246 0 0 0 0-6.492zM5.754 8a2.246 2.246 0 1 1 4.492 0 2.246 2.246 0 0 1-4.492 0z"/><path d="M9.796 1.343c-.527-1.79-3.065-1.79-3.592 0l-.094.319a.873.873 0 0 1-1.255.52l-.292-.16c-1.64-.892-3.433.902-2.54 2.541l.159.292a.873.873 0 0 1-.52 1.255l-.319.094c-1.79.527-1.79 3.065 0 3.592l.319.094a.873.873 0 0 1 .52 1.255l-.16.292c-.892 1.64.901 3.434 2.541 2.54l.292-.159a.873.873 0 0 1 1.255.52l.094.319c.527 1.79 3.065 1.79 3.592 0l.094-.319a.873.873 0 0 1 1.255-.52l.292.16c1.64.893 3.434-.902 2.54-2.541l-.159-.292a.873.873 0 0 1 .52-1.255l.319-.094c1.79-.527 1.79-3.065 0-3.592l-.319-.094a.873.873 0 0 1-.52-1.255l.16-.292c.893-1.64-.902-3.433-2.541-2.54l-.292.159a.873.873 0 0 1-1.255-.52l-.094-.319z"/></svg>',
},
section: 'Settings',
handler: () => console.log('Opening settings'),
},
{
id: 'help',
title: 'Help & Documentation',
icon: { html: '❓' },
section: 'Settings',
handler: () => console.log('Opening help'),
},
];
export default {
title: 'Core/CommandBar',
component: N8nCommandBar,
argTypes: {
placeholder: {
control: 'text',
},
context: {
control: 'text',
},
items: {
control: 'object',
},
isLoading: {
control: 'boolean',
},
},
parameters: {
backgrounds: { default: '--color--background--light-2' },
},
};
const Template: StoryFn = (args, { argTypes }) => ({
setup: () => ({ args }),
props: Object.keys(argTypes),
components: {
N8nCommandBar,
},
template:
'<n8n-command-bar v-bind="args" @input-change="onInputChange" @navigate-to="onNavigateTo" />',
methods: {
onInputChange: action('input-change'),
onNavigateTo: action('navigate-to'),
},
});
export const Default = Template.bind({});
Default.args = {
placeholder: 'Type a command...',
items: [],
};
export const WithItems = Template.bind({});
WithItems.args = {
placeholder: 'Search commands...',
items: sampleItems,
};
export const WithContext = Template.bind({});
WithContext.args = {
placeholder: 'Search for anything...',
context: 'Workflow Editor',
items: sampleItems,
};
export const CustomPlaceholder = Template.bind({});
CustomPlaceholder.args = {
placeholder: 'What would you like to do?',
items: sampleItems,
};
export const KeyboardShortcut: StoryFn = () => ({
components: {
N8nCommandBar,
},
data: () => ({
items: sampleItems,
}),
template: `
<div>
<p style="margin-bottom: 20px; color: var(--color--text);">
Press <kbd style="background: var(--color--background); padding: 2px 6px; border-radius: 3px;">⌘ + K</kbd>
or <kbd style="background: var(--color--background); padding: 2px 6px; border-radius: 3px;">Ctrl + K</kbd>
to open the command bar. Use arrow keys to navigate and Enter to select.
</p>
<n8n-command-bar
placeholder="Try pressing Cmd/Ctrl + K!"
:items="items"
@input-change="onInputChange"
@navigate-to="onNavigateTo"
/>
</div>
`,
methods: {
onInputChange: action('input-change'),
onNavigateTo: action('navigate-to'),
},
});
export const SectionGrouping: StoryFn = () => ({
components: {
N8nCommandBar,
},
data: () => ({
items: sampleItems,
}),
template: `
<div>
<p style="margin-bottom: 20px; color: var(--color--text);">
This example shows how items are grouped by sections:
<br/>• <strong>Recent items</strong> (no section) appear first
<br/>• Then items are grouped by <strong>Actions</strong>, <strong>Navigation</strong>, <strong>Tools</strong>, and <strong>Settings</strong> sections
</p>
<n8n-command-bar
placeholder="Search commands... (sections will be grouped)"
:items="items"
@input-change="onInputChange"
@navigate-to="onNavigateTo"
/>
</div>
`,
methods: {
onInputChange: action('input-change'),
onNavigateTo: action('navigate-to'),
},
});
export const Loading: StoryFn = () => ({
components: {
N8nCommandBar,
},
template: `
<div>
<p style="margin-bottom: 20px; color: var(--color--text);">
This example shows the loading state with skeleton loaders.
</p>
<n8n-command-bar
placeholder="Loading commands..."
:items="[]"
:is-loading="true"
@input-change="onInputChange"
@navigate-to="onNavigateTo"
/>
</div>
`,
methods: {
onInputChange: action('input-change'),
onNavigateTo: action('navigate-to'),
},
});