mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 14:08:47 +00:00
* feat: add base and radix docs * feat: transform code for display * fix * fix * fix * fix * fix * chore: remove claude files * fix * fix * fix * chore: run format:write * fix * feat: add more examples * fix * feat: add aspect-ratio * feat: add avatar * feat: add badge * feat: add breadcrumb * fix * feat: add button * fix * fix * fix * feat: add calendar and card * feat: add carousel * fix: chart * feat: add checkbox * feat: add collapsible * feat: add combobox * feat: add command * feat: add context menu * feat: add data-table dialog and drawer * feat: dropdown-menu * feat: add date-picker * feat: add empty * feat: add field and hover-card * fix: input * feat: add input * feat: add input-group * feat: add input-otp * feat: add item * feat: add kbd and label * feat: add menubar * feat: add native-select * feat: add more components * feat: more components * feat: more components * feat: add skeleton, slider and sonner * feat: add spinner and switch * feat: add more components * fix: tabs * fix: tabs * feat: add docs for sidebar * fix * fix * fi * docs: update * fix: create page * fix * fix * chore: add changelog * fix
91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { Button } from "@/examples/base/ui/button"
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
} from "@/examples/base/ui/dialog"
|
|
import {
|
|
Drawer,
|
|
DrawerClose,
|
|
DrawerContent,
|
|
DrawerDescription,
|
|
DrawerFooter,
|
|
DrawerHeader,
|
|
DrawerTitle,
|
|
DrawerTrigger,
|
|
} from "@/examples/base/ui/drawer"
|
|
import { Input } from "@/examples/base/ui/input"
|
|
import { Label } from "@/examples/base/ui/label"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { useMediaQuery } from "@/hooks/use-media-query"
|
|
|
|
export function DrawerDialogDemo() {
|
|
const [open, setOpen] = React.useState(false)
|
|
const isDesktop = useMediaQuery("(min-width: 768px)")
|
|
|
|
if (isDesktop) {
|
|
return (
|
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
<DialogTrigger render={<Button variant="outline" />}>
|
|
Edit Profile
|
|
</DialogTrigger>
|
|
<DialogContent className="sm:max-w-[425px]">
|
|
<DialogHeader>
|
|
<DialogTitle>Edit profile</DialogTitle>
|
|
<DialogDescription>
|
|
Make changes to your profile here. Click save when you're
|
|
done.
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<ProfileForm />
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Drawer open={open} onOpenChange={setOpen}>
|
|
<DrawerTrigger asChild>
|
|
<Button variant="outline">Edit Profile</Button>
|
|
</DrawerTrigger>
|
|
<DrawerContent>
|
|
<DrawerHeader className="text-left">
|
|
<DrawerTitle>Edit profile</DrawerTitle>
|
|
<DrawerDescription>
|
|
Make changes to your profile here. Click save when you're done.
|
|
</DrawerDescription>
|
|
</DrawerHeader>
|
|
<ProfileForm className="px-4" />
|
|
<DrawerFooter className="pt-2">
|
|
<DrawerClose asChild>
|
|
<Button variant="outline">Cancel</Button>
|
|
</DrawerClose>
|
|
</DrawerFooter>
|
|
</DrawerContent>
|
|
</Drawer>
|
|
)
|
|
}
|
|
|
|
function ProfileForm({ className }: React.ComponentProps<"form">) {
|
|
return (
|
|
<form className={cn("grid items-start gap-6", className)}>
|
|
<div className="grid gap-3">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input type="email" id="email" defaultValue="shadcn@example.com" />
|
|
</div>
|
|
<div className="grid gap-3">
|
|
<Label htmlFor="username">Username</Label>
|
|
<Input id="username" defaultValue="@shadcn" />
|
|
</div>
|
|
<Button type="submit">Save changes</Button>
|
|
</form>
|
|
)
|
|
}
|