import "./Modal.scss"; import React, { useState, useLayoutEffect } from "react"; import { createPortal } from "react-dom"; import clsx from "clsx"; import { KEYS } from "../keys"; export const Modal = (props: { className?: string; children: React.ReactNode; maxWidth?: number; onCloseRequest(): void; labelledBy: string; }) => { const modalRoot = useBodyRoot(); if (!modalRoot) { return null; } const handleKeydown = (event: React.KeyboardEvent) => { if (event.key === KEYS.ESCAPE) { event.nativeEvent.stopImmediatePropagation(); props.onCloseRequest(); } }; return createPortal(