From e0d7d565bc58d0c4176094ec38defa959f5c202a Mon Sep 17 00:00:00 2001 From: soumitradev Date: Fri, 5 Jan 2024 14:28:37 +0530 Subject: [PATCH] feat: make edit page responsive --- frontend/src/EditTimetable.tsx | 141 ++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 45 deletions(-) diff --git a/frontend/src/EditTimetable.tsx b/frontend/src/EditTimetable.tsx index ac6b4599..be577230 100644 --- a/frontend/src/EditTimetable.tsx +++ b/frontend/src/EditTimetable.tsx @@ -24,6 +24,7 @@ import { GripVertical, Send, Trash, + Menu, } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; import { z } from "zod"; @@ -52,6 +53,11 @@ import { Badge } from "./components/ui/badge"; import { Button } from "./components/ui/button"; import { toast, useToast } from "./components/ui/use-toast"; import { router } from "./main"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "./components/ui/popover"; const fetchTimetable = async (timetableId: string) => { const response = await axios.get>( @@ -641,6 +647,16 @@ function EditTimetable() { [currentCourseID], ); + const [screenIsLarge, setScreenIsLarge] = useState( + window.matchMedia("(min-width: 1024px)").matches, + ); + + useEffect(() => { + window + .matchMedia("(min-width: 1024px)") + .addEventListener("change", (e) => setScreenIsLarge(e.matches)); + }, []); + const handleMissingCDCClick = (courseId: string) => { setCurrentTab("CDCs"); if (courseId === "") { @@ -759,12 +775,14 @@ function EditTimetable() { return ( <> {!isSpinner ? ( -
+
-

{timetable.name}

- +

+ {timetable.name} +

+

{timetable.acadYear} @@ -774,8 +792,8 @@ function EditTimetable() { {`${timetable.year}-${timetable.semester}`}

- -

Last Updated:

+ +

Last Updated:

{new Date(timetable.lastUpdated).toLocaleString()}

@@ -790,7 +808,7 @@ function EditTimetable() { className="hover:bg-slate-700 transition duration-200 ease-in-out" >
- +
@@ -844,22 +862,24 @@ function EditTimetable() { )} - - - - - -

- Make timetable {isVertical ? "horizontal" : "vertical"} -

-
-
+ {screenIsLarge && ( + + + + + +

+ Make timetable {isVertical ? "horizontal" : "vertical"} +

+
+
+ )} @@ -892,7 +912,7 @@ function EditTimetable() { variant="ghost" className="rounded-full p-3 hover:bg-destructive/90 hover:text-destructive-foreground" > - + @@ -1017,28 +1037,59 @@ function EditTimetable() {
-
- +
+ {screenIsLarge ? ( + + ) : ( + + + + + + + + + )} console.log(e)} handleUnitDelete={(e) => {