Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layla/finish edit classes frontend #928

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

laylaliuuu
Copy link
Collaborator

Summary

Finishes Editing classes frontend, resolved Sophie's PR from last semester.

  1. Fix the inconsistency in hover effects in former classes
  2. Cleaned up the style code in .tsx file to .cscc

Test Plan

Notes

Breaking Changes

None

  • I have updated the documentation accordingly.
  • My PR adds a @ts-ignore

@laylaliuuu laylaliuuu requested a review from a team as a code owner March 3, 2025 01:37
@dti-github-bot
Copy link
Member

dti-github-bot commented Mar 3, 2025

[diff-counting] Significant lines: 571.

role-color-ta:"#BF7913"; // the color for "TA"
role-color-professor: "green"; // a purple thats closer to our brand colors- #726CFF
selectedBackgroundColor-role-student: "rgba(214, 234, 254, 0.4)"; // "Student" role background color
selectedBorderColor-role-student: "#77BBFA"; // "Student" role border color
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the variable names in the css files are a nice addition to make the code more organized

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like the variable names as well, I think its a great idea! I'm not sure if its an error on my end, but for some reason in the CourseCard.scss file the variables are not recognized as variables with the $ starting character?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Annie, this is what it looks like on my end with and without the $:
image

Copy link
Contributor

@NIDHI2023 NIDHI2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, the hover issue seems to be fixed for me! A few more things, I think Richard mentioned a change to the font style specifically from sans-serif to Roboto, I think the font-size Sophie took care of already.
image

Also, when running I was getting this new warning that should probably be addressed:
image

You could resolve these by adding 'filterOnActiveAndRole' and 'currentCourses' into the useEffect dependency arrays as suggested. However, since filterOnActiveAndRole is an inline function, React sees it as a "new" function on every render of the CourseSelection component. So even if the logic inside filterOnActiveAndRole does not change, its reference will still be different after each render, which could unnecessarily trigger a lot of useEffect calls.

I think you could look into useCallback to ensure that the function reference remains stable unless one of its dependencies changes - so something like this:
const filterOnActiveAndRole = useCallback(() => { return allCourses .... }); }, [allCourses, CURRENT_SEMESTER, user.userId]);

@anchen9 anchen9 self-requested a review March 3, 2025 03:40
Copy link
Collaborator

@anchen9 anchen9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Layla! The hover state and documentation look great, good work on finish up Sophie's PR! Could you attach before & after screenshots to the PR as well?

role-color-ta:"#BF7913"; // the color for "TA"
role-color-professor: "green"; // a purple thats closer to our brand colors- #726CFF
selectedBackgroundColor-role-student: "rgba(214, 234, 254, 0.4)"; // "Student" role background color
selectedBorderColor-role-student: "#77BBFA"; // "Student" role border color
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like the variable names as well, I think its a great idea! I'm not sure if its an error on my end, but for some reason in the CourseCard.scss file the variables are not recognized as variables with the $ starting character?


//check coursecard for hex color of prof
border: 2px solid #BF7913;
color: #BF7913;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Prof color is hardcoded here, maybe use one of the variables you defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i just delete it here? Because I dont think it make sense here.

setFormerCourses(allCourses.filter((course) => {
return course.semester !== CURRENT_SEMESTER;
}));
const filterOnActiveAndRole = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an optimization that can be made for the filterOnActiveAndRole function is to use the React Hook useMemo to "memoize" the calculation of all the filtering and sorting of all courses. The current implementation would have to run the filtering and sorting every time the page renders, which may result in latency. This is probably not a significant issue right now since QMI only has a limited number of courses, but once the course list expands for allCourses, it would be computation-heavy. An example of useMemo would be:

const filterOnActiveAndRole = useMemo(() => { ... }, [dependency array])

className="courseRole"
style={{
border: "2px solid " + roleColor,
color: roleColor,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here's where Sophie's trying to use the roleColor variable above - if the css variables don't work out you might just need to hardcode values like "green" for professor and "#BF7913" for TA

Comment on lines 58 to 59
${roleString === "" ? "editable" : "ineditable"}`}
onClick={selectCourse}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I need this, as all of them should be ineditable (clickable?)

Comment on lines 40 to 53
let roleString = "";
let roleColor = "";
let selectedBackgroundColor = "var(selected-background-color)"; // variables can be changed based on different roles
let selectedBorderColor = "var(selected-border-color)";
if (role === "ta") {
roleString = "TA";
roleColor = "#var(role-color-ta)";
} else if (role === "professor") {
roleString = "PROF";
roleColor = "#var(role-color-professor)";
} else {
selectedBackgroundColor = "selectedBackgroundColor-role-student";
selectedBorderColor = "selectedBorderColor-role-student";
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this can be deleted too, but we can talk about it tomorrow, because there are few places that used roleString and i don't know if that will change the behavior of the roles.

flex: 1;
border-radius: 15px;
border: none;
font-size: 18px;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the font here, but I think "Roboto" is already coded as the font for the entire page at top, but I just added it here again. Also I changed the font size to a little bit smaller to match the design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants