-
Notifications
You must be signed in to change notification settings - Fork 0
/
Relive.svelte
80 lines (68 loc) 路 2.72 KB
/
Relive.svelte
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
<script>
import { goto } from '$app/navigation';
import ImageScroller from './ImageScroller.svelte';
import Timeline from './Timeline.svelte';
import Commentsection from './Commentsection.svelte';
const events = [
{ id: 1, url: 'https://picsum.photos/id/234/200/300' },
{ id: 2, url: 'https://picsum.photos/id/233/200/300' },
{ id: 3, url: 'https://picsum.photos/id/232/200/300' },
{ id: 4, url: 'https://picsum.photos/id/238/200/300' },
{ id: 5, url: 'https://picsum.photos/id/239/200/300' },
{ id: 6, url: 'https://picsum.photos/id/230/200/300' },
{ id: 7, url: 'https://picsum.photos/id/231/200/300' },
{ id: 8, url: 'https://picsum.photos/id/236/200/300' },
{ id: 9, url: 'https://picsum.photos/id/237/200/300' }
];
let selectedEvent = events[0];
let showingComments;
const goBackwards = () => {
const indexOfPreviousElement = Math.max(events.indexOf(selectedEvent) - 1, 0);
selectedEvent = events[indexOfPreviousElement];
};
const goForwards = () => {
const indexOfNextElement = Math.min(events.indexOf(selectedEvent) + 1, events.length - 1);
selectedEvent = events[indexOfNextElement];
};
const showComments = () => {
showingComments = true;
};
const starEvent = () => {
selectedEvent.starred = !selectedEvent.starred;
};
</script>
<section class="h-full flex flex-col relative">
<div class="bg-transparent absolute text-white top-20 left-2 z-30">
<!-- angle-left -->
<a href="/events" class="w-8 h-8 p-4 rounded-full">
<i class="fa fa-close text-2xl mx-auto" />
</a>
</div>
<Timeline />
<div class="flex-grow relative">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<dv class="h-full w-1/4 absolute z-20 opacity-0" on:click={goBackwards} />
<!-- svelte-ignore a11y-click-events-have-key-events -->
<dv class="h-full w-1/4 absolute right-0 z-20 opacity-0" on:click={goForwards} />
<img
class="max-h-full h-full w-full object-cover rounded-xl -z-10"
src={selectedEvent.url}
alt="Main Thumbnail"
/>
<!-- Backwards -->
<!-- <img src="logoWithText.png" alt="Test" /> -->
<!-- Button Bar -->
<div class="absolute bottom-10 right-1/3 left-1/3 flex justify-center">
<button on:click={starEvent} class="flex items-center px-7 py-3 text-white rounded-l-full" style="background-color:#5C3D95">
<i class="fa fa-star text-2xl mr-2" style="color: {selectedEvent.starred ? '#FFCD29' : 'white'}"></i>
</button>
<button on:click={showComments} class="flex items-center px-7 py-3 text-white rounded-r-full" style="background-color:#5C3D95">
<i class="fa fa-comment text-2xl mr-2"></i>
</button>
</div>
</div>
<ImageScroller {events} bind:selectedEvent />
{#if showingComments}
<Commentsection bind:event={selectedEvent} bind:showingComments/>
{/if}
</section>