2023-02-14 16:36:38 +00:00
|
|
|
import { Content, Portal, Root, Trigger } from '@radix-ui/react-popover'
|
|
|
|
import { Stack } from 'tamagui'
|
|
|
|
|
|
|
|
import type { PopoverContentProps } from '@radix-ui/react-popover'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
children: [React.ReactElement, React.ReactElement]
|
|
|
|
onOpenChange?: (open: boolean) => void
|
|
|
|
modal?: false
|
|
|
|
side?: PopoverContentProps['side']
|
|
|
|
sideOffset?: PopoverContentProps['sideOffset']
|
|
|
|
align?: PopoverContentProps['align']
|
|
|
|
alignOffset?: PopoverContentProps['alignOffset']
|
|
|
|
}
|
|
|
|
|
|
|
|
const Popover = (props: Props) => {
|
|
|
|
const { children, onOpenChange, modal, ...contentProps } = props
|
|
|
|
|
|
|
|
const [trigger, content] = children
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Root onOpenChange={onOpenChange} modal={modal}>
|
|
|
|
<Trigger asChild>{trigger}</Trigger>
|
|
|
|
<Portal>
|
|
|
|
<Content {...contentProps}>{content}</Content>
|
|
|
|
</Portal>
|
|
|
|
</Root>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-03-13 21:24:39 +00:00
|
|
|
type ContentProps = {
|
|
|
|
children: React.ReactNode
|
|
|
|
}
|
|
|
|
|
|
|
|
const PopoverContent = (props: ContentProps) => {
|
2023-02-14 16:36:38 +00:00
|
|
|
const { children } = props
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Stack
|
|
|
|
backgroundColor="$white-100"
|
2023-04-11 10:30:25 +00:00
|
|
|
borderRadius="$12"
|
2023-02-14 16:36:38 +00:00
|
|
|
shadowRadius={30}
|
2023-10-23 13:02:17 +00:00
|
|
|
shadowOffset={{ width: 0, height: 8 }}
|
2023-02-14 16:36:38 +00:00
|
|
|
shadowColor="rgba(9, 16, 28, 0.12)"
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Stack>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Popover.Content = PopoverContent
|
|
|
|
|
|
|
|
export { Popover as Popover }
|
|
|
|
export type { Props as PopoverProps }
|