-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6385 from Ocelot-Social-Community/6379-fix-event-…
…teaser-date-from-start-to-end fix(webapp): fix event teaser date from start to end by new components
- Loading branch information
Showing
6 changed files
with
204 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<template> | ||
<ds-text class="date-time-range" align="left" color="soft" :size="size"> | ||
<div> | ||
<div> | ||
<base-icon name="calendar" data-test="calendar" /> | ||
{{ getStartDateString }} | ||
</div> | ||
<div> | ||
<base-icon name="clock" data-test="calendar" /> | ||
{{ | ||
getStartTimeString + | ||
(this.endDateAsDate && isSameDayLocal ? '—' + getEndTimeString : '') | ||
}} | ||
</div> | ||
</div> | ||
<template v-if="!isSameDayLocal"> | ||
— | ||
<div> | ||
<div> | ||
<base-icon name="calendar" data-test="calendar" /> | ||
{{ getEndDateString }} | ||
</div> | ||
<div> | ||
<base-icon name="clock" data-test="calendar" /> | ||
{{ getEndTimeString }} | ||
</div> | ||
</div> | ||
</template> | ||
</ds-text> | ||
</template> | ||
|
||
<script> | ||
import { format, isSameDay, isSameYear } from 'date-fns' | ||
export default { | ||
name: 'DateTimeRange', | ||
props: { | ||
/** | ||
* The size used for the text. | ||
* @options small|base|large|x-large|xx-large|xxx-large | ||
*/ | ||
size: { | ||
type: String, | ||
default: null, | ||
validator: (value) => { | ||
return value.match(/(small|base|large|x-large|xx-large|xxx-large)/) | ||
}, | ||
}, | ||
startDate: { | ||
type: String, | ||
require: true, | ||
}, | ||
endDate: { | ||
type: String, | ||
default: null, | ||
}, | ||
}, | ||
computed: { | ||
startDateAsDate() { | ||
return new Date(this.startDate) | ||
}, | ||
endDateAsDate() { | ||
return this.endDate ? new Date(this.endDate) : null | ||
}, | ||
isSameDayLocal() { | ||
return !this.endDateAsDate || isSameDay(this.endDateAsDate, this.startDateAsDate) | ||
}, | ||
isSameYearLocal() { | ||
return !this.endDateAsDate || isSameYear(this.endDateAsDate, this.startDateAsDate) | ||
}, | ||
getStartDateString() { | ||
let startDateFormat = this.$t('components.dateTimeRange.yearMonthDay') | ||
if (!this.isSameDayLocal && this.isSameYearLocal) { | ||
startDateFormat = this.$t('components.dateTimeRange.monthDay') | ||
} | ||
return format(this.startDateAsDate, startDateFormat) | ||
}, | ||
getStartTimeString() { | ||
return format(new Date(this.startDate), this.$t('components.dateTimeRange.hourMinute')) | ||
}, | ||
getEndDateString() { | ||
return this.endDate | ||
? format(new Date(this.endDate), this.$t('components.dateTimeRange.yearMonthDay')) | ||
: '' | ||
}, | ||
getEndTimeString() { | ||
return this.endDate | ||
? format(new Date(this.endDate), this.$t('components.dateTimeRange.hourMinute')) | ||
: '' | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.date-time-range { | ||
display: flex; | ||
align-items: center; | ||
gap: 2px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<template> | ||
<ds-text class="location-teaser" align="left" color="soft" :size="size"> | ||
<base-icon name="map-marker" data-test="map-marker" /> | ||
<span v-if="venue">{{ venue }}</span> | ||
<span v-if="venue"> — </span> | ||
<span v-if="!isOnline"> | ||
{{ locationName }} | ||
</span> | ||
<span v-else> | ||
{{ $t('post.viewEvent.eventIsOnline') }} | ||
</span> | ||
</ds-text> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'LocationTeaser', | ||
props: { | ||
/** | ||
* The size used for the text. | ||
* @options small|base|large|x-large|xx-large|xxx-large | ||
*/ | ||
size: { | ||
type: String, | ||
default: null, | ||
validator: (value) => { | ||
return value.match(/(small|base|large|x-large|xx-large|xxx-large)/) | ||
}, | ||
}, | ||
venue: { | ||
type: String, | ||
default: null, | ||
}, | ||
locationName: { | ||
type: String, | ||
default: null, | ||
}, | ||
isOnline: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss"> | ||
.location-teaser { | ||
display: flex; | ||
align-items: center; | ||
gap: 2px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.