From fddac5c5a398a639b74e92102660781078ffe5eb Mon Sep 17 00:00:00 2001 From: WeiViv <100058931+WeiViv@users.noreply.github.com> Date: Tue, 8 Oct 2024 22:04:31 -0500 Subject: [PATCH] Task K: Course Selector --- src/components/CourseList.css | 19 +++++++++++++------ src/components/CourseList.jsx | 15 +++++++++------ src/components/TermPage.jsx | 21 +++++++++++++-------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/components/CourseList.css b/src/components/CourseList.css index cf9a5f9..0f77282 100644 --- a/src/components/CourseList.css +++ b/src/components/CourseList.css @@ -1,15 +1,23 @@ .course-list { display: grid; grid-template-columns: repeat(auto-fill, 14rem); - gap: 1rem; /* Adds some space between the cards */ + gap: 1rem; } .card { display: flex; flex-direction: column; - height: 100%; /* Ensures consistent card height */ - padding: 1rem; - box-sizing: border-box; /* Includes padding in height calculation */ + height: 100%; + padding: 0; /* Remove internal padding if necessary */ + box-sizing: border-box; + border: 1px solid #ddd; /* Set a border to make unselected cards visible */ + transition: background-color 0.3s; /* Smooth transition for color change */ +} + +.card.selected { + background-color: rgb(64, 165, 241); + color: rgb(255, 255, 255); + border: 1px solid rgb(64, 165, 241); /* Match border color with background */ } .card-body { @@ -17,11 +25,10 @@ flex-direction: column; justify-content: space-between; flex-grow: 1; - height: 100%; /* Ensures the card body takes full height of the card */ } .course-info-divider { display: flex; flex-direction: column; - margin-top: auto; /* Pushes this section to the bottom of the card-body */ + margin-top: auto; } \ No newline at end of file diff --git a/src/components/CourseList.jsx b/src/components/CourseList.jsx index c1eccdc..e1936eb 100644 --- a/src/components/CourseList.jsx +++ b/src/components/CourseList.jsx @@ -1,14 +1,17 @@ import React from 'react'; import './CourseList.css'; -const CourseList = ({ courses, selectedTerm }) => { - const filteredCourses = Object.values(courses).filter( - (course) => course.term === selectedTerm - ); +const CourseList = ({ courses, selectedTerm, selectedCourse, toggleSelectedCourse}) => { + const filteredCourses = Object.entries(courses).filter(([key, course]) => course.term === selectedTerm); + return(
{course.title}
diff --git a/src/components/TermPage.jsx b/src/components/TermPage.jsx index 13f71cd..dc3cbbf 100644 --- a/src/components/TermPage.jsx +++ b/src/components/TermPage.jsx @@ -3,14 +3,19 @@ import TermSelector from './TermSelector'; import CourseList from './CourseList'; const TermPage = ({ courses }) => { - const [selectedTerm, setSelectedTerm] = useState("Fall"); // Default to "Fall" - -return ( -