working on modal

This commit is contained in:
nospeedlimitindonesia
2024-07-29 23:55:39 +00:00
parent 93df0458e6
commit 1bef19f624
7 changed files with 197 additions and 146 deletions

View File

@@ -1,15 +1,28 @@
// src/components/Modal.js
import React from 'react';
import styles from './Modal.module.css';
import React from "react";
import styles from "./Modal.module.css";
const Modal = ({ isOpen, onClose, children }) => {
if (!isOpen) return null;
// Function to handle clicks on the overlay
const handleOverlayClick = (event) => {
// Close the modal only if the overlay is clicked
onClose();
};
// Function to handle clicks on the modal content
const handleContentClick = (event) => {
// Prevent click event from propagating to the overlay
event.stopPropagation();
};
return (
<div className={styles.modalOverlay}>
<div className={styles.modalContent}>
<div onClick={handleOverlayClick} className={styles.modalOverlay}>
<div className={styles.modalContent} onClick={handleContentClick}>
{children}
<button onClick={onClose} className={styles.closeButton}>Close</button>
<button onClick={onClose} className={styles.closeButton}>
Close
</button>
</div>
</div>
);