From 043e563960423feb038c0ae713d22979783f13e5 Mon Sep 17 00:00:00 2001 From: Bl20052005 <88120481+Bl20052005@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:10:37 -0800 Subject: [PATCH] some time fixes --- .../(main)/schedule/components/EventCard.tsx | 43 +++++++++++++++++-- .../schedule/components/EventSidebar.tsx | 23 ++++++++-- .../(main)/schedule/sections/SchedulePage.tsx | 7 +-- .../schedule/sections/ScheduleScroll.tsx | 26 ++++++++++- 4 files changed, 86 insertions(+), 13 deletions(-) diff --git a/apps/site/src/app/(main)/schedule/components/EventCard.tsx b/apps/site/src/app/(main)/schedule/components/EventCard.tsx index daeb305c..b80aa3b4 100644 --- a/apps/site/src/app/(main)/schedule/components/EventCard.tsx +++ b/apps/site/src/app/(main)/schedule/components/EventCard.tsx @@ -1,7 +1,14 @@ +import { SwordsIcon } from "lucide-react"; import EventProps from "../EventProps"; +import { motion } from "framer-motion"; + import getTimeAndDates from "@/lib/utils/getTimeAndDates"; +interface EventCardProps extends EventProps { + isHappening: boolean; +} + export default function EventCard({ title, location, @@ -11,14 +18,38 @@ export default function EventCard({ organization, hosts, description, -}: EventProps) { + isHappening, +}: EventCardProps) { return ( -
+
{title ? ( <>
-

{title}

+
+

+ {title} +

+ {isHappening && ( + + + + )} +

{getTimeAndDates(startTime).day}

@@ -36,7 +67,11 @@ export default function EventCard({ }`}

-
+
{hosts && (
{`Hosted By: ${hosts?.join( diff --git a/apps/site/src/app/(main)/schedule/components/EventSidebar.tsx b/apps/site/src/app/(main)/schedule/components/EventSidebar.tsx index 6f80b1a6..220d7c77 100644 --- a/apps/site/src/app/(main)/schedule/components/EventSidebar.tsx +++ b/apps/site/src/app/(main)/schedule/components/EventSidebar.tsx @@ -86,7 +86,10 @@ export default function EventSidebar({
{events.map((event) => { return ( -
+
{ @@ -98,7 +101,10 @@ export default function EventSidebar({ title={event.title} startTime={event.startTime} endTime={event.endTime} - isHappening={currentTitle === event.title} + isHappening={ + currentTitle === + `${event.title}${event.startTime.toISOString()}` + } />
); @@ -106,8 +112,17 @@ export default function EventSidebar({ {events.map((event) => { return ( -
- +
+
); })} diff --git a/apps/site/src/app/(main)/schedule/sections/SchedulePage.tsx b/apps/site/src/app/(main)/schedule/sections/SchedulePage.tsx index aa2bae9a..eb2f152b 100644 --- a/apps/site/src/app/(main)/schedule/sections/SchedulePage.tsx +++ b/apps/site/src/app/(main)/schedule/sections/SchedulePage.tsx @@ -37,7 +37,7 @@ export default function SchedulePage({ schedule }: ScheduleProps) { ); const [selectedEventDay, setSelectedEventDay] = useState( - getEventDate(new Date()), + getEventDate(new Date(Date.now())), ); function getEventDate(date: Date) { @@ -51,7 +51,7 @@ export default function SchedulePage({ schedule }: ScheduleProps) { // ); // } - const firstDay = new Date(2025, 1, 24); // hackathon start day + const firstDay = new Date(2025, 0, 24); // hackathon start day const allDays = schedule .map((event) => (event ? event[0].startTime : new Date(0))) @@ -101,7 +101,7 @@ export default function SchedulePage({ schedule }: ScheduleProps) { ? selectedScheduleEvents : currentScheduleEvents } - currentTitle={currentEvent?.title} + currentTitle={`${currentEvent?.title}${currentEvent?.startTime.toISOString()}`} setSelectedEvent={setSelectedEvent} /> {selectedEvent ? ( @@ -109,6 +109,7 @@ export default function SchedulePage({ schedule }: ScheduleProps) {
diff --git a/apps/site/src/app/(main)/schedule/sections/ScheduleScroll.tsx b/apps/site/src/app/(main)/schedule/sections/ScheduleScroll.tsx index 0bc2323f..8150c286 100644 --- a/apps/site/src/app/(main)/schedule/sections/ScheduleScroll.tsx +++ b/apps/site/src/app/(main)/schedule/sections/ScheduleScroll.tsx @@ -2,7 +2,7 @@ import clsx from "clsx"; import styles from "./ScheduleScroll.module.scss"; -import { useRef } from "react"; +import { useEffect, useRef } from "react"; import { ChevronLeft, ChevronRight } from "lucide-react"; import getTimeAndDates from "@/lib/utils/getTimeAndDates"; @@ -28,7 +28,7 @@ export default function ScheduleScroll({ }); } - function scrollDir(action: string) { + function getCurrentDateIndex() { let ind = 0; for (let i = 0; i < weekdays.length; i++) { if ( @@ -38,6 +38,28 @@ export default function ScheduleScroll({ ind = i; } + return ind; + } + + useEffect(() => { + const date = new Date(Date.now()); + const curDay = new Date( + date.getFullYear(), + date.getMonth(), + date.getDate(), + ); + let ind = 0; + for (let i = 0; i < weekdays.length; i++) { + if (curDay && weekdays[i].getTime() === curDay.getTime()) ind = i; + } + if (ind > 0) { + scrollTo(ind); + } + }, [weekdays]); + + function scrollDir(action: string) { + const ind = getCurrentDateIndex(); + if (action === "left") { const nextIndex = (ind + (weekdays.length - 1)) % weekdays.length; scrollTo(nextIndex);