Workspace created
dialog-demo.tsx
dialog.tsx
alert-dialog.tsx
1
"use client"
2
3
import * as React from "react"
4
import { Globe, Upload, CheckCircle2, FileUp, X } from "lucide-react"
5
6
import {
7
Dialog,
8
DialogContent,
9
DialogHeader,
10
DialogTitle,
11
DialogTrigger,
12
} from "@/components/ui/dialog"
13
14
import {
15
AlertDialog,
16
AlertDialogAction,
17
AlertDialogCancel,
18
AlertDialogContent,
19
AlertDialogDescription,
20
AlertDialogFooter,
21
AlertDialogHeader,
22
AlertDialogTitle,
23
AlertDialogTrigger,
24
} from "@/components/ui/alert-dialog"
25
26
export default function DialogDemo() {
27
const [dialogType, setDialogType] = React.useState<"multi" | "alert">("multi")
28
29
// Multi-step state
30
const [open, setOpen] = React.useState(false)
31
const [step, setStep] = React.useState(1)
32
const [showToast, setShowToast] = React.useState(false)
33
34
const handleNext = () => setStep((s) => s + 1)
35
const handleBack = () => setStep((s) => s - 1)
36
37
const handleCreate = () => {
38
setOpen(false)
39
setTimeout(() => {
40
setShowToast(true)
41
setTimeout(() => setShowToast(false), 3000)
42
}, 300)
43
}
44
45
React.useEffect(() => {
46
if (!open) {
47
setTimeout(() => setStep(1), 300)
48
}
49
}, [open])
50
51
return (
52
<div className="flex w-full min-h-[500px] border border-black/10 dark:border-white/10 rounded-xl overflow-hidden bg-white dark:bg-[#111111]">
53
{/* Left Preview Area */}
54
<div className="flex-1 flex items-center justify-center relative bg-zinc-50 dark:bg-[#111111]">
55
{/* Fake Toast */}
56
<div
57
className={"absolute top-4 transition-all duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] flex items-center gap-2 rounded-full border border-black/10 dark:border-white/10 bg-white dark:bg-[#161616] px-4 py-2 shadow-sm z-50 " + (showToast ? "translate-y-0 opacity-100" : "-translate-y-8 opacity-0")}
58
>
59
<div className="rounded-full bg-blue-500 flex items-center justify-center h-4 w-4">
60
<CheckCircle2 className="h-3 w-3 text-white" />
61
</div>
62
<span className="text-sm font-medium dark:text-zinc-50">Workspace created</span>
63
</div>
64
65
{dialogType === "multi" ? (
66
<Dialog open={open} onOpenChange={setOpen}>
67
<DialogTrigger className="inline-flex h-9 items-center justify-center rounded-full border border-black/10 bg-transparent px-4 py-2 text-sm font-medium transition-colors hover:bg-black/5 dark:border-white/10 dark:text-white dark:hover:bg-white/5">
68
Create workspace
69
</DialogTrigger>
70
<DialogContent
71
onOpenAutoFocus={(e) => e.preventDefault()}
72
className="sm:max-w-[425px]"
73
>
74
{step === 1 && (
75
<div className="animate-in fade-in-0 slide-in-from-left-2 duration-300">
76
<DialogHeader className="mb-6">
77
<DialogTitle>Create your workspace</DialogTitle>
78
</DialogHeader>
79
<div className="grid gap-4 py-2">
80
<div className="grid gap-2">
81
<label className="text-[13px] font-medium text-zinc-950 dark:text-zinc-50">
82
Workspace name
83
</label>
84
<input
85
defaultValue="Acme Design"
86
onFocus={(e) => {
87
const len = e.currentTarget.value.length;
88
e.currentTarget.setSelectionRange(len, len);
89
}}
90
className="flex h-9 w-full rounded-md border border-black/10 bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-zinc-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-zinc-950 disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:placeholder:text-zinc-400 dark:focus-visible:ring-white/20 dark:text-white"
91
/>
92
</div>
93
<div className="grid gap-2">
94
<label className="text-[13px] font-medium text-zinc-950 dark:text-zinc-50">
95
Workspace URL
96
</label>
97
<div className="relative flex items-center">
98
<Globe className="absolute left-3 h-4 w-4 text-zinc-500" />
99
<input
100
defaultValue="https://www.addsunflower.tech/acme"
101
className="flex h-9 w-full rounded-md border border-black/10 bg-transparent pl-9 pr-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-zinc-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-zinc-950 disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:placeholder:text-zinc-400 dark:focus-visible:ring-white/20 dark:text-white"
102
/>
103
</div>
104
</div>
105
</div>
106
<div className="mt-6 flex justify-end gap-2">
107
<button
108
onClick={() => setOpen(false)}
109
className="inline-flex h-9 items-center justify-center rounded-lg bg-black/5 dark:bg-white/10 px-4 py-2 text-sm font-medium transition-colors hover:bg-black/10 dark:hover:bg-white/20 dark:text-white"
110
>
111
Cancel
112
</button>
113
<button
114
onClick={handleNext}
115
className="inline-flex h-9 items-center justify-center rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-zinc-50 transition-colors hover:bg-zinc-900/90 dark:bg-zinc-50 dark:text-zinc-900 dark:hover:bg-zinc-50/90 shadow-sm"
116
>
117
Continue
118
</button>
119
</div>
120
</div>
121
)}
122
123
{step === 2 && (
124
<div className="animate-in fade-in-0 slide-in-from-right-2 duration-300">
125
<DialogHeader className="mb-6">
126
<DialogTitle>Add sources</DialogTitle>
127
</DialogHeader>
128
<div className="py-2">
129
<div className="flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-black/20 dark:border-white/20 p-8 text-center cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 transition-colors group">
130
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-black/5 dark:bg-white/5 transition-colors group-hover:bg-black/10 dark:group-hover:bg-white/10">
131
<FileUp className="h-5 w-5 text-zinc-500 dark:text-zinc-400" />
132
</div>
133
<div className="flex flex-col gap-1">
134
<span className="text-sm font-medium dark:text-zinc-50">Upload sources</span>
135
<span className="text-[13px] text-zinc-500 dark:text-zinc-400">Drop files or click to browse</span>
136
</div>
137
</div>
138
</div>
139
<div className="mt-6 flex justify-end gap-2">
140
<button
141
onClick={handleBack}
142
className="inline-flex h-9 items-center justify-center rounded-lg bg-black/5 dark:bg-white/10 px-4 py-2 text-sm font-medium transition-colors hover:bg-black/10 dark:hover:bg-white/20 dark:text-white"
143
>
144
Back
145
</button>
146
<button
147
onClick={handleNext}
148
className="inline-flex h-9 items-center justify-center rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-zinc-50 transition-colors hover:bg-zinc-900/90 dark:bg-zinc-50 dark:text-zinc-900 dark:hover:bg-zinc-50/90 shadow-sm"
149
>
150
Continue
151
</button>
152
</div>
153
</div>
154
)}
155
156
{step === 3 && (
157
<div className="animate-in fade-in-0 slide-in-from-right-2 duration-300">
158
<DialogHeader className="mb-6">
159
<DialogTitle>Review</DialogTitle>
160
</DialogHeader>
161
<div className="py-2">
162
<div className="rounded-xl border border-black/10 dark:border-white/10 divide-y divide-black/10 dark:divide-white/10 overflow-hidden text-[13px]">
163
<div className="flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02]">
164
<span className="text-zinc-500 dark:text-zinc-400 font-medium">Name</span>
165
<span className="font-medium dark:text-zinc-100">Acme Design</span>
166
</div>
167
<div className="flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02]">
168
<span className="text-zinc-500 dark:text-zinc-400 font-medium">URL</span>
169
<span className="font-medium dark:text-zinc-100">https://www.addsunflower.tech/acme</span>
170
</div>
171
<div className="flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02]">
172
<span className="text-zinc-500 dark:text-zinc-400 font-medium">Sources</span>
173
<span className="font-medium dark:text-zinc-100">None yet</span>
174
</div>
175
<div className="flex items-center justify-between p-3 bg-black/[0.02] dark:bg-white/[0.02]">
176
<span className="text-zinc-500 dark:text-zinc-400 font-medium">Members</span>
177
<span className="font-medium dark:text-zinc-100">Just you</span>
178
</div>
179
</div>
180
</div>
181
<div className="mt-6 flex justify-end gap-2">
182
<button
183
onClick={handleBack}
184
className="inline-flex h-9 items-center justify-center rounded-lg bg-black/5 dark:bg-white/10 px-4 py-2 text-sm font-medium transition-colors hover:bg-black/10 dark:hover:bg-white/20 dark:text-white"
185
>
186
Back
187
</button>
188
<button
189
onClick={handleCreate}
190
className="inline-flex h-9 items-center justify-center rounded-lg bg-zinc-900 px-4 py-2 text-sm font-medium text-zinc-50 transition-colors hover:bg-zinc-900/90 dark:bg-zinc-50 dark:text-zinc-900 dark:hover:bg-zinc-50/90 shadow-sm"
191
>
192
Create workspace
193
</button>
194
</div>
195
</div>
196
)}
197
</DialogContent>
198
</Dialog>
199
) : (
200
<AlertDialog>
201
<AlertDialogTrigger className="inline-flex h-9 items-center justify-center rounded-full border border-black/10 bg-transparent px-4 py-2 text-sm font-medium transition-colors hover:bg-black/5 dark:border-white/10 dark:text-white dark:hover:bg-white/5">
202
Delete workspace
203
</AlertDialogTrigger>
204
<AlertDialogContent className="sm:max-w-[425px]">
205
<AlertDialogCancel className="absolute right-4 top-4 rounded-full bg-black/5 dark:bg-white/5 p-1.5 opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-500 dark:ring-offset-zinc-950 dark:focus:ring-zinc-300 dark:data-[state=open]:bg-zinc-800 dark:data-[state=open]:text-zinc-400 border-none h-auto w-auto hover:bg-black/10 dark:hover:bg-white/10">
206
<X className="h-4 w-4" />
207
<span className="sr-only">Close</span>
208
</AlertDialogCancel>
209
210
<AlertDialogHeader>
211
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
212
<AlertDialogDescription>
213
This cannot be undone.
214
</AlertDialogDescription>
215
</AlertDialogHeader>
216
<AlertDialogFooter>
217
<AlertDialogCancel className="border-none bg-black/5 hover:bg-black/10 dark:bg-white/10 dark:hover:bg-white/20 dark:text-white">Cancel</AlertDialogCancel>
218
<AlertDialogAction className="bg-red-500 hover:bg-red-600 dark:bg-red-500 dark:text-white dark:hover:bg-red-600">Delete</AlertDialogAction>
219
</AlertDialogFooter>
220
</AlertDialogContent>
221
</AlertDialog>
222
)}
223
</div>
224
225
{/* Right Sidebar Control Panel (matching screenshot) */}
226
<div className="w-[340px] border-l border-black/10 dark:border-white/10 bg-white dark:bg-[#161616] p-6 flex flex-col gap-8">
227
<div>
228
<h3 className="text-sm font-medium dark:text-zinc-50 mb-4">Preview</h3>
229
<div className="flex flex-col gap-3">
230
<label className="flex items-center justify-between cursor-pointer group">
231
<span className="text-sm text-zinc-600 dark:text-zinc-400 group-hover:text-zinc-900 dark:group-hover:text-zinc-300 transition-colors">Multi step</span>
232
<input
233
type="radio"
234
name="dialog-type"
235
className="sr-only"
236
checked={dialogType === "multi"}
237
onChange={() => setDialogType("multi")}
238
/>
239
<div className={"h-4 w-4 rounded-[4px] border flex items-center justify-center transition-colors " + (dialogType === "multi" ? "bg-zinc-900 border-zinc-900 dark:bg-zinc-50 dark:border-zinc-50" : "border-black/20 dark:border-white/20 group-hover:border-black/40 dark:group-hover:border-white/40")}>
240
{dialogType === "multi" && <CheckCircle2 className="h-3 w-3 text-white dark:text-zinc-900" />}
241
</div>
242
</label>
243
<label className="flex items-center justify-between cursor-pointer group">
244
<span className="text-sm text-zinc-600 dark:text-zinc-400 group-hover:text-zinc-900 dark:group-hover:text-zinc-300 transition-colors">Alert dialog</span>
245
<input
246
type="radio"
247
name="dialog-type"
248
className="sr-only"
249
checked={dialogType === "alert"}
250
onChange={() => setDialogType("alert")}
251
/>
252
<div className={"h-4 w-4 rounded-[4px] border flex items-center justify-center transition-colors " + (dialogType === "alert" ? "bg-zinc-900 border-zinc-900 dark:bg-zinc-50 dark:border-zinc-50" : "border-black/20 dark:border-white/20 group-hover:border-black/40 dark:group-hover:border-white/40")}>
253
{dialogType === "alert" && <CheckCircle2 className="h-3 w-3 text-white dark:text-zinc-900" />}
254
</div>
255
</label>
256
</div>
257
</div>
258
259
<div className="flex-1">
260
<table className="w-full text-left text-sm text-zinc-500 dark:text-zinc-400">
261
<thead>
262
<tr className="border-b border-black/10 dark:border-white/10">
263
<th className="pb-2 font-medium">Prop</th>
264
<th className="pb-2 font-medium">Type</th>
265
<th className="pb-2 font-medium">Default</th>
266
</tr>
267
</thead>
268
<tbody className="divide-y divide-black/10 dark:divide-white/10">
269
<tr>
270
<td className="py-3 font-mono text-[12px] text-zinc-800 dark:text-zinc-300">children</td>
271
<td className="py-3">ReactNode</td>
272
<td className="py-3 text-[13px]">Component<br/>content</td>
273
</tr>
274
<tr>
275
<td className="py-3 font-mono text-[12px] text-zinc-800 dark:text-zinc-300">className</td>
276
<td className="py-3">string</td>
277
<td className="py-3 text-[13px]">Optional<br/>CSS<br/>classes</td>
278
</tr>
279
<tr>
280
<td className="py-3 font-mono text-[12px] text-zinc-800 dark:text-zinc-300">open</td>
281
<td className="py-3">boolean</td>
282
<td className="py-3 text-[13px]">Controlled<br/>visibility</td>
283
</tr>
284
<tr>
285
<td className="py-3 font-mono text-[12px] text-zinc-800 dark:text-zinc-300">defaultOpen</td>
286
<td className="py-3">boolean</td>
287
<td className="py-3 font-mono text-[12px]">false</td>
288
</tr>
289
</tbody>
290
</table>
291
</div>
292
</div>
293
</div>
294
)
295
}
296