-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.modalOverlay { | ||
position: fixed; /* Use fixed positioning */ | ||
top: 0; | ||
left: 0; | ||
width: 100%; /* Full width */ | ||
height: 100%; /* Full height */ | ||
background-color: rgba(0, 0, 0, 0.5); /* Black background with opacity */ | ||
display: flex; /* Use flexbox for centering */ | ||
justify-content: center; /* Center horizontally */ | ||
align-items: center; /* Center vertically */ | ||
z-index: 1000; /* Ensure it sits above other content */ | ||
} | ||
|
||
.modalContent { | ||
width: 500px; /* Or any desired width */ | ||
padding: 20px; | ||
background-color: white; /* Background color of the modal */ | ||
border-radius: 35px; /* Optional: rounded corners */ | ||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Optional: shadow for aesthetics */ | ||
overflow: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ReactNode, useEffect, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
import styles from './modal.module.scss'; | ||
|
||
type Props = { | ||
children: ReactNode | ReactNode[]; | ||
}; | ||
function Portal({ children }: Props) { | ||
const [mounted, setMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
setMounted(true); | ||
|
||
return () => setMounted(false); | ||
}, []); | ||
|
||
return mounted | ||
? createPortal( | ||
<div className={styles.modalOverlay}> | ||
<div className={styles.modalContent}>{children}</div> | ||
</div>, | ||
document.body | ||
) | ||
: null; | ||
} | ||
|
||
export default Portal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters