diff --git a/src/components/Modal.css b/src/components/Modal.css new file mode 100644 index 0000000..cf44c1b --- /dev/null +++ b/src/components/Modal.css @@ -0,0 +1,24 @@ +.modal { + display: block; + visibility: hidden; +} + +.modal-show { + visibility:visible; + background-color: rgba(169, 169, 169, 0.8); + transition: opacity 0.2s linear; +} + +.modal-content { + opacity: 0; +} + +.modal-show .modal-content { + opacity: 1; + transition: 0.2s linear; +} + +.modal-header { + display: flex; + justify-content: space-between; +} \ No newline at end of file diff --git a/src/components/Modal.jsx b/src/components/Modal.jsx new file mode 100644 index 0000000..6fb49e2 --- /dev/null +++ b/src/components/Modal.jsx @@ -0,0 +1,42 @@ +import './Modal.css'; + +const Modal = ({ CoursePlan, open, close }) => ( +
{ if (evt.target === evt.currentTarget) close(); }} + > +
+
+
+
Course Plan
+
+
+ {CoursePlan.length === 0 ? ( +

+ No courses selected. +
+ Please select courses by clicking on the cards. +

+ ) : ( +
    + {CoursePlan.map((course) => ( +
  • + {course.term} CS {course.number}: {course.title} +
    + {course.meets} +
  • + ))} +
+ )} +
+
+
+
+ ); + +export default Modal; \ No newline at end of file diff --git a/src/components/TermPage.jsx b/src/components/TermPage.jsx index dc3cbbf..708c589 100644 --- a/src/components/TermPage.jsx +++ b/src/components/TermPage.jsx @@ -1,18 +1,32 @@ import React, { useState } from 'react'; import TermSelector from './TermSelector'; import CourseList from './CourseList'; +import Modal from './Modal'; const TermPage = ({ courses }) => { const [selectedTerm, setSelectedTerm] = useState("Fall"); // Default to "Fall" const [selectedCourse, setSelectedCourse] = useState([]); + + // Modal state and functions + const [open, setOpen] = useState(false); + const openModal = () => setOpen(true); + const closeModal = () => setOpen(false); + const toggleSelectedCourse = (item) => setSelectedCourse( selectedCourse.includes(item) ? selectedCourse.filter(x => x !== item) : [...selectedCourse, item] );// store selected items in selected array + + const CoursePlan = selectedCourse.map(key => courses[key]); + return (
- +
+ + +
+
);