-
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.
Merge pull request #316 from pennlabs/revert-315-revert-313-feature/c…
…alender-frontend Revert "Revert "Calendar frontend""
- Loading branch information
Showing
31 changed files
with
4,366 additions
and
1,810 deletions.
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
Large diffs are not rendered by default.
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 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 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,3 +1,4 @@ | ||
from http.client import HTTPResponse | ||
import math | ||
import re | ||
from datetime import datetime, timedelta | ||
|
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,134 @@ | ||
import { Icon, Modal, SemanticICONS } from "semantic-ui-react"; | ||
import React from "react"; | ||
import Link from "next/link"; | ||
import { Occurrence, UserMembership } from "../../types"; | ||
import { dayNames, paramsToDays } from "./calendarUtils"; | ||
|
||
const IconTextBlock = (props: { | ||
iconName: SemanticICONS; | ||
children: React.JSX.Element; | ||
}) => { | ||
const { iconName, children } = props; | ||
|
||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Icon | ||
size="large" | ||
name={iconName} | ||
style={{ marginRight: "10px" }} | ||
/> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export const EventInfoModal = (props: { | ||
occurrence: Occurrence | null; | ||
membership: UserMembership | undefined; | ||
setOccurrence: (occurrence: Occurrence | null) => void; | ||
}) => { | ||
const { occurrence, membership, setOccurrence } = props; | ||
|
||
return ( | ||
<Modal | ||
size="tiny" | ||
open={occurrence !== null} | ||
onClose={() => setOccurrence(null)} | ||
> | ||
<Modal.Header> | ||
{`${membership?.course.department} ${membership?.course.courseCode} – ${occurrence?.title}`} | ||
<button | ||
type="button" | ||
style={{ | ||
float: "right", | ||
cursor: "pointer", | ||
background: "none", | ||
border: "none", | ||
}} | ||
onClick={() => setOccurrence(null)} | ||
> | ||
<i className="close icon" /> | ||
</button> | ||
</Modal.Header> | ||
<Modal.Content> | ||
<Modal.Description> | ||
<IconTextBlock iconName="clock outline"> | ||
<span> | ||
{occurrence?.start.toLocaleDateString("en-US", { | ||
weekday: "long", | ||
month: "long", | ||
day: "numeric", | ||
hour: "numeric", | ||
minute: "numeric", | ||
})}{" "} | ||
-{" "} | ||
{occurrence?.start.toDateString() === | ||
occurrence?.end.toDateString() | ||
? occurrence?.end.toLocaleTimeString("en-US", { | ||
hour: "numeric", | ||
minute: "numeric", | ||
}) | ||
: occurrence?.end.toLocaleDateString("en-US", { | ||
weekday: "long", | ||
month: "long", | ||
day: "numeric", | ||
hour: "numeric", | ||
minute: "numeric", | ||
})} | ||
{occurrence?.event.rule && ( | ||
<> | ||
<br /> | ||
Weekly on{" "} | ||
{paramsToDays( | ||
occurrence.event.rule.params, | ||
0 | ||
) | ||
.map((dayNum) => dayNames[dayNum]) | ||
.join(", ")} | ||
</> | ||
)} | ||
</span> | ||
</IconTextBlock> | ||
{occurrence?.description && ( | ||
<> | ||
<br /> | ||
<IconTextBlock iconName="list"> | ||
<span style={{ whiteSpace: "pre-wrap" }}> | ||
{occurrence.description} | ||
</span> | ||
</IconTextBlock> | ||
</> | ||
)} | ||
{occurrence?.location && ( | ||
<> | ||
<br /> | ||
<IconTextBlock iconName="map marker alternate"> | ||
<span style={{ whiteSpace: "pre-wrap" }}> | ||
{occurrence.location} | ||
</span> | ||
</IconTextBlock> | ||
</> | ||
)} | ||
<> | ||
<br /> | ||
<IconTextBlock iconName="linkify"> | ||
<Link | ||
href="/courses/[course]" | ||
as={`/courses/${occurrence?.event.course_id}`} | ||
legacyBehavior | ||
> | ||
Go to queue | ||
</Link> | ||
</IconTextBlock> | ||
</> | ||
</Modal.Description> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
}; |
74 changes: 74 additions & 0 deletions
74
frontend/components/Calendar/DashboardCalendar/EventCard.tsx
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,74 @@ | ||
import { Grid, Header, Segment, SemanticCOLORS } from "semantic-ui-react"; | ||
import { useState } from "react"; | ||
import { Course, Occurrence } from "../../../types"; | ||
|
||
interface EventCardProps { | ||
occurrence: Occurrence; | ||
course: Course; | ||
color: SemanticCOLORS; | ||
onClick: () => void; | ||
} | ||
|
||
const EventCard = (props: EventCardProps) => { | ||
const { occurrence, course, color, onClick } = props; | ||
|
||
const startDate = new Date(occurrence.start); | ||
const endDate = new Date(occurrence.end); | ||
|
||
const [hover, setHover] = useState(false); | ||
|
||
const formatDate = (date: Date) => | ||
date.toLocaleString("en-US", { | ||
hour: "numeric", | ||
minute: "numeric", | ||
hour12: true, | ||
}); | ||
|
||
return ( | ||
<Segment | ||
color={color as SemanticCOLORS} | ||
style={{ | ||
cursor: "pointer", | ||
title: occurrence.description, | ||
}} | ||
raised={hover} | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
onClick={onClick} | ||
> | ||
{/* TODO: get rid of hardcoded width */} | ||
<Grid style={{ width: "240px" }}> | ||
<Grid.Column width={10}> | ||
<Header | ||
as="h4" | ||
style={{ | ||
whiteSpace: "nowrap", | ||
textOverflow: "ellipsis", | ||
overflow: "hidden", | ||
}} | ||
> | ||
{`${course.department} ${course.courseCode}`} | ||
<Header.Subheader | ||
style={{ | ||
whiteSpace: "nowrap", | ||
textOverflow: "ellipsis", | ||
overflow: "hidden", | ||
}} | ||
> | ||
{occurrence.title} | ||
</Header.Subheader> | ||
</Header> | ||
</Grid.Column> | ||
<Grid.Column width={6} textAlign="right"> | ||
<Header as="h5"> | ||
{formatDate(startDate)} | ||
<br /> | ||
{formatDate(endDate)} | ||
</Header> | ||
</Grid.Column> | ||
</Grid> | ||
</Segment> | ||
); | ||
}; | ||
|
||
export default EventCard; |
Oops, something went wrong.