|
1
|
import type { Meta, StoryObj } from "@storybook/react" |
|
2
|
import * as React from "react" |
|
3
|
|
|
4
|
import { Select } from "./select" |
|
5
|
|
|
6
|
const meta: Meta<typeof Select> = { |
|
7
|
title: "Components/Select", |
|
8
|
component: Select, |
|
9
|
parameters: { |
|
10
|
layout: "centered", |
|
11
|
}, |
|
12
|
} |
|
13
|
|
|
14
|
export default meta |
|
15
|
|
|
16
|
type Story = StoryObj<typeof Select> |
|
17
|
|
|
18
|
const data = [ |
|
19
|
{ |
|
20
|
label: "Shirts", |
|
21
|
items: [ |
|
22
|
{ |
|
23
|
value: "dress-shirt-striped", |
|
24
|
label: "Striped Dress Shirt", |
|
25
|
}, |
|
26
|
{ |
|
27
|
value: "relaxed-button-down", |
|
28
|
label: "Relaxed Fit Button Down", |
|
29
|
}, |
|
30
|
{ |
|
31
|
value: "slim-button-down", |
|
32
|
label: "Slim Fit Button Down", |
|
33
|
}, |
|
34
|
{ |
|
35
|
value: "dress-shirt-solid", |
|
36
|
label: "Solid Dress Shirt", |
|
37
|
}, |
|
38
|
{ |
|
39
|
value: "dress-shirt-check", |
|
40
|
label: "Check Dress Shirt", |
|
41
|
}, |
|
42
|
], |
|
43
|
}, |
|
44
|
{ |
|
45
|
label: "T-Shirts", |
|
46
|
items: [ |
|
47
|
{ |
|
48
|
value: "v-neck", |
|
49
|
label: "V-Neck", |
|
50
|
}, |
|
51
|
{ |
|
52
|
value: "crew-neck", |
|
53
|
label: "Crew Neck", |
|
54
|
}, |
|
55
|
{ |
|
56
|
value: "henley", |
|
57
|
label: "Henley", |
|
58
|
}, |
|
59
|
{ |
|
60
|
value: "polo", |
|
61
|
label: "Polo", |
|
62
|
}, |
|
63
|
{ |
|
64
|
value: "mock-neck", |
|
65
|
label: "Mock Neck", |
|
66
|
}, |
|
67
|
{ |
|
68
|
value: "turtleneck", |
|
69
|
label: "Turtleneck", |
|
70
|
}, |
|
71
|
{ |
|
72
|
value: "scoop-neck", |
|
73
|
label: "Scoop Neck", |
|
74
|
}, |
|
75
|
], |
|
76
|
}, |
|
77
|
] |
|
78
|
|
|
79
|
export const Default: Story = { |
|
80
|
render: () => { |
|
81
|
return ( |
|
82
|
<div className="w-[250px]"> |
|
83
|
<Select open> |
|
84
|
<Select.Trigger> |
|
85
|
<Select.Value placeholder="Select" /> |
|
86
|
</Select.Trigger> |
|
87
|
<Select.Content> |
|
88
|
{data.map((group) => ( |
|
89
|
<Select.Group key={group.label}> |
|
90
|
<Select.Label>{group.label}</Select.Label> |
|
91
|
{group.items.map((item) => ( |
|
92
|
<Select.Item key={item.value} value={item.value}> |
|
93
|
{item.label} |
|
94
|
</Select.Item> |
|
95
|
))} |
|
96
|
</Select.Group> |
|
97
|
))} |
|
98
|
</Select.Content> |
|
99
|
</Select> |
|
100
|
</div> |
|
101
|
) |
|
102
|
}, |
|
103
|
} |
|
104
|
|
|
105
|
export const Disabled: Story = { |
|
106
|
render: () => { |
|
107
|
return ( |
|
108
|
<div className="w-[250px]"> |
|
109
|
<Select> |
|
110
|
<Select.Trigger disabled={true}> |
|
111
|
<Select.Value placeholder="Select" /> |
|
112
|
</Select.Trigger> |
|
113
|
<Select.Content> |
|
114
|
{data.map((group) => ( |
|
115
|
<Select.Group key={group.label}> |
|
116
|
<Select.Label>{group.label}</Select.Label> |
|
117
|
{group.items.map((item) => ( |
|
118
|
<Select.Item key={item.value} value={item.value}> |
|
119
|
{item.label} |
|
120
|
</Select.Item> |
|
121
|
))} |
|
122
|
</Select.Group> |
|
123
|
))} |
|
124
|
</Select.Content> |
|
125
|
</Select> |
|
126
|
</div> |
|
127
|
) |
|
128
|
}, |
|
129
|
} |
|
130
|
|
|
131
|
export const Small: Story = { |
|
132
|
render: () => { |
|
133
|
return ( |
|
134
|
<div className="w-[250px]"> |
|
135
|
<Select size="small"> |
|
136
|
<Select.Trigger> |
|
137
|
<Select.Value placeholder="Select" /> |
|
138
|
</Select.Trigger> |
|
139
|
<Select.Content> |
|
140
|
{data.map((group) => ( |
|
141
|
<Select.Group key={group.label}> |
|
142
|
<Select.Label>{group.label}</Select.Label> |
|
143
|
{group.items.map((item) => ( |
|
144
|
<Select.Item key={item.value} value={item.value}> |
|
145
|
{item.label} |
|
146
|
</Select.Item> |
|
147
|
))} |
|
148
|
</Select.Group> |
|
149
|
))} |
|
150
|
</Select.Content> |
|
151
|
</Select> |
|
152
|
</div> |
|
153
|
) |
|
154
|
}, |
|
155
|
} |
|
156
|
|
|
157
|
// const InModalDemo = () => { |
|
158
|
// const [open, setOpen] = React.useState(false) |
|
159
|
// const prompt = usePrompt() |
|
160
|
|
|
161
|
// const onClose = async () => { |
|
162
|
// const res = await prompt({ |
|
163
|
// title: "Are you sure?", |
|
164
|
// description: "You have unsaved changes. Are you sure you want to close?", |
|
165
|
// confirmText: "Yes", |
|
166
|
// cancelText: "Cancel", |
|
167
|
// }) |
|
168
|
|
|
169
|
// if (!res) { |
|
170
|
// return |
|
171
|
// } |
|
172
|
|
|
173
|
// setOpen(false) |
|
174
|
// } |
|
175
|
|
|
176
|
// return ( |
|
177
|
// <Drawer open={open} onOpenChange={setOpen}> |
|
178
|
// <Drawer.Trigger asChild> |
|
179
|
// <Button>Edit Variant</Button> |
|
180
|
// </Drawer.Trigger> |
|
181
|
// <Drawer.Content> |
|
182
|
// <Drawer.Header> |
|
183
|
// <Drawer.Title>Edit Variant</Drawer.Title> |
|
184
|
// </Drawer.Header> |
|
185
|
// <Drawer.Body> |
|
186
|
// <Select size="small"> |
|
187
|
// <Select.Trigger> |
|
188
|
// <Select.Value placeholder="Select" /> |
|
189
|
// </Select.Trigger> |
|
190
|
// <Select.Content> |
|
191
|
// {data.map((group) => ( |
|
192
|
// <Select.Group key={group.label}> |
|
193
|
// <Select.Label>{group.label}</Select.Label> |
|
194
|
// {group.items.map((item) => ( |
|
195
|
// <Select.Item key={item.value} value={item.value}> |
|
196
|
// {item.label} |
|
197
|
// </Select.Item> |
|
198
|
// ))} |
|
199
|
// </Select.Group> |
|
200
|
// ))} |
|
201
|
// </Select.Content> |
|
202
|
// </Select> |
|
203
|
// </Drawer.Body> |
|
204
|
// <Drawer.Footer> |
|
205
|
// <Button variant="secondary" onClick={onClose}> |
|
206
|
// Cancel |
|
207
|
// </Button> |
|
208
|
// <Button>Save</Button> |
|
209
|
// </Drawer.Footer> |
|
210
|
// </Drawer.Content> |
|
211
|
// </Drawer> |
|
212
|
// ) |
|
213
|
// } |
|
214
|
|
|
215
|
// export const InModal: Story = { |
|
216
|
// render: () => { |
|
217
|
// return <InModalDemo /> |
|
218
|
// }, |
|
219
|
// } |