diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx index 2ce9001..7e8d033 100644 --- a/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarMonth.tsx @@ -1,14 +1,12 @@ "use client"; -import { CalendarMonthModel, getWeekNumber } from "./calendarMonthUtils"; +import { CalendarMonthModel } from "./calendarMonthUtils"; import { DayOfWeek } from "@/models/local/localCourse"; -import Day from "./day/Day"; import { Expandable } from "@/components/Expandable"; -import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; -import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; +import { CalendarWeek } from "./CalendarWeek"; export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => { const weekInMilliseconds = 604_800_000; - const four_days_in_milliseconds = 345_600_000 + const four_days_in_milliseconds = 345_600_000; const isInPast = new Date(month.year, month.month, 1) < new Date(Date.now() - four_days_in_milliseconds); @@ -53,34 +51,3 @@ export const CalendarMonth = ({ month }: { month: CalendarMonthModel }) => { ); }; - -function CalendarWeek({ - week, - monthNumber, -}: { - week: string[]; //date strings - monthNumber: number; -}) { - const { data: settings } = useLocalCourseSettingsQuery(); - const startDate = getDateFromStringOrThrow( - settings.startDate, - "week calculation start date" - ); - const firstDateString = getDateFromStringOrThrow( - week[0], - "week calculation first day of week" - ); - const weekNumber = getWeekNumber(startDate, firstDateString); - return ( -
-
- {weekNumber.toString().padStart(2, "0")} -
-
- {week.map((day, dayIndex) => ( - - ))} -
-
- ); -} diff --git a/nextjs/src/app/course/[courseName]/calendar/CalendarWeek.tsx b/nextjs/src/app/course/[courseName]/calendar/CalendarWeek.tsx new file mode 100644 index 0000000..bb34262 --- /dev/null +++ b/nextjs/src/app/course/[courseName]/calendar/CalendarWeek.tsx @@ -0,0 +1,36 @@ +"use client"; +import { useLocalCourseSettingsQuery } from "@/hooks/localCourse/localCoursesHooks"; +import { getDateFromStringOrThrow } from "@/models/local/timeUtils"; +import { getWeekNumber } from "./calendarMonthUtils"; +import Day from "./day/Day"; + +export function CalendarWeek({ + week, + monthNumber, +}: { + week: string[]; //date strings + monthNumber: number; +}) { + const { data: settings } = useLocalCourseSettingsQuery(); + const startDate = getDateFromStringOrThrow( + settings.startDate, + "week calculation start date" + ); + const firstDateString = getDateFromStringOrThrow( + week[0], + "week calculation first day of week" + ); + const weekNumber = getWeekNumber(startDate, firstDateString); + return ( +
+
+ {weekNumber.toString().padStart(2, "0")} +
+
+ {week.map((day, dayIndex) => ( + + ))} +
+
+ ); +} diff --git a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx index a48eca5..879a3f5 100644 --- a/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx +++ b/nextjs/src/app/course/[courseName]/calendar/day/Day.tsx @@ -43,15 +43,17 @@ export default function Day({ day, month }: { day: string; month: number }) { const meetingClasses = classOnThisDay && isInSemester ? " bg-slate-900 " : " "; - const monthClass = isInSameMonth - ? isToday - ? " border border-blue-700 shadow-[0_0px_10px_0px] shadow-blue-500/50 " - : " border border-slate-700 " + + const todayClasses = isToday + ? " border border-blue-700 shadow-[0_0px_10px_0px] shadow-blue-500/50 " : " "; + const monthClass = + isInSameMonth && !isToday ? " border border-slate-700 " : " "; + return (
itemDropOnDay(e, day)} onDragOver={(e) => e.preventDefault()} >