diff --git a/src/components/Dialog/Dialog.stories.tsx b/src/components/Dialog/Dialog.stories.tsx new file mode 100644 index 0000000..bfed32a --- /dev/null +++ b/src/components/Dialog/Dialog.stories.tsx @@ -0,0 +1,51 @@ +import { Meta } from "@storybook/react"; +import React from "react"; +import { + Dialog, + DialogTrigger, + DialogContent, + DialogHeader, + DialogTitle, + DialogFooter, + DialogClose, + DialogDescription +} from "./index"; +import { Button } from "../Button"; +import { StoryObj } from "@storybook/react"; + +const meta = { + title: "Elements/Dialog", + component: Dialog, + argTypes: {}, + parameters: { + layout: "centered" + }, + + tags: ["autodocs"] +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const DefaultVariant: Story = { + name: "Default", + render: () => ( + + + + + + + Dialog Title + + Dialog Description + + + + + + + + ) +}; diff --git a/src/components/Dialog/Dialog.tsx b/src/components/Dialog/Dialog.tsx new file mode 100644 index 0000000..d3b8860 --- /dev/null +++ b/src/components/Dialog/Dialog.tsx @@ -0,0 +1,118 @@ +"use client"; + +import * as React from "react"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { cn } from "../../utilities"; + +const Dialog = DialogPrimitive.Root; + +const DialogTrigger = DialogPrimitive.Trigger; + +const DialogPortal = DialogPrimitive.Portal; + +const DialogClose = DialogPrimitive.Close; + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + +)); +DialogContent.displayName = DialogPrimitive.Content.displayName; + +const DialogHeader = ({ className, children, ...props }: React.HTMLAttributes) => ( +
+ {children} + + + + + + Close + +
+); +DialogHeader.displayName = "DialogHeader"; + +const DialogFooter = ({ className, ...props }: React.HTMLAttributes) => ( +
+); +DialogFooter.displayName = "DialogFooter"; + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; + +export { + Dialog, + DialogTrigger, + DialogContent, + DialogOverlay, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, + DialogClose +}; diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx new file mode 100644 index 0000000..24cc75a --- /dev/null +++ b/src/components/Dialog/index.tsx @@ -0,0 +1 @@ +export * from "./Dialog"; diff --git a/src/components/index.ts b/src/components/index.ts index 455ee43..fd70e9c 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -15,3 +15,4 @@ export * from "./Collapsible"; export * from "./Tooltip"; export * from "./Checkbox"; export * from "./Toast"; +export * from "./Dialog";