Skip to content

Commit

Permalink
feat: Manage
Browse files Browse the repository at this point in the history
  • Loading branch information
mathhulk committed Jun 9, 2024
1 parent d9ed10a commit d781078
Show file tree
Hide file tree
Showing 30 changed files with 527 additions and 517 deletions.
20 changes: 14 additions & 6 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import Catalog from "@/app/Catalog";
import Explore from "@/app/Explore";
import Landing from "@/app/Landing";
import Plan from "@/app/Plan";
import Schedule from "@/app/Schedule";
import Compare from "@/app/Schedule/Compare";
import Manage from "@/app/Schedule/Manage";
import Schedules from "@/app/Schedules";
import Compare from "@/app/Schedules/Compare";
import AccountProvider from "@/components/AccountProvider";
import Layout from "@/components/Layout";

import Schedule from "./app/Schedule";

const router = createBrowserRouter([
{
element: <Layout header={false} footer={false} />,
Expand Down Expand Up @@ -42,10 +44,16 @@ const router = createBrowserRouter([
{
element: <Schedule />,
path: "schedules/:scheduleId",
},
{
element: <Compare />,
path: "schedules/compare/:leftScheduleId?/:rightScheduleId?",
children: [
{
element: <Manage />,
index: true,
},
{
element: <Compare />,
path: "compare/:comparedScheduleId?",
},
],
},
],
},
Expand Down
50 changes: 0 additions & 50 deletions frontend/src/app/Schedule/Calendar/Event/Event.module.scss

This file was deleted.

61 changes: 0 additions & 61 deletions frontend/src/app/Schedule/Calendar/Event/index.tsx

This file was deleted.

101 changes: 101 additions & 0 deletions frontend/src/app/Schedule/Compare/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { useEffect, useRef, useState } from "react";

import { DataTransferBoth, Xmark } from "iconoir-react";
import { Link, useOutletContext } from "react-router-dom";

import IconButton from "@/components/IconButton";
import Week from "@/components/Week";

import { ScheduleContextType } from "../schedule";
import styles from "./Compare.module.scss";

export default function Compare() {
const { selectedSections } = useOutletContext<ScheduleContextType>();

const [y, setY] = useState<number | null>(null);
const leftRef = useRef<HTMLDivElement>(null);
const rightRef = useRef<HTMLDivElement>(null);
const [current, setCurrent] = useState<number | null>(null);

useEffect(() => {
if (!leftRef.current || !rightRef.current) return;

const left = leftRef.current;
const right = rightRef.current;

const handleScroll = (left?: boolean) => {
if (!leftRef.current || !rightRef.current) return;

if (left) {
if (current === 1) return;

rightRef.current.scrollTo({
top: leftRef.current.scrollTop,
left: leftRef.current.scrollLeft,
});

return;
}

if (current === 0) return;

leftRef.current.scrollTo({
top: rightRef.current.scrollTop,
left: rightRef.current.scrollLeft,
});
};

const handleLeftScroll = () => handleScroll(true);
left.addEventListener("scroll", handleLeftScroll);

const handleRightScroll = () => handleScroll();
right.addEventListener("scroll", handleRightScroll);

return () => {
right.removeEventListener("scroll", handleLeftScroll);
left.removeEventListener("scroll", handleRightScroll);
};
}, [current]);

return (
<div className={styles.root}>
<div className={styles.header}>
<div className={styles.group}>
<p className={styles.heading}>Untitled Spring 2024 schedule</p>
<p className={styles.paragraph}>Spring 2024</p>
</div>
<div className={styles.group}>
<p className={styles.heading}>No schedule selected</p>
<IconButton>
<DataTransferBoth />
</IconButton>
<IconButton as={Link} to="../">
<Xmark />
</IconButton>
</div>
</div>
<div className={styles.body}>
<div
className={styles.view}
ref={leftRef}
onMouseEnter={() => setCurrent(0)}
onMouseLeave={() =>
setCurrent((previous) => (previous === 0 ? null : previous))
}
>
<Week selectedSections={selectedSections} y={y} updateY={setY} />
</div>
<div
className={styles.view}
ref={rightRef}
onMouseEnter={() => setCurrent(1)}
onMouseLeave={() =>
setCurrent((previous) => (previous === 1 ? null : previous))
}
>
<Week selectedSections={[]} y={y} updateY={setY} />
</div>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,47 @@

.header {
display: flex;
flex-direction: column;
border-bottom: 1px solid var(--border-color);
position: sticky;
top: 0;
background-color: var(--background-color);
z-index: 1;
font-size: 12px;
color: var(--label-color);
line-height: 1;
z-index: 2;

.legend {
display: flex;
padding: 0 12px;
height: 32px;
gap: 12px;
align-items: center;
background-color: var(--slate-100);
border-bottom: 1px solid var(--border-color);
color: var(--paragraph-color);

.timezone {
margin-left: auto;
}

.category {
display: flex;
gap: 8px;
align-items: center;
}
}

.week {
display: grid;
grid-template-columns: repeat(7, 1fr);
color: var(--label-color);
flex-grow: 1;

.day {
height: 32px;
display: flex;
align-items: center;
justify-content: center;
display: grid;
place-items: center;

&:not(:last-child) {
border-right: 1px solid var(--border-color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,47 @@
gap: 8px;
height: 24px;
white-space: nowrap;
color: white;

&:not(.exam) {
border: 1px dashed var(--color);
}

&.exam {
background-color: var(--color);

.time {
color: rgb(255 255 255 / 75%);
}

.course {
color: white;
}
}

&.active {
opacity: 0.5;
}

.time {
color: rgb(255 255 255 / 75%);
font-size: 8px;
color: var(--label-color);
}

.course {
color: white;
font-weight: 500;
text-overflow: ellipsis;
overflow: hidden;
color: var(--color);
}
}

.date {
display: flex;

.month {
color: var(--heading-color);
font-weight: 500;
}
color: var(--label-color);

.number {
margin-left: auto;
color: var(--label-color);
}
}
}
Loading

0 comments on commit d781078

Please sign in to comment.