npx shadcn@latest add https://sketchcn.chuwii.com/r/dialog.jsonimport { Button } from "@/components/ui/button";
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
export function NewSketchDialog() {
return (
<Dialog>
<DialogTrigger render={<Button>New sketch</Button>} />
<DialogContent>
<DialogHeader>
<DialogTitle>New sketch</DialogTitle>
<DialogDescription>Give it a name before you start.</DialogDescription>
</DialogHeader>
<div className="flex flex-col gap-3">
<Input placeholder="Sketch name" />
<Textarea placeholder="What is it for?" />
</div>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>Cancel</DialogClose>
<Button>Create</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
export function UnsavedChangesDialog() {
const [open, setOpen] = useState(false);
return (
<>
<Button variant="outline" onClick={() => setOpen(true)}>
Leave page
</Button>
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>
<DialogHeader>
<DialogTitle>Leave without saving?</DialogTitle>
<DialogDescription>Your sketch has unsaved changes.</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="outline" onClick={() => setOpen(false)}>
Keep editing
</Button>
<Button variant="destructive" onClick={() => setOpen(false)}>
Discard
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}