diff --git a/src/shared/types/CourseMeeting.ts b/src/shared/types/CourseMeeting.ts index 2e8339f8..62c49f02 100644 --- a/src/shared/types/CourseMeeting.ts +++ b/src/shared/types/CourseMeeting.ts @@ -2,6 +2,7 @@ import { Serialized } from 'chrome-extension-toolkit'; /** * a map of the days of the week that a class is taught, and the corresponding abbreviation + * Don't modify the keys */ export const DAY_MAP = { M: 'Monday', diff --git a/src/stories/components/CalendarCourseCell.stories.tsx b/src/stories/components/CalendarCourseCell.stories.tsx index 647a766d..8203d74a 100644 --- a/src/stories/components/CalendarCourseCell.stories.tsx +++ b/src/stories/components/CalendarCourseCell.stories.tsx @@ -45,7 +45,7 @@ export const Default: Story = { schedule: new CourseSchedule({ meetings: [ new CourseMeeting({ - days: [DAY_MAP.M, DAY_MAP.W, DAY_MAP.F], + days: [DAY_MAP.MON, DAY_MAP.WED, DAY_MAP.FRI], startTime: 480, endTime: 570, location: { diff --git a/src/stories/components/CalendarGridCell.stories.tsx b/src/stories/components/CalendarGridCell.stories.tsx new file mode 100644 index 00000000..20ac21d7 --- /dev/null +++ b/src/stories/components/CalendarGridCell.stories.tsx @@ -0,0 +1,19 @@ +// Calendar.stories.tsx +import React from 'react'; +import CalendarCell from '@views/components/common/CalendarGridCell/CalendarGridCell'; +import type { Meta, StoryObj } from '@storybook/react'; + +const meta = { + title: 'Components/Common/CalendarGridCell', + component: CalendarCell, + parameters: { + // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout + layout: 'centered', + tags: ['autodocs'], + } +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = {}; \ No newline at end of file diff --git a/src/views/components/common/CalendarGrid/CalendarGrid.module.scss b/src/views/components/common/CalendarGrid/CalendarGrid.module.scss deleted file mode 100644 index a2e208a4..00000000 --- a/src/views/components/common/CalendarGrid/CalendarGrid.module.scss +++ /dev/null @@ -1,94 +0,0 @@ -@use 'sass:color'; -@use 'src/views/styles/colors.module.scss'; - -.dayLabelContainer { - display: flex; - flex-direction: row; - height: 13px; - min-width: 40px; - min-height: 13px; - padding-bottom: 15px; - justify-content: center; - align-items: center; - gap: 10px; - flex: 1 0 0; -} - -.calendarGrid { - display: grid; - grid-template-columns: repeat(5, 1fr); - grid-template-rows: repeat(13, 1fr); -} - -.calendarRow { - display: flex; -} - -.calendar { - // display: grid; - // grid-template-columns: auto repeat(5, 1fr); - gap: 10px; -} - -.day { - gap: 5px; - color: colors.$burnt_orange; - text-align: center; - font-size: 14.22px; - font-style: normal; - font-weight: 500; - line-height: normal; -} - -.timeAndGrid { - display: flex; -} - -.timeColumn { - display: flex; - min-height: 573px; - flex-direction: column; - justify-content: space-between; - align-items: flex-start; - flex: 1 0 0; - border-radius: var(--border-radius-none, 0px); -} - -.timeBlock { - display: flex; - width: 50px; - height: 40.279px; - min-width: 50px; - max-width: 50px; - min-height: 40px; - flex-direction: column; - align-items: flex-end; - - .timeLabelContainer { - display: flex; - max-height: 20px; - flex-direction: column; - align-items: flex-end; - gap: 17px; - flex: 1 0 0; - align-self: stretch; - border-radius: var(--border-radius-none, 0px); - } - - p { - color: #1A2024; - text-align: left; - height: 6.6px; - align-self: stretch; - margin-top: 0; - margin-bottom: 0; - - /* Type scale/small */ - font-family: "Roboto Flex"; - font-size: 14.22px; - font-style: normal; - font-weight: 500; - line-height: normal; - } -} - diff --git a/src/views/components/common/CalendarGrid/CalendarGrid.tsx b/src/views/components/common/CalendarGrid/CalendarGrid.tsx index 4b90edf1..4c0ed875 100644 --- a/src/views/components/common/CalendarGrid/CalendarGrid.tsx +++ b/src/views/components/common/CalendarGrid/CalendarGrid.tsx @@ -1,15 +1,23 @@ import React from 'react'; -import styles from './CalendarGrid.module.scss'; import CalendarCell from '../CalendarGridCell/CalendarGridCell'; import { DAY_MAP } from 'src/shared/types/CourseMeeting'; -const daysOfWeek = Object.values(DAY_MAP).filter(d => d != "Saturday" && d != "Sunday") +const daysOfWeek = Object.keys(DAY_MAP).filter(key => !['S', 'SU'].includes(key)); const hoursOfDay = Array.from({ length: 14 }, (_, index) => index + 8); -const grid = Array.from({ length: 5 }, () => - Array.from({ length: 13 }, (_, columnIndex) => ( - - )) -); +const grid = []; +for (let i = 0; i < 13; i++) { + const row = []; + let hour = hoursOfDay[i]; + row.push( +
+
+

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

+
+
+ ); + row.push(Array.from({ length: 5 }, (_, j) => )); + grid.push(row); +} /** * Grid of CalendarGridCell components forming the user's course schedule calendar view @@ -17,36 +25,34 @@ const grid = Array.from({ length: 5 }, () => */ const Calendar: React.FC = (props) => { return ( -
-
- {/* Empty cell in the top-left corner */} -
- {/* Displaying day labels */} - {daysOfWeek.map(day => ( -
- {day} -
- ))} +
+
{/* Displaying the rest of the calendar */} -
-
+
+ {/*
+
{hoursOfDay.map((hour) => ( -
-
-

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

+
+
+

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

))} -
-
- {grid.map((row, rowIndex) => ( - row +
*/} +
+ {/* Displaying day labels */} +
+ {daysOfWeek.map(day => ( +
+ {day} +
))} + {grid.map((row, rowIndex) => (row))}
) }; -export default Calendar; \ No newline at end of file +export default Calendar; diff --git a/src/views/components/common/CalendarGridCell/CalendarGridCell.module.scss b/src/views/components/common/CalendarGridCell/CalendarGridCell.module.scss deleted file mode 100644 index 2199d866..00000000 --- a/src/views/components/common/CalendarGridCell/CalendarGridCell.module.scss +++ /dev/null @@ -1,18 +0,0 @@ -.calendarCell { - display: flex; - width: 165px; - height: 52.231px; - min-width: 45px; - min-height: 40px; - flex-direction: column; - justify-content: center; - align-items: flex-start; - border: 1px solid #DADCE0; -} - -.hourLine { - width: 165px; - height: 1px; - border-radius: var(--border-radius-none, 0px); - background: rgba(218, 220, 224, 0.25); -} \ No newline at end of file diff --git a/src/views/components/common/CalendarGridCell/CalendarGridCell.tsx b/src/views/components/common/CalendarGridCell/CalendarGridCell.tsx index cdc2c1b1..ec678306 100644 --- a/src/views/components/common/CalendarGridCell/CalendarGridCell.tsx +++ b/src/views/components/common/CalendarGridCell/CalendarGridCell.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import styles from './CalendarGridCell.module.scss'; /** * Component representing each 1 hour time block of a calendar @@ -7,10 +6,8 @@ import styles from './CalendarGridCell.module.scss'; */ const CalendarCell: React.FC = (props) => { return ( -
-
- -
+
+
); };