-
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
edit classes frontend redesign #887
Open
swang235
wants to merge
8
commits into
master
Choose a base branch
from
sophie-edit-classes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
28c2670
edit classes frontend
swang235 afbece3
lint fixes
swang235 b8f555c
lint fixes 2
swang235 656e3a2
pr comments
swang235 41097ae
Merge remote-tracking branch 'origin/master' into sophie-edit-classes
swang235 58a8ded
fix merge conflict and margin
swang235 eed7814
make all classes hoverable after saved classes
swang235 71dcc5a
change search bar input size
swang235 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as React from 'react'; | ||
import { useHistory } from 'react-router'; | ||
import { Icon } from 'semantic-ui-react'; | ||
import * as React from "react"; | ||
import { useHistory } from "react-router"; | ||
import { Icon } from "semantic-ui-react"; | ||
import { Grid } from "@material-ui/core"; | ||
|
||
type Props = { | ||
course: FireCourse; | ||
|
@@ -11,53 +12,103 @@ type Props = { | |
selected: boolean; | ||
inactive?: boolean; | ||
}; | ||
|
||
/** | ||
* Renders a course card to display in the course selection page. Displays course code, name, and role if applicable. | ||
* @param course: the course to be displayed | ||
* @param role: the role of the user in the course | ||
* @param onSelectCourse: function to call when the course is selected | ||
* @param editable: whether the course card is editable (ex if you are a ta, you cannot unselect the course) | ||
* @param selected: whether the course is selected | ||
* @param inactive: whether the course is inactive for the current semester | ||
* @returns rendered CourseCard component | ||
*/ | ||
const CourseCard = ({ course, role, onSelectCourse, editable, selected, inactive = false }: Props) => { | ||
const history = useHistory(); | ||
|
||
const selectCourse = () => { | ||
if (!editable) { | ||
if (!inactive) { | ||
history.push('/course/' + course.courseId); | ||
history.push("/course/" + course.courseId); | ||
} | ||
return; | ||
} | ||
if (role === undefined || role === 'student') { | ||
if (role === undefined || role === "student") { | ||
onSelectCourse(!selected); | ||
} | ||
}; | ||
|
||
let roleString = ''; | ||
if (role === 'ta') { | ||
roleString = 'TA'; | ||
} else if (role === 'professor') { | ||
roleString = 'PROF'; | ||
let roleString = ""; | ||
let roleColor = ""; | ||
let selectedBackgroundColor = "#F5F5F5"; | ||
let selectedBorderColor = "#D8D8D8"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh can we put these in the associated .scss file? |
||
if (role === "ta") { | ||
roleString = "TA"; | ||
roleColor = "#BF7913"; | ||
} else if (role === "professor") { | ||
roleString = "PROF"; | ||
roleColor = "green"; // a purple thats closer to our brand colors- #726CFF | ||
} else { | ||
selectedBackgroundColor = "rgba(214, 234, 254, 0.4)"; | ||
selectedBorderColor = "#77BBFA"; | ||
} | ||
|
||
return ( | ||
<div | ||
className={`CourseCard ${selected && editable ? 'selected' : ''} ${ | ||
inactive ? 'inactive' : 'active' | ||
}`} | ||
className={`CourseCard ${selected && editable ? "selected" : ""} ${inactive ? "inactive" : "active"} | ||
${roleString === "" ? "editable" : "ineditable"}`} | ||
onClick={selectCourse} | ||
style={ | ||
selected && editable | ||
? { backgroundColor: selectedBackgroundColor, borderColor: selectedBorderColor } | ||
: {} | ||
} | ||
> | ||
<Grid container direction="row" justifyContent="space-between" style={{ height: "58px" }}> | ||
{roleString ? ( | ||
<Grid container item className="courseColor" xs={6}> | ||
<span | ||
className="courseRole" | ||
style={{ | ||
border: "2px solid " + roleColor, | ||
color: roleColor, | ||
}} | ||
> | ||
{roleString} | ||
</span>{" "} | ||
</Grid> | ||
) : ( | ||
<Grid container item className="courseColor" xs={6} /> | ||
)} | ||
{roleString === "" && !inactive ? ( | ||
<div> | ||
{editable ? ( | ||
<Grid container item xs={6} justify-self="end"> | ||
<div className="courseColor"> | ||
{selected ? ( | ||
<Icon className="icon" fill="#77BBFA" color="blue" name="check circle" /> | ||
) : ( | ||
<Icon className="icon" color="grey" name="circle outline" /> | ||
)} | ||
</div> | ||
</Grid> | ||
) : ( | ||
<Grid container item xs={6} justify-self="end" /> | ||
)} | ||
</div> | ||
) : ( | ||
<></> | ||
)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: let's avoid empty components |
||
</Grid> | ||
<div className="courseText"> | ||
<div className="courseCode"> | ||
{course.code} | ||
{roleString && <span className="role">{roleString}</span>} | ||
<div className="courseCode">{course.code}</div> | ||
<div className="courseName"> | ||
{course.name.length > 30 ? course.name.substring(0, 27) + "..." : course.name} | ||
</div> | ||
<div className="courseName">{course.name}</div> | ||
</div> | ||
{!inactive ? ( | ||
<div className="courseColor"> | ||
{editable ? ( | ||
selected ? ( | ||
<Icon className="icon" name="check" /> | ||
) : ( | ||
<Icon className="icon" name="plus" /> | ||
) | ||
) : ( | ||
<div>Go to course</div> | ||
)} | ||
|
||
{!inactive && !editable ? ( | ||
<div className="myClasses"> | ||
<div className="myClassesText">Go to course</div> | ||
</div> | ||
) : ( | ||
<></> | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
General: non prof/ta former classes still seem to have the hover effect (benji 2110) when idt they should