Skip to content

Commit 68d9ecf

Browse files
committed
Show time range for very long sessions
1 parent b600a58 commit 68d9ecf

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/app/conf/2025/schedule/_components/schedule-session-card.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import ClockIcon from "@/app/conf/_design-system/pixelarticons/clock.svg?svgr"
1919

2020
import { getEventTitle } from "../../utils"
2121
import { CalendarIcon } from "@/app/conf/_design-system/pixelarticons/calendar-icon"
22+
import { formatBlockTime } from "./format-block-time"
2223

2324
function isString(x: unknown): x is string {
2425
return Object.prototype.toString.call(x) === "[object String]"
@@ -139,17 +140,10 @@ export function ScheduleSessionCard({
139140
{session.venue}
140141
</span>
141142
)}
142-
{blockTimeFraction < 1 && (
143-
<span className="typography-body-xs flex items-center gap-0.5">
144-
<ClockIcon className="size-4 text-pri-base [@container(width<240px)]:hidden" />
145-
{Math.round(
146-
(new Date(session.event_end).getTime() -
147-
new Date(session.event_start).getTime()) /
148-
(1000 * 60),
149-
)}{" "}
150-
min
151-
</span>
152-
)}
143+
<SessionDuration
144+
session={session}
145+
blockTimeFraction={blockTimeFraction}
146+
/>
153147
<AddToCalendarLink
154148
eventTitle={eventTitle}
155149
session={session}
@@ -164,6 +158,33 @@ export function ScheduleSessionCard({
164158
)
165159
}
166160

161+
function SessionDuration({
162+
session,
163+
blockTimeFraction,
164+
}: {
165+
session: ScheduleSession
166+
blockTimeFraction: number
167+
}): React.ReactNode {
168+
if (blockTimeFraction >= 1) return null
169+
170+
const durationMs =
171+
new Date(session.event_end).getTime() -
172+
new Date(session.event_start).getTime()
173+
174+
// if a session is longer than 3 hourse, we show the time range
175+
const formattedTime =
176+
durationMs > 1000 * 60 * 60 * 3
177+
? formatBlockTime(session.event_start, new Date(session.event_end))
178+
: `${Math.round(durationMs / (1000 * 60))} min`
179+
180+
return (
181+
<span className="typography-body-xs flex items-center gap-0.5">
182+
<ClockIcon className="size-4 text-pri-base [@container(width<240px)]:hidden" />
183+
{formattedTime}
184+
</span>
185+
)
186+
}
187+
167188
function AddToCalendarLink({
168189
eventTitle,
169190
session,

0 commit comments

Comments
 (0)