Modal2.tsx 782 B

1234567891011121314151617181920212223
  1. 'use client';
  2. import Icon from '@/components/Icon';
  3. import { ModalContext } from '@/contexts/ModalContext';
  4. import { useContext } from 'react';
  5. const Modal = ({ content }) => {
  6. let { showModal, handleModal } = useContext(ModalContext);
  7. // const modalRoot = document.getElementById('#modal-root');
  8. return showModal ? (
  9. <div className="modal-backdrop" tabIndex={-1} role="dialog" onClick={handleModal} onKeyDown={handleModal}>
  10. <div className="modal" onClick={(e) => e.stopPropagation()}>
  11. <a href="#" className="modal-close" data-dismiss="modal" aria-label="Close modal" onClick={handleModal}>
  12. <Icon name="x" />
  13. </a>
  14. <div className="modal-body">{content}</div>
  15. </div>
  16. </div>
  17. ) : (
  18. <></>
  19. );
  20. };
  21. export default Modal;