Skip to content
Snippets Groups Projects
Commit 3d1cba9c authored by Planoetscher Daniel (Student Com20)'s avatar Planoetscher Daniel (Student Com20)
Browse files

open popups in portals

parent 91ea30f7
No related branches found
No related tags found
No related merge requests found
import { ReactNode } from 'react';
import { createPortal } from 'react-dom';
import './popup.scss';
const root = document.getElementById('root') ?? document.getElementsByTagName('html')[0];
interface Props {
children: ReactNode
onClose: Function
......@@ -10,17 +13,18 @@ interface Props {
export default function Popup({ children, onClose }: Props) {
document.addEventListener('keydown', (e) => {
if(e.key === "Escape") {
if (e.key === "Escape") {
onClose();
}
});
return (
return createPortal(
<div className="popup-container">
<div className="popup">
{children}
</div>
<div className="background" onClick={() => onClose()}></div>
</div>
</div>, root
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment