-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bd434c
commit 49e77f2
Showing
3 changed files
with
47 additions
and
36 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
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
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 |
---|---|---|
@@ -1,42 +1,51 @@ | ||
"use client" | ||
'use client' | ||
|
||
import * as React from "react" | ||
import * as PopoverPrimitive from "@radix-ui/react-popover" | ||
import * as React from 'react' | ||
import * as PopoverPrimitive from '@radix-ui/react-popover' | ||
|
||
import classNames from "classnames" | ||
import classNames from 'classnames' | ||
import { useContext } from 'react' | ||
import { ThemeContext } from '../../contexts/theme' | ||
|
||
const Popover = PopoverPrimitive.Root | ||
|
||
const PopoverTrigger = PopoverPrimitive.Trigger | ||
|
||
const PopoverContent = React.forwardRef< | ||
React.ElementRef<typeof PopoverPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> | ||
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( | ||
React.ElementRef<typeof PopoverPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> | ||
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => { | ||
const { dark } = useContext(ThemeContext) | ||
|
||
return ( | ||
<PopoverPrimitive.Portal> | ||
<div className={classNames(dark ? 'dark' : null)}> | ||
<PopoverPrimitive.Content | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={classNames( | ||
"z-50 rounded-md border bg-popover p-4 text-popover-foreground\ | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={classNames( | ||
'z-50 rounded-md border bg-popover p-4 text-popover-foreground\ | ||
shadow-md outline-none animate-in data-[side=bottom]:slide-in-from-top-2\ | ||
data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2\ | ||
data-[side=top]:slide-in-from-bottom-2", | ||
className | ||
)} | ||
{...props} | ||
data-[side=top]:slide-in-from-bottom-2', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
</div> | ||
</PopoverPrimitive.Portal> | ||
)) | ||
) | ||
}) | ||
PopoverContent.displayName = PopoverPrimitive.Content.displayName | ||
|
||
const PopoverExample = () => { | ||
return <Popover> | ||
<PopoverTrigger>Open</PopoverTrigger> | ||
<PopoverContent>Place content for the popover here.</PopoverContent> | ||
return ( | ||
<Popover> | ||
<PopoverTrigger>Open</PopoverTrigger> | ||
<PopoverContent>Place content for the popover here.</PopoverContent> | ||
</Popover> | ||
) | ||
} | ||
|
||
|
||
export { Popover, PopoverTrigger, PopoverContent, PopoverExample } | ||
export { Popover, PopoverTrigger, PopoverContent, PopoverExample } |