@@ -19,6 +19,7 @@ import ClockIcon from "@/app/conf/_design-system/pixelarticons/clock.svg?svgr"
19
19
20
20
import { getEventTitle } from "../../utils"
21
21
import { CalendarIcon } from "@/app/conf/_design-system/pixelarticons/calendar-icon"
22
+ import { formatBlockTime } from "./format-block-time"
22
23
23
24
function isString ( x : unknown ) : x is string {
24
25
return Object . prototype . toString . call ( x ) === "[object String]"
@@ -29,11 +30,13 @@ export function ScheduleSessionCard({
29
30
year,
30
31
eventsColors,
31
32
blockEnd,
33
+ durationVisible,
32
34
} : {
33
35
session : ScheduleSession
34
36
year : `202${number } `
35
37
eventsColors : Record < string , string >
36
38
blockEnd : Date
39
+ durationVisible : boolean
37
40
} ) {
38
41
let eventType = session . event_type
39
42
@@ -139,17 +142,7 @@ export function ScheduleSessionCard({
139
142
{ session . venue }
140
143
</ span >
141
144
) }
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
- ) }
145
+ { durationVisible && < SessionDuration session = { session } /> }
153
146
< AddToCalendarLink
154
147
eventTitle = { eventTitle }
155
148
session = { session }
@@ -164,6 +157,29 @@ export function ScheduleSessionCard({
164
157
)
165
158
}
166
159
160
+ function SessionDuration ( {
161
+ session,
162
+ } : {
163
+ session : ScheduleSession
164
+ } ) : React . ReactNode {
165
+ const durationMs =
166
+ new Date ( session . event_end ) . getTime ( ) -
167
+ new Date ( session . event_start ) . getTime ( )
168
+
169
+ // if a session is longer than 3 hourse, we show the time range
170
+ const formattedTime =
171
+ durationMs > 1000 * 60 * 60 * 3
172
+ ? formatBlockTime ( session . event_start , new Date ( session . event_end ) )
173
+ : `${ Math . round ( durationMs / ( 1000 * 60 ) ) } min`
174
+
175
+ return (
176
+ < span className = "typography-body-xs flex items-center gap-0.5" >
177
+ < ClockIcon className = "size-4 text-pri-base [@container(width<240px)]:hidden" />
178
+ { formattedTime }
179
+ </ span >
180
+ )
181
+ }
182
+
167
183
function AddToCalendarLink ( {
168
184
eventTitle,
169
185
session,
0 commit comments