107 lines
2.9 KiB
TypeScript
107 lines
2.9 KiB
TypeScript
import type { Meta, StoryObj } from '@storybook/react'
|
|
|
|
import {
|
|
Dialog,
|
|
DialogTrigger,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogClose,
|
|
} from '@/components/ui/dialog'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Input } from '@/components/ui/input'
|
|
import { Label } from '@/components/ui/label'
|
|
|
|
const meta = {
|
|
title: 'Overlay/Dialog',
|
|
component: Dialog,
|
|
tags: ['autodocs'],
|
|
parameters: { layout: 'centered' },
|
|
} satisfies Meta<typeof Dialog>
|
|
|
|
export default meta
|
|
type Story = StoryObj<typeof meta>
|
|
|
|
export const Default: Story = {
|
|
render: () => (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">Open Dialog</Button>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<DialogTitle>Dialog Title</DialogTitle>
|
|
<DialogDescription>
|
|
This is a dialog description. It provides context about the dialog content.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="py-4">
|
|
<p>Dialog body content goes here.</p>
|
|
</div>
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button variant="outline">Cancel</Button>
|
|
</DialogClose>
|
|
<Button>Confirm</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
),
|
|
}
|
|
|
|
export const WithForm: Story = {
|
|
render: () => (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button>Edit Profile</Button>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<DialogTitle>Edit profile</DialogTitle>
|
|
<DialogDescription>
|
|
Make changes to your profile here. Click save when you are done.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="grid gap-4 py-4">
|
|
<div className="grid gap-2">
|
|
<Label htmlFor="name">Name</Label>
|
|
<Input id="name" defaultValue="John Doe" />
|
|
</div>
|
|
<div className="grid gap-2">
|
|
<Label htmlFor="username">Username</Label>
|
|
<Input id="username" defaultValue="@johndoe" />
|
|
</div>
|
|
</div>
|
|
<DialogFooter>
|
|
<Button type="submit">Save changes</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
),
|
|
}
|
|
|
|
export const NoCloseButton: Story = {
|
|
render: () => (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<Button variant="outline">Open (no close button)</Button>
|
|
</DialogTrigger>
|
|
<DialogContent showCloseButton={false}>
|
|
<DialogHeader>
|
|
<DialogTitle>No Close Button</DialogTitle>
|
|
<DialogDescription>
|
|
This dialog has no close button in the corner.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<DialogFooter>
|
|
<DialogClose asChild>
|
|
<Button>Got it</Button>
|
|
</DialogClose>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
),
|
|
}
|