Skip to content

Commit

Permalink
Implemented Popover Component based on task #18
Browse files Browse the repository at this point in the history
  • Loading branch information
ser888gio committed Sep 17, 2024
1 parent 18c35de commit a951b8f
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions packages/design-system/src/popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { forwardRef, ElementRef, ComponentPropsWithoutRef } from "react";
import * as PopoverPrimitive from "@headlessui/react";
import cn from "classnames";

const Popover = forwardRef<
ElementRef<typeof PopoverPrimitive.Popover>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.Popover>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.Popover
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.Popover.displayName = "Popover";

const PopoverBackdrop = forwardRef<
ElementRef<typeof PopoverPrimitive.PopoverBackdrop>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.PopoverBackdrop>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.PopoverBackdrop
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.PopoverBackdrop.displayName = "PopoverBackdrop";

const PopoverPanel = forwardRef<
ElementRef<typeof PopoverPrimitive.PopoverPanel>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.PopoverPanel>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.PopoverPanel
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.PopoverPanel.displayName = "PopoverPanel";

const PopoverButton = forwardRef<
ElementRef<typeof PopoverPrimitive.PopoverButton>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.PopoverButton>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.PopoverButton
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.PopoverButton.displayName = "PopoverButton";

const PopoverGroup = forwardRef<
ElementRef<typeof PopoverPrimitive.PopoverGroup>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.PopoverGroup>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.PopoverGroup
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.PopoverGroup.displayName = "PopoverGroup";

const CloseButton = forwardRef<
ElementRef<typeof PopoverPrimitive.CloseButton>,
ComponentPropsWithoutRef<typeof PopoverPrimitive.CloseButton>
>(({ className, ...props }, ref) => (
<PopoverPrimitive.CloseButton
ref={ref}
className={(cn(""), className)}
{...props}
/>
));
PopoverPrimitive.CloseButton.displayName = "CloseButton";

export {
Popover,
PopoverPanel,
PopoverBackdrop,
PopoverButton,
PopoverGroup,
CloseButton,
};

0 comments on commit a951b8f

Please sign in to comment.