Skip to content

Commit

Permalink
modal root properties override (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA authored Aug 1, 2024
1 parent 10de23d commit e5fcbc0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import * as ModalPrimitive from '@radix-ui/react-dialog'
import { clsx } from 'clsx'
import { motion, MotionProps } from 'framer-motion'
import { PropsWithChildren, useEffect, useState } from 'react'

Expand All @@ -24,6 +25,7 @@ export type ModalProps = {
scroll?: boolean
overlayProps?: MotionProps
contentProps?: MotionProps
rootProps?: BoxProps
} & styles.ContentVariants

// const portalRoot = document.getElementById('portal')
Expand All @@ -40,6 +42,7 @@ export const Modal = (props: PropsWithChildren<ModalProps>) => {
size = 'lg',
overlayProps,
contentProps,
rootProps = {},
} = props
const { root } = useTheme()
const [container, setContainer] = useState<HTMLElement | null>(null)
Expand All @@ -51,7 +54,10 @@ export const Modal = (props: PropsWithChildren<ModalProps>) => {
return container ? (
<ModalPrimitive.Root modal defaultOpen onOpenChange={onClose}>
<ModalPrimitive.Portal forceMount container={container}>
<Box className={styles.root}>
<Box
{...rootProps}
className={clsx(styles.root, rootProps?.className)}
>
<Box
as={ModalPrimitive.Overlay}
asChild
Expand Down

0 comments on commit e5fcbc0

Please sign in to comment.