-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
[diff-counting] Significant lines: 571. |
src/styles/courses/CourseCard.scss
Outdated
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
Also, when running I was getting this new warning that should probably be addressed:
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]);
There was a problem hiding this 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?
src/styles/courses/CourseCard.scss
Outdated
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 |
There was a problem hiding this comment.
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?
src/styles/courses/CourseCard.scss
Outdated
|
||
//check coursecard for hex color of prof | ||
border: 2px solid #BF7913; | ||
color: #BF7913; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
${roleString === "" ? "editable" : "ineditable"}`} | ||
onClick={selectCourse} |
There was a problem hiding this comment.
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?)
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"; | ||
} |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
Summary
Finishes Editing classes frontend, resolved Sophie's PR from last semester.
Test Plan
Notes
Breaking Changes
None