forked from TechLabs-Berlin/radar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EventListItem.vue
142 lines (137 loc) · 3.82 KB
/
EventListItem.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<template>
<WrapperContentBox
:faded="isPastDate && !isLive"
:emphasized="isCurrentEvent"
>
<article class="relative pt-8 lg:pt-0">
<Stamp v-if="isCurrentEvent" :date="eventDate" />
<header class="flex flex-col items-center mb-8">
<p
class="mb-4 text-4xl font-bold text-center"
:class="isCurrentEvent ? 'text-pink-600' : 'text-gray-400'"
>
<TIcon icon="calendar-day" class="inline-block" />
</p>
<template v-if="showPermalink">
<NuxtLink :to="`/event/${tlEvent.slug}`" class="title-link">
<h2
class="relative inline-block mb-1 text-2xl font-bold hover:underline"
>
{{ tlEvent.title }}
<div
class="absolute top-0 right-0 hidden pl-2 text-base text-blue-600 transform translate-x-full translate-y-1 icon"
>
<TIcon icon="link" class="inline-block" />
</div></h2
></NuxtLink>
</template>
<template v-else>
<h2 class="inline-block mb-1 text-2xl font-bold">
{{ tlEvent.title }}
</h2>
</template>
<div>
<p class="text-lg text-center">
{{ verb }} statt:
{{ format(eventDate, "dd.MM, 'um' h:mm aaaa") }}
</p>
</div>
</header>
<main>
<!-- BODY -->
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="pb-10 prose" v-html="$md.render(tlEvent.description)" />
</main>
<!-- RESOURCES -->
<aside v-if="hasResources" class="space-y-8">
<template
v-if="
(isInOneHour || isLive) &&
tlEvent.meetings &&
tlEvent.meetings.length
"
>
<EventListItemResourceList
:resources="tlEvent.meetings"
title="Meetings"
/>
</template>
<template v-else-if="isCurrentEvent">
<p class="italic text-center text-gray-400">
Weitere Event-links werden in Kürze veröffentlicht!!
</p>
</template>
<template
v-if="isLive || isPastDate || showResources || tlEvent.showResources"
>
<EventListItemResourceList
v-if="tlEvent.forms && tlEvent.forms.length"
:resources="tlEvent.forms"
title="Umfragen"
/>
<EventListItemResourceList
v-if="tlEvent.resources && tlEvent.resources.length"
:resources="tlEvent.resources"
title="Ressourcen"
/>
</template>
</aside>
</article>
</WrapperContentBox>
</template>
<script>
import { format } from 'date-fns'
import { defineComponent, computed } from '@nuxtjs/composition-api'
import { useEvent } from '@/composables/useEvent'
export default defineComponent({
props: {
tlEvent: {
type: Object,
required: true,
},
isCurrentEvent: {
type: Boolean,
},
isPastEvent: {
type: Boolean,
},
showResources: {
type: Boolean,
},
showPermalink: {
type: Boolean,
},
},
setup(props) {
const eventDate = new Date(props.tlEvent.date)
const { isPastDate, isFutureDate, isLive, isInOneHour } = useEvent({
...props.tlEvent,
date: eventDate,
})
const hasResources = computed(
() =>
props.tlEvent.resources || props.tlEvent.forms || props.tlEvent.meetings
)
const verb = computed(() => {
if (isLive.value) return 'Findet gerade'
if (isPastDate.value) return 'Fand'
return 'Findet'
})
return {
format,
eventDate,
hasResources,
isInOneHour,
isLive,
isPastDate,
isFutureDate,
verb,
}
},
})
</script>
<style lang="scss" scoped>
.title-link:hover .icon {
@apply inline-block;
}
</style>