-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Home): add Verified/Unverified Instructor label (#39)
Co-authored-by: Ethan Turner <[email protected]>
- Loading branch information
1 parent
af6dce8
commit 38dc5be
Showing
15 changed files
with
1,471 additions
and
1,132 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import React, { useEffect } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import PropTypes from "prop-types"; | ||
import { Card, Popup, Icon, Button } from "semantic-ui-react"; | ||
import { format, parseISO } from "date-fns"; | ||
import { truncateString } from "../../util/HelperFunctions"; | ||
import ProjectProgressBar from "../ProjectProgressBar"; | ||
import "./ProjectCard.css"; | ||
import { Project } from "../../../types"; | ||
|
||
type ProjectCardProps = { | ||
project: Project; | ||
showPinButton?: boolean; | ||
onPin?: (projectID: string) => void; | ||
}; | ||
/** | ||
* A UI component representing a Project and displaying its basic information and status. | ||
*/ | ||
const ProjectCard = ({ | ||
project, | ||
showPinButton = false, | ||
onPin = () => {}, | ||
...props | ||
}: ProjectCardProps) => { | ||
let updateDate; | ||
let updateTime; | ||
|
||
if (project.updatedAt) { | ||
const parsedDate = parseISO(project.updatedAt); | ||
updateDate = format(parsedDate, "MM/dd/yy"); | ||
updateTime = format(parsedDate, "h:mm aa"); | ||
} | ||
|
||
/** | ||
* Activates the provided callback (if valid) when the user clicks the "Pin" button. | ||
*/ | ||
const handlePinClick = () => { | ||
if (typeof onPin === "function") { | ||
onPin(project.projectID); | ||
} | ||
}; | ||
|
||
return ( | ||
<Card raised {...props}> | ||
<div className="flex-col-div project-card-content"> | ||
<div className="flex-row-div"> | ||
<div className="flex-col-div project-card-title-column"> | ||
<Link | ||
className="project-card-title" | ||
to={`/projects/${project.projectID}`} | ||
> | ||
{truncateString(project.title, 100)} | ||
</Link> | ||
<span className="muted-text project-card-lastupdate"> | ||
Last updated {updateDate} at {updateTime} | ||
</span> | ||
</div> | ||
<div className="flex-col-div"> | ||
{showPinButton && ( | ||
<Popup | ||
content={<span>Add to your Pinned Projects</span>} | ||
trigger={ | ||
<Button | ||
color="blue" | ||
onClick={handlePinClick} | ||
icon | ||
circular | ||
size="small" | ||
> | ||
<Icon name="pin" /> | ||
</Button> | ||
} | ||
position="top center" | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
<div className="flex-row-div"> | ||
<div className="project-card-progress-container"> | ||
<ProjectProgressBar | ||
progress={project.currentProgress || 0} | ||
type="progress" | ||
showPercent={false} | ||
/> | ||
</div> | ||
<div className="project-card-progress-container"> | ||
<ProjectProgressBar | ||
progress={project.peerProgress || 0} | ||
type="peer" | ||
showPercent={false} | ||
/> | ||
</div> | ||
<div className="project-card-progress-container"> | ||
<ProjectProgressBar | ||
progress={project.a11yProgress || 0} | ||
type="a11y" | ||
showPercent={false} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default ProjectCard; |
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
Oops, something went wrong.