diff --git a/src/components/ui/Popover.stories.tsx b/src/components/ui/Popover.stories.tsx new file mode 100644 index 0000000..763531d --- /dev/null +++ b/src/components/ui/Popover.stories.tsx @@ -0,0 +1,70 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { Popover, PopoverTrigger, PopoverContent, PopoverTitle, PopoverDescription } from "./popover"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; + +const meta = { + title: "UI/Popover", + component: Popover, + parameters: { layout: "centered" }, + tags: ["autodocs"], +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: () => ( + + + + + +
+
+ Dimensions + + Set the dimensions for the layer. + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ ), +}; diff --git a/src/components/ui/ScrollArea.stories.tsx b/src/components/ui/ScrollArea.stories.tsx new file mode 100644 index 0000000..d053e11 --- /dev/null +++ b/src/components/ui/ScrollArea.stories.tsx @@ -0,0 +1,70 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import * as React from "react"; +import { ScrollArea, ScrollBar } from "./scroll-area"; +import { Separator } from "./separator"; + +const meta = { + title: "UI/ScrollArea", + component: ScrollArea, + parameters: { + layout: "centered", + }, + tags: ["autodocs"], +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +const tags = Array.from({ length: 50 }).map( + (_, i, a) => `v1.2.0-beta.${a.length - i}` +); + +export const Default: Story = { + render: () => ( + +
+

Tags

+ {tags.map((tag) => ( + +
+ {tag} +
+ +
+ ))} +
+
+ ), +}; + +export const Horizontal: Story = { + render: () => ( + +
+ {Array.from({ length: 20 }).map((_, i) => ( +
+ Item {i + 1} +
+ ))} +
+ +
+ ), +}; + +export const Both: Story = { + render: () => ( + +
+
+ Large content area (600x500px) +
+
+ + +
+ ), +}; diff --git a/src/components/ui/Skeleton.stories.tsx b/src/components/ui/Skeleton.stories.tsx new file mode 100644 index 0000000..0d1ab50 --- /dev/null +++ b/src/components/ui/Skeleton.stories.tsx @@ -0,0 +1,59 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { Skeleton } from "./skeleton"; + +const meta = { + title: "UI/Skeleton", + component: Skeleton, + parameters: { + layout: "centered", + }, + tags: ["autodocs"], +} satisfies Meta; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: () => , +}; + +export const Card: Story = { + render: () => ( +
+ +
+ + +
+
+ ), +}; + +export const List: Story = { + render: () => ( +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ ), +}; diff --git a/src/components/ui/index.ts b/src/components/ui/index.ts index 68be726..db3d2a8 100644 --- a/src/components/ui/index.ts +++ b/src/components/ui/index.ts @@ -122,6 +122,24 @@ export { DropdownMenuTrigger, } from "./dropdown-menu"; +// Popover component +export { + Popover, + PopoverTrigger, + PopoverContent, + PopoverPortal, + PopoverDescription, + PopoverTitle, + PopoverClose, + PopoverArrow, +} from "./popover"; + +// Skeleton component +export { Skeleton } from "./skeleton"; + +// ScrollArea component +export { ScrollArea, ScrollBar } from "./scroll-area"; + // AlertDialog component export { AlertDialog, diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx new file mode 100644 index 0000000..c339fd4 --- /dev/null +++ b/src/components/ui/popover.tsx @@ -0,0 +1,94 @@ +import * as React from "react" +import { Popover as PopoverPrimitive } from "@base-ui/react/popover" + +import { cn } from "@/lib/utils" +import { useTheme } from "@/providers"; + +function Popover({ ...props }: PopoverPrimitive.Root.Props) { + return ; +} + +function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) { + return ; +} + +function PopoverPortal({ ...props }: PopoverPrimitive.Portal.Props) { + return ; +} + +function PopoverContent({ + className, + align = "center", + alignOffset = 0, + side = "bottom", + sideOffset = 4, + ...props +}: PopoverPrimitive.Popup.Props & + Pick< + PopoverPrimitive.Positioner.Props, + "align" | "alignOffset" | "side" | "sideOffset" + >) { + const { mode } = useTheme(); + return ( + + + + + + ) +} + +function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) { + return ( + + ) +} + +function PopoverDescription({ + className, + ...props +}: PopoverPrimitive.Description.Props) { + return ( + + ) +} + +export { + Popover, + PopoverContent, + PopoverDescription, + PopoverHeader, + PopoverTitle, + PopoverTrigger, +} diff --git a/src/components/ui/scroll-area.tsx b/src/components/ui/scroll-area.tsx new file mode 100644 index 0000000..b1767dc --- /dev/null +++ b/src/components/ui/scroll-area.tsx @@ -0,0 +1,55 @@ +import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"; +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +function ScrollArea({ + className, + children, + ...props +}: ScrollAreaPrimitive.Root.Props) { + return ( + + + {children} + + + + + ); +} + +type ScrollAreaPrimitiveType = ScrollAreaPrimitive.Scrollbar.Props & { + scrollBarClassName?: string +} + +function ScrollBar({ + className, + orientation = "vertical", + scrollBarClassName = "", + ...props +}: ScrollAreaPrimitiveType) { + return ( + + + + ); +} + +export { ScrollArea, ScrollBar }; diff --git a/src/components/ui/skeleton.tsx b/src/components/ui/skeleton.tsx new file mode 100644 index 0000000..96f5857 --- /dev/null +++ b/src/components/ui/skeleton.tsx @@ -0,0 +1,18 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +function Skeleton({ + className, + ...props +}: React.HTMLAttributes) { + return ( +
+ ) +} + +export { Skeleton } diff --git a/src/index.ts b/src/index.ts index 4e959c7..72fb5aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -133,6 +133,20 @@ export { ModalFooter, ModalHeader, ModalOverlay, ModalTitle, // Notice Notice, NoticeAction, NoticeTitle, + // Popover + Popover, + PopoverArrow, + PopoverClose, + PopoverContent, + PopoverDescription, + PopoverPortal, + PopoverTitle, + PopoverTrigger, + // Skeleton + Skeleton, + // ScrollArea + ScrollArea, + ScrollBar, // Progress Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue,