Skip to content

Commit

Permalink
feat(Modal): use createPortal for rendering modal in the DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
shenshin committed Nov 20, 2024
1 parent d6980f9 commit 98ef1ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use client'

import { FC, ReactNode } from 'react'
import Image from 'next/image'
import { cn } from '@/lib/utils'
import { createPortal } from 'react-dom'

interface Props {
className?: string
Expand All @@ -9,7 +12,7 @@ interface Props {
width?: number
}
export const Modal: FC<Props> = ({ children, onClose, width, className }) => {
return (
return createPortal(
<div className="fixed inset-0 flex items-center justify-center z-50 rounded-[8px]">
<div
className="fixed inset-0 backdrop-filter backdrop-blur-2xl transition-opacity"
Expand All @@ -27,6 +30,7 @@ export const Modal: FC<Props> = ({ children, onClose, width, className }) => {
</button>
{children}
</div>
</div>
</div>,
document.body,
)
}

0 comments on commit 98ef1ac

Please sign in to comment.