hensei-web/components/common/PopoverContent/index.tsx
Justin Edmund 4c5fb3c28d Rename all files and fix imports
* Renaming index.scss files to index.module.scss
* Changing `import from` to `import styles from`
2023-06-23 13:19:38 -07:00

44 lines
1.1 KiB
TypeScript

import React, { PropsWithChildren } from 'react'
import classnames from 'classnames'
import * as PopoverPrimitive from '@radix-ui/react-popover'
import styles from './index.module.scss'
interface Props
extends React.DetailedHTMLProps<
React.DialogHTMLAttributes<HTMLDivElement>,
HTMLDivElement
>,
PopoverPrimitive.PopoverContentProps {}
export const Popover = PopoverPrimitive.Root
export const PopoverAnchor = PopoverPrimitive.Anchor
export const PopoverTrigger = PopoverPrimitive.Trigger
export const PopoverContent = React.forwardRef<HTMLDivElement, Props>(
function Popover(
{ children, ...props }: PropsWithChildren<Props>,
forwardedRef
) {
const classes = classnames(props.className, {
Popover: true,
})
return (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
{...props}
className={classes}
ref={forwardedRef}
>
{children}
<PopoverPrimitive.Arrow className="Arrow" />
</PopoverPrimitive.Content>
</PopoverPrimitive.Portal>
)
}
)
PopoverContent.defaultProps = {
sideOffset: 8,
}