From 7479004a65c4220937d4ca1f70d6b68ece14f642 Mon Sep 17 00:00:00 2001 From: knownotunknown <78577376+knownotunknown@users.noreply.github.com> Date: Sat, 17 Feb 2024 16:59:34 -0600 Subject: [PATCH] Need to add sorting --- .../components/CalendarGrid.stories.tsx | 10 +-- src/stories/components/PopupMain.stories.tsx | 0 .../CalendarGrid/CalendarGrid.module.scss | 3 + .../common/CalendarGrid/CalendarGrid.tsx | 79 +++++++++++-------- 4 files changed, 52 insertions(+), 40 deletions(-) delete mode 100644 src/stories/components/PopupMain.stories.tsx diff --git a/src/stories/components/CalendarGrid.stories.tsx b/src/stories/components/CalendarGrid.stories.tsx index 4e5d1ff8..1d05426c 100644 --- a/src/stories/components/CalendarGrid.stories.tsx +++ b/src/stories/components/CalendarGrid.stories.tsx @@ -21,8 +21,8 @@ const testData: CalendarGridCourse[] = [ { calendarGridPoint: { dayIndex: 0, - startIndex: 1, - endIndex: 2, + startIndex: 4, + endIndex: 6, }, componentProps: { courseDeptAndInstr: 'Course 1', @@ -33,9 +33,9 @@ const testData: CalendarGridCourse[] = [ }, { calendarGridPoint: { - dayIndex: 1, - startIndex: 2, - endIndex: 3, + dayIndex: 4, + startIndex: 10, + endIndex: 20, }, componentProps: { courseDeptAndInstr: 'Course 2', diff --git a/src/stories/components/PopupMain.stories.tsx b/src/stories/components/PopupMain.stories.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/src/views/components/common/CalendarGrid/CalendarGrid.module.scss b/src/views/components/common/CalendarGrid/CalendarGrid.module.scss index 961b505e..f5af41dc 100644 --- a/src/views/components/common/CalendarGrid/CalendarGrid.module.scss +++ b/src/views/components/common/CalendarGrid/CalendarGrid.module.scss @@ -15,6 +15,7 @@ display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(13, 1fr); + position:absolute; } .calendarRow { @@ -26,6 +27,8 @@ flex-direction: column; gap: 10px; position: relative; // Ensuring that child elements can be positioned in relation to this. + min-width: 500px; + min-height: 500px; } .day { diff --git a/src/views/components/common/CalendarGrid/CalendarGrid.tsx b/src/views/components/common/CalendarGrid/CalendarGrid.tsx index 7c541813..e148d9bc 100644 --- a/src/views/components/common/CalendarGrid/CalendarGrid.tsx +++ b/src/views/components/common/CalendarGrid/CalendarGrid.tsx @@ -1,11 +1,12 @@ -import React from 'react'; +import React, { useState } from 'react'; import { DAY_MAP } from 'src/shared/types/CourseMeeting'; import { CalendarGridCourse } from 'src/views/hooks/useFlattenedCourseSchedule'; import CalendarCell from '../CalendarGridCell/CalendarGridCell'; import CalendarCourseCell from '../CalendarCourseCell/CalendarCourseCell'; import styles from './CalendarGrid.module.scss'; -import calIcon from 'src/assets/icons/cal.svg'; -import pngIcon from 'src/assets/icons/png.svg'; + +// import calIcon from 'src/assets/icons/cal.svg'; +// import pngIcon from 'src/assets/icons/png.svg'; const daysOfWeek = Object.keys(DAY_MAP).filter(key => !['S', 'SU'].includes(key)); const hoursOfDay = Array.from({ length: 14 }, (_, index) => index + 8); @@ -34,56 +35,64 @@ interface Props { * @param props */ function CalendarGrid({ courseCells, saturdayClass }: React.PropsWithChildren ): JSX.Element { + const [iterator, setIterator] = useState(0); return (
- {/* Displaying the rest of the calendar */} -
- {/*
-
- {hoursOfDay.map((hour) => ( -
-
-

{hour % 12 === 0 ? 12 : hour % 12} {hour < 12 ? 'AM' : 'PM'}

-
-
- ))} -
*/} -
+ {/* Displaying the rest of the calendar */} +
+ {/*
+
+ {hoursOfDay.map((hour) => ( +
+
+

{hour % 12 === 0 ? 12 : hour % 12} {hour < 12 ? 'AM' : 'PM'}

+
+
+ ))} +
*/} +
{/* Displaying day labels */}
- {daysOfWeek.map(day => ( -
+ {daysOfWeek.map((day, x) => ( +
{day}
))} - {grid.map(row => row)} + {grid.map((row, y) => ( +
+ {row.map((cell, x) => { + const shouldRenderChild = courseCells[iterator].calendarGridPoint && x === courseCells[iterator].calendarGridPoint.dayIndex && y === courseCells[iterator].calendarGridPoint.startIndex; + if (shouldRenderChild) { + setIterator((iterator) => iterator + 1); + } + return ( +
+ {cell} + {shouldRenderChild && } +
+ ); + })} +
+ ))}
- {courseCells.map((block: CalendarGridCourse) => ( -
- -
- ))} */} -
-
{/* First divider */} + + {/*
+
-
{/* Second divider */} +
-
+
*/}
); }