From 282cb314b1ccc25650cf253b1128ecb69ae0a59e Mon Sep 17 00:00:00 2001 From: Stuart Hendren Date: Thu, 4 Aug 2022 12:57:44 +0000 Subject: [PATCH] fix(Popover): updates Popover for radix v1 Update Popover for addition of Portal component see #286 --- src/components/Popover/Popover.tsx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/Popover/Popover.tsx b/src/components/Popover/Popover.tsx index 2a785985..d6279495 100644 --- a/src/components/Popover/Popover.tsx +++ b/src/components/Popover/Popover.tsx @@ -3,12 +3,14 @@ import { Arrow, Close, Content, + Portal, Root, Trigger, } from '@radix-ui/react-popover' import React, { ComponentProps, ElementRef, FC, forwardRef } from 'react' import type { AsProps, CSSProps } from '../../stitches.config' import { styled } from '../../stitches.config' +import { ConditionalWrapper } from '../../utils' import { paperStyles } from '../Paper' const StyledContent = styled(Content, paperStyles, { @@ -30,16 +32,28 @@ const StyledArrow = styled(Arrow, { fill: '$paper', }) -type PopoverContentProps = CSSProps & AsProps & ComponentProps +type PopoverContentProps = CSSProps & + AsProps & + ComponentProps & { + /** By default, portals your content parts into the body, set false to add at dom location. */ + portalled?: boolean + /** Specify a container element to portal the content into. */ + container?: ComponentProps['container'] + } export const PopoverContent = forwardRef< ElementRef, PopoverContentProps ->(({ children, ...props }, forwardedRef) => ( - - - {children} - +>(({ portalled = true, container, children, ...props }, forwardedRef) => ( + {child}} + > + + + {children} + + )) PopoverContent.toString = () => `.${StyledContent.className}`