Skip to content

Commit 1c0f7e4

Browse files
authored
Merge pull request #15200 from nextcloud/backport/15112/stable31
2 parents 440258e + ec242bf commit 1c0f7e4

File tree

4 files changed

+123
-63
lines changed

4 files changed

+123
-63
lines changed

src/assets/variables.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ $transition-duration-slow: var(--animation-slow, 300ms);
2525

2626
$transition: all $transition-duration-quick ease-in-out;
2727
$transition-slow: all $transition-duration-slow ease-in-out;
28+
29+
// To be in sync with nextcloud-vue
30+
$breakpoint-mobile-small: 512px;

src/components/Dashboard/EventCard.vue

Lines changed: 53 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,17 +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-
// 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
7199
})
72100
73101
const hasAttachments = computed(() => {
@@ -107,24 +135,24 @@ function handleJoin({ call = false } = {}) {
107135
'event-card--highlighted': isToday,
108136
'event-card--in-call': hasCall,
109137
}">
110-
<span class="title">
138+
<h4 class="title">
111139
<span v-for="calendar in props.eventRoom.calendars"
112140
:key="calendar.principalUri"
113141
class="calendar-badge"
114142
:style="{ backgroundColor: calendar.calendarColor ?? usernameToColor(calendar.principalUri).color }" />
115143
<span class="title_text">
116144
{{ props.eventRoom.eventName }}
117145
</span>
118-
</span>
146+
</h4>
119147
<p class="event-card__date secondary_text">
120-
{{ eventDateLabel }}
148+
<span>{{ eventDateLabel }}</span>
121149
<template v-if="hasCall">
122150
<IconVideo :size="20" :fill-color="'#E9322D'" />
123151
<span>{{ elapsedTime }}</span>
124152
</template>
125153
</p>
126154
<span class="event-card__room secondary_text">
127-
<span>
155+
<span class="event-card__room-prefix">
128156
{{ props.eventRoom.roomType === CONVERSATION.TYPE.ONE_TO_ONE ? t('spreed', 'With') : t('spreed', 'In') }}
129157
</span>
130158
<NcChip type="tertiary"
@@ -160,7 +188,7 @@ function handleJoin({ call = false } = {}) {
160188
<NcButton type="tertiary"
161189
@click="handleJoin">
162190
<template #icon>
163-
<NcIconSvgWrapper :svg="IconTalk" />
191+
<NcIconSvgWrapper :svg="IconTalk" :size="20" />
164192
</template>
165193
{{ t('spreed', 'View conversation') }}
166194
</NcButton>
@@ -212,6 +240,10 @@ function handleJoin({ call = false } = {}) {
212240
display: flex;
213241
gap: 2px;
214242
243+
& > span::first-letter {
244+
text-transform: capitalize;
245+
}
246+
215247
& > * {
216248
white-space: nowrap;
217249
overflow: hidden;
@@ -234,11 +266,12 @@ function handleJoin({ call = false } = {}) {
234266
align-items: center;
235267
gap: var(--default-grid-baseline);
236268
237-
& > span {
269+
&-prefix {
238270
line-height: var(--chip-size);
239271
white-space: nowrap;
240272
overflow: hidden;
241273
text-overflow: ellipsis;
274+
flex-shrink: 0;
242275
}
243276
}
244277
@@ -279,6 +312,8 @@ function handleJoin({ call = false } = {}) {
279312
align-items: center;
280313
padding-inline-start: 6px; // revert negative margin
281314
gap: var(--default-grid-baseline);
315+
font-size: inherit;
316+
margin: 0;
282317
283318
&_text {
284319
font-weight: bold;

0 commit comments

Comments
 (0)