Skip to content

Commit ec242bf

Browse files
DorraJaouadbackportbot[bot]
authored andcommitted
fix: add missing aria label and improve date processing for better translation
Signed-off-by: Dorra Jaouad <[email protected]>
1 parent c945e66 commit ec242bf

File tree

1 file changed

+45
-18
lines changed

1 file changed

+45
-18
lines changed

src/components/Dashboard/EventCard.vue

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { useIsInCall } from '../../composables/useIsInCall.js'
2828
import { useStore } from '../../composables/useStore.js'
2929
import { CONVERSATION } from '../../constants.ts'
3030
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'
3232
3333
const props = defineProps<{
3434
eventRoom: DashboardEventRoom,
@@ -57,20 +57,45 @@ const eventDateLabel = computed(() => {
5757
}
5858
const startDate = new Date(props.eventRoom.start * 1000)
5959
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-
return t('spreed', '{dateString} {startDateString} - {endDateString}', {
70-
dateString,
71-
startDateString,
72-
endDateString,
73-
})
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
7499
})
75100
76101
const hasAttachments = computed(() => {
@@ -120,7 +145,7 @@ function handleJoin({ call = false } = {}) {
120145
</span>
121146
</h4>
122147
<p class="event-card__date secondary_text">
123-
{{ eventDateLabel }}
148+
<span>{{ eventDateLabel }}</span>
124149
<template v-if="hasCall">
125150
<IconVideo :size="20" :fill-color="'#E9322D'" />
126151
<span>{{ elapsedTime }}</span>
@@ -215,6 +240,10 @@ function handleJoin({ call = false } = {}) {
215240
display: flex;
216241
gap: 2px;
217242
243+
& > span::first-letter {
244+
text-transform: capitalize;
245+
}
246+
218247
& > * {
219248
white-space: nowrap;
220249
overflow: hidden;
@@ -291,8 +320,6 @@ function handleJoin({ call = false } = {}) {
291320
white-space: nowrap;
292321
overflow: hidden;
293322
text-overflow: ellipsis;
294-
font-size: inherit;
295-
margin: 0;
296323
}
297324
}
298325

0 commit comments

Comments
 (0)