From 0d523c5403d4c25af95b112279e2e5e36d4d2bce Mon Sep 17 00:00:00 2001 From: Antoine Phan Date: Mon, 13 Oct 2025 21:38:46 -0400 Subject: [PATCH] Update the Office Hour Calendar look Shoutout to Curosr for the implementation --- src/components/officehour/OHBlock.svelte | 63 ++++++ src/components/officehour/OHSchedule.svelte | 225 +++++++++++++++++--- 2 files changed, 253 insertions(+), 35 deletions(-) create mode 100644 src/components/officehour/OHBlock.svelte diff --git a/src/components/officehour/OHBlock.svelte b/src/components/officehour/OHBlock.svelte new file mode 100644 index 0000000..e73d0df --- /dev/null +++ b/src/components/officehour/OHBlock.svelte @@ -0,0 +1,63 @@ + + +
+ {#if !hideTime} +

+ {officeHour.startTime} - {officeHour.endTime} +

+ {/if} + +

+ {officeHour.member.name.split(' ')[0]} +

+ +

+ {displayPosition} +

+
+ diff --git a/src/components/officehour/OHSchedule.svelte b/src/components/officehour/OHSchedule.svelte index 6d3ce99..c4aa0e3 100644 --- a/src/components/officehour/OHSchedule.svelte +++ b/src/components/officehour/OHSchedule.svelte @@ -1,44 +1,199 @@ -
- {#each ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] as day} -
-

{day}

- {#each sortedOHs.filter((OH) => OH.day == day) as OH} -
-

- {OH.startTime} - {OH.endTime} -

+
+
+ +
+
Time
+ {#each DAYS as day} +
+ {day} +
+ {/each} +
-

- {OH.member.name.split(' ')[0]} -

-

{OH.member.position}

-
- {/each} -
- {/each} + +
+ {#each DAYS as day, dayIndex} + {@const segments = getSegmentsForDay(day)} + + + {#if dayIndex === 0} +
+ {#each timeSlots as timeSlot} + {@const isHourMark = timeSlot % 60 === 0} +
+ {#if isHourMark}{formatTime(timeSlot)}{/if} +
+ {/each} +
+ {/if} + + +
+ + {#each timeSlots as timeSlot, idx} + {@const isHourMark = timeSlot % 60 === 0} +
+ {/each} + + + {#each segments as segment} + {@const startIndex = timeSlots.findIndex(ts => ts >= segment.startSlot)} + {@const duration = segment.endSlot - segment.startSlot} + {@const heightPx = (duration / SLOT_DURATION) * SLOT_HEIGHT} + {@const isShortBlock = duration <= SLOT_DURATION} + +
+ {#each segment.ohs as oh} +
+
+

+ {oh.member.name.split(' ')[0]} +

+ {#if !isShortBlock} +

+ {shortenPosition(oh.member.position)} +

+ {/if} +
+
+ {/each} +
+ {/each} +
+ {/each} +
+
\ No newline at end of file