@@ -28,7 +28,7 @@ import { useIsInCall } from '../../composables/useIsInCall.js'
28
28
import { useStore } from ' ../../composables/useStore.js'
29
29
import { CONVERSATION } from ' ../../constants.ts'
30
30
import type { DashboardEventRoom } from ' ../../types/index.ts'
31
- import { formattedTime } from ' ../../utils/formattedTime.ts'
31
+ import { formattedTime , ONE_DAY_IN_MS } from ' ../../utils/formattedTime.ts'
32
32
33
33
const props = defineProps <{
34
34
eventRoom: DashboardEventRoom ,
@@ -57,17 +57,45 @@ const eventDateLabel = computed(() => {
57
57
}
58
58
const startDate = new Date (props .eventRoom .start * 1000 )
59
59
const endDate = new Date (props .eventRoom .end * 1000 )
60
- const startDateString = startDate .toLocaleString (getCanonicalLocale (), { hour: ' 2-digit' , minute: ' 2-digit' })
61
- const endDateString = endDate .toLocaleString (getCanonicalLocale (), { hour: ' 2-digit' , minute: ' 2-digit' })
62
- const dateString = isToday .value
63
- ? t (' spreed' , ' Today' )
64
- : moment (startDate ).calendar (null , {
65
- nextDay: ' [Tomorrow]' ,
66
- nextWeek: ' dddd' ,
67
- sameElse: ' dddd'
68
- })
69
- // FIXME should be a translated string
70
- return ` ${dateString } ${startDateString } - ${endDateString } `
60
+ const isToday = startDate .toDateString () === new Date ().toDateString ()
61
+ const isTomorrow = startDate .toDateString () === new Date (Date .now () + ONE_DAY_IN_MS ).toDateString ()
62
+
63
+ let time
64
+ if (startDate .toDateString () === endDate .toDateString ()) {
65
+ if (isToday || isTomorrow ) {
66
+ // show the time only
67
+ const timeRange = Intl .DateTimeFormat (getCanonicalLocale (), {
68
+ hour: ' numeric' ,
69
+ minute: ' numeric' ,
70
+ }).formatRange (startDate , endDate )
71
+
72
+ const relativeFormatter = new Intl .RelativeTimeFormat (' en' , { numeric: ' auto' })
73
+
74
+ // TRANSLATORS: e.g. "Tomorrow 10:00 - 11:00"
75
+ time = t (' spreed' , ' {dayPrefix} {dateTime}' , {
76
+ dayPrefix: isToday ? relativeFormatter .format (0 , ' day' ) : relativeFormatter .format (1 , ' day' ),
77
+ dateTime: timeRange
78
+ })
79
+ } else {
80
+ time = Intl .DateTimeFormat (getCanonicalLocale (), {
81
+ weekday: ' long' ,
82
+ hour: ' numeric' ,
83
+ minute: ' numeric' ,
84
+ }).formatRange (startDate , endDate )
85
+ }
86
+ } else {
87
+ // show the month and the year as well
88
+ time = Intl .DateTimeFormat (getCanonicalLocale (), {
89
+ month: ' long' ,
90
+ year: ' numeric' ,
91
+ day: ' 2-digit' ,
92
+ hour: ' numeric' ,
93
+ minute: ' numeric' ,
94
+ }).formatRange (startDate , endDate )
95
+
96
+ }
97
+
98
+ return time
71
99
})
72
100
73
101
const hasAttachments = computed (() => {
@@ -107,24 +135,24 @@ function handleJoin({ call = false } = {}) {
107
135
'event-card--highlighted': isToday,
108
136
'event-card--in-call': hasCall,
109
137
}" >
110
- <span class =" title" >
138
+ <h4 class =" title" >
111
139
<span v-for =" calendar in props.eventRoom.calendars"
112
140
:key =" calendar.principalUri"
113
141
class =" calendar-badge"
114
142
:style =" { backgroundColor: calendar.calendarColor ?? usernameToColor(calendar.principalUri).color }" />
115
143
<span class =" title_text" >
116
144
{{ props.eventRoom.eventName }}
117
145
</span >
118
- </span >
146
+ </h4 >
119
147
<p class =" event-card__date secondary_text" >
120
- {{ eventDateLabel }}
148
+ < span > {{ eventDateLabel }}</ span >
121
149
<template v-if =" hasCall " >
122
150
<IconVideo :size =" 20" :fill-color =" '#E9322D'" />
123
151
<span >{{ elapsedTime }}</span >
124
152
</template >
125
153
</p >
126
154
<span class =" event-card__room secondary_text" >
127
- <span >
155
+ <span class = " event-card__room-prefix " >
128
156
{{ props.eventRoom.roomType === CONVERSATION.TYPE.ONE_TO_ONE ? t('spreed', 'With') : t('spreed', 'In') }}
129
157
</span >
130
158
<NcChip type =" tertiary"
@@ -160,7 +188,7 @@ function handleJoin({ call = false } = {}) {
160
188
<NcButton type =" tertiary"
161
189
@click =" handleJoin" >
162
190
<template #icon >
163
- <NcIconSvgWrapper :svg =" IconTalk" />
191
+ <NcIconSvgWrapper :svg =" IconTalk" :size = " 20 " />
164
192
</template >
165
193
{{ t('spreed', 'View conversation') }}
166
194
</NcButton >
@@ -212,6 +240,10 @@ function handleJoin({ call = false } = {}) {
212
240
display : flex ;
213
241
gap : 2px ;
214
242
243
+ & > span ::first-letter {
244
+ text-transform : capitalize ;
245
+ }
246
+
215
247
& > * {
216
248
white-space : nowrap ;
217
249
overflow : hidden ;
@@ -234,11 +266,12 @@ function handleJoin({ call = false } = {}) {
234
266
align-items : center ;
235
267
gap : var (--default-grid-baseline );
236
268
237
- & > span {
269
+ & -prefix {
238
270
line-height : var (--chip-size );
239
271
white-space : nowrap ;
240
272
overflow : hidden ;
241
273
text-overflow : ellipsis ;
274
+ flex-shrink : 0 ;
242
275
}
243
276
}
244
277
@@ -279,6 +312,8 @@ function handleJoin({ call = false } = {}) {
279
312
align-items : center ;
280
313
padding-inline-start : 6px ; // revert negative margin
281
314
gap : var (--default-grid-baseline );
315
+ font-size : inherit ;
316
+ margin : 0 ;
282
317
283
318
& _text {
284
319
font-weight : bold ;
0 commit comments