-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Popover Component based on task #18
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |