From 881a6d147d5349bdb8139404e4bd195b36d1c270 Mon Sep 17 00:00:00 2001 From: Lejun Deng Date: Sun, 21 Apr 2024 11:23:25 -0400 Subject: [PATCH] Re-added profile dropdown, fixed hight issues --- .../src/navbar/account/MeDropdown.module.css | 1 - frontend/src/navbar/account/MeDropdown.tsx | 7 +- frontend/src/pages/Courses/Courses.tsx | 121 +++++++++++++----- frontend/src/pages/Graduation/Graduation.tsx | 83 +++++++----- frontend/src/pages/Majors/Majors.tsx | 66 ++++++---- 5 files changed, 185 insertions(+), 93 deletions(-) diff --git a/frontend/src/navbar/account/MeDropdown.module.css b/frontend/src/navbar/account/MeDropdown.module.css index 1adc531..c05f09d 100644 --- a/frontend/src/navbar/account/MeDropdown.module.css +++ b/frontend/src/navbar/account/MeDropdown.module.css @@ -37,7 +37,6 @@ .navbarMe { /* padding-left: 1rem; */ - height: 40px; display: flex; } diff --git a/frontend/src/navbar/account/MeDropdown.tsx b/frontend/src/navbar/account/MeDropdown.tsx index 30873dc..8a71c8c 100644 --- a/frontend/src/navbar/account/MeDropdown.tsx +++ b/frontend/src/navbar/account/MeDropdown.tsx @@ -8,7 +8,10 @@ import { FaSignOutAlt } from "react-icons/fa"; import clsx from "clsx"; import styles from "./MeDropdown.module.css"; -import { scrollToTop, useComponentVisible } from "../../commons/utilities/display"; +import { + scrollToTop, + useComponentVisible, +} from "../../commons/utilities/display"; import { SurfaceComponent, TextComponent, HoverText } from "../Typography"; function DropdownItem({ @@ -102,6 +105,7 @@ function DropdownContent({ smooth */}
+ {/* About @@ -111,6 +115,7 @@ function DropdownContent({ Release Notes + */} Sign Out diff --git a/frontend/src/pages/Courses/Courses.tsx b/frontend/src/pages/Courses/Courses.tsx index c874b57..94eac8d 100644 --- a/frontend/src/pages/Courses/Courses.tsx +++ b/frontend/src/pages/Courses/Courses.tsx @@ -1,4 +1,3 @@ - import React, { useState, useEffect } from "react"; import styles from "./Courses.module.css"; @@ -6,7 +5,7 @@ import YearBox from "./components/YearBox"; import AddCourseMenu from "./components/add_course/AddCourse"; import { MockStudent } from "./../../commons/mock/MockStudent"; - +import MeDropdown from "../../navbar/account/MeDropdown"; import nav_styles from "./../../commons/components/navbar/NavBar.module.css"; import img_logo from "./../../commons/images/ma_logo.png"; import { NavLink } from "react-router-dom"; @@ -15,59 +14,102 @@ function NavBar() { return (
- +
- isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Graduation - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Courses - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Majors - {/* */} +
); } export interface DisplaySetting { - rating: boolean, - workload: boolean, + rating: boolean; + workload: boolean; } const defaultDisplaySetting = { rating: true, workload: true }; -function Settings(props: { displaySetting: DisplaySetting, updateDisplaySetting: Function }) { - +function Settings(props: { + displaySetting: DisplaySetting; + updateDisplaySetting: Function; +}) { const [isOpen, setIsOpen] = useState(false); - const toggleDropdown = () => { setIsOpen(!isOpen); }; + const toggleDropdown = () => { + setIsOpen(!isOpen); + }; const throwBack = (key: string) => { - if(key === "rating"){ - const newSetting = { ...props.displaySetting, rating: !props.displaySetting.rating }; + if (key === "rating") { + const newSetting = { + ...props.displaySetting, + rating: !props.displaySetting.rating, + }; props.updateDisplaySetting(newSetting); - } else - if(key === "workload"){ - const newSetting = { ...props.displaySetting, workload: !props.displaySetting.workload }; + } else if (key === "workload") { + const newSetting = { + ...props.displaySetting, + workload: !props.displaySetting.workload, + }; props.updateDisplaySetting(newSetting); } - } + }; return (
- {isOpen && (
- -
@@ -77,35 +119,44 @@ function Settings(props: { displaySetting: DisplaySetting, updateDisplaySetting: } function Courses() { - const [displaySetting, setDisplaySetting] = useState(defaultDisplaySetting); - const updateDisplaySetting = (newSetting: DisplaySetting) => { setDisplaySetting(newSetting); }; + const updateDisplaySetting = (newSetting: DisplaySetting) => { + setDisplaySetting(newSetting); + }; useEffect(() => {}, [displaySetting]); const [addCourse, setAddCourse] = useState(false); - const toggleAddCourse = () => { setAddCourse(!addCourse); }; + const toggleAddCourse = () => { + setAddCourse(!addCourse); + }; useEffect(() => {}, [addCourse]); const yearboxComponents = []; - for(let i=0; i ); + for (let i = 0; i < MockStudent["metadata"].length; i++) { + yearboxComponents.push( + + ); } - return( + return (
- - + +
-
- {addCourse && ()} -
-
- {yearboxComponents} +
+ {addCourse && }
+
{yearboxComponents}
); diff --git a/frontend/src/pages/Graduation/Graduation.tsx b/frontend/src/pages/Graduation/Graduation.tsx index 2e80077..01dc253 100644 --- a/frontend/src/pages/Graduation/Graduation.tsx +++ b/frontend/src/pages/Graduation/Graduation.tsx @@ -1,12 +1,11 @@ - import React, { useState } from "react"; import styles from "./Graduation.module.css"; import GraduationDistribution from "./components/DistributionTable"; import GraduationOverview from "./components/Overview"; -import { CPSC } from "./../../commons/mock/MockProgram" - +import { CPSC } from "./../../commons/mock/MockProgram"; +import MeDropdown from "../../navbar/account/MeDropdown"; import nav_styles from "./../../commons/components/navbar/NavBar.module.css"; import img_logo from "./../../commons/images/ma_logo.png"; import { NavLink } from "react-router-dom"; @@ -14,62 +13,80 @@ import { NavLink } from "react-router-dom"; function NavBar() { return (
-
- +
- isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Graduation - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Courses - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Majors - {/* */} +
); } -function Recommendations(){ - return( +function Recommendations() { + return (
-
- Hello, Ryan! -
+
Hello, Ryan!
); } function Graduation() { + const UserYear = () => { + return 2; + }; + const [currYear, setCurrYear] = useState(UserYear()); + const alterCurrYear = (num: number) => { + setCurrYear(num); + }; -const UserYear = () => { return 2; } -const [currYear, setCurrYear] = useState(UserYear()); -const alterCurrYear = (num: number) => { - setCurrYear(num); -}; + return ( +
+ -return ( -
- - - -
-
-
- - +
+
+
+ + +
+
-
-
-); + ); } export default Graduation; - diff --git a/frontend/src/pages/Majors/Majors.tsx b/frontend/src/pages/Majors/Majors.tsx index ae9b11a..d486573 100644 --- a/frontend/src/pages/Majors/Majors.tsx +++ b/frontend/src/pages/Majors/Majors.tsx @@ -1,5 +1,4 @@ - -import React, { useState } from 'react'; +import React, { useState } from "react"; import styles from "./Majors.module.css"; import ProgramRequirementsBox from "./components/ProgramRequirementsBox"; @@ -8,7 +7,7 @@ import ProgramMetadataBox from "./components/ProgramMetadataBox"; import nav_styles from "./../../commons/components/navbar/NavBar.module.css"; import img_logo from "./../../commons/images/ma_logo.png"; import { NavLink } from "react-router-dom"; - +import MeDropdown from "../../navbar/account/MeDropdown"; import { CGSC, CPSC, ECON, HIST } from "./../../commons/mock/MockProgram"; const programs = [CGSC, CPSC, ECON, HIST]; @@ -16,54 +15,75 @@ function NavBar() { return (
- +
- isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Graduation - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Courses - isActive ? nav_styles.activeLink : nav_styles.dormantLink }> + + isActive ? nav_styles.activeLink : nav_styles.dormantLink + } + > Majors - {/* */} +
); } export const Majors = () => { - // Which Program const [currdex, setCurrdex] = useState(0); - const alterCurrdex = (dir: number) => { + const alterCurrdex = (dir: number) => { setCurrdex((currdex + dir + programs.length) % programs.length); - setCurrDegree(0); + setCurrDegree(0); }; - const seeProgram = (dir: number) => { - return programs[(currdex + dir + programs.length) % programs.length]; + const seeProgram = (dir: number) => { + return programs[(currdex + dir + programs.length) % programs.length]; }; // Which Degree const [currDegree, setCurrDegree] = useState(0); - const alterCurrDegree = (num: number) => { - setCurrDegree(num); + const alterCurrDegree = (num: number) => { + setCurrDegree(num); }; - - return( + + return (
- +
- - + alterCurrDegree={alterCurrDegree} + /> +
);