chore: upgrade ariakit

This commit is contained in:
Aman Harwara
2023-05-16 16:19:22 +05:30
parent 0c4d44fb00
commit 3b23312b62
12 changed files with 91 additions and 114 deletions

View File

@@ -6,39 +6,29 @@ import { useModalAnimation } from '../Modal/useModalAnimation'
type Props = {
isOpen: boolean
children: ReactNode
portal?: boolean
}
const ModalOverlay = forwardRef(
({ isOpen, children, portal = true, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
const [isMounted, setElement] = useModalAnimation(isOpen)
const dialog = useDialogStore({
open: isMounted,
})
const ModalOverlay = forwardRef(({ isOpen, children, ...props }: Props, ref: ForwardedRef<HTMLDivElement>) => {
const [isMounted, setElement] = useModalAnimation(isOpen)
const dialog = useDialogStore({
open: isMounted,
})
if (!isMounted) {
return null
}
if (!isMounted) {
return null
}
return (
<Dialog
tabIndex={0}
className="h-full w-full"
backdropProps={{
className: '!z-modal',
style: {
position: !portal ? 'absolute' : 'fixed',
},
}}
ref={mergeRefs([setElement, ref])}
store={dialog}
portal={portal}
{...props}
>
{children}
</Dialog>
)
},
)
return (
<Dialog
tabIndex={0}
className="fixed top-0 left-0 z-modal h-full w-full"
ref={mergeRefs([setElement, ref])}
store={dialog}
{...props}
>
{children}
</Dialog>
)
})
export default ModalOverlay