-
Notifications
You must be signed in to change notification settings - Fork 0
/
CaptionedGif.svelte
93 lines (82 loc) · 1.65 KB
/
CaptionedGif.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
81
82
83
84
85
86
87
88
89
90
91
92
93
<script>
import { onMount } from "svelte";
import { fade } from "svelte/transition";
import { push } from "svelte-spa-router";
import axios from "axios";
import LoadingAnimation from "../components/LoadingAnimation.svelte";
import Heading from "../components/Heading.svelte";
export let params = {};
let gifFile;
let loading = true;
onMount(async () => {
try {
const res = await axios.get(`API_URL/captioned/${params.filename}`);
gifFile = res.data;
loading = false;
} catch (error) {
loading = false;
}
});
</script>
<main>
<Heading />
{#if !loading}
{#if gifFile}
<div class="gif" in:fade>
<img
src={`API_URL/captioned/${params.filename}`}
loop="infinite"
alt="Captioned GIF"
/>
</div>
<br />
<button>Download</button>
<br />
<button on:click={() => push("/")}>Upload another GIF</button>
{:else}
<div class="center">
<h3>Cannot find GIF '{params.filename}'.</h3>
<h4>GIFs are available for 24 hours after creation.</h4>
<button on:click={() => push("/")}>Upload another GIF</button>
</div>
{/if}
{/if}
{#if loading}
<LoadingAnimation />
{/if}
</main>
<style>
main {
text-align: center;
padding: 1em;
max-width: 240px;
margin-left: auto;
margin: 0 auto 5% auto;
}
.center {
margin-top: 5%;
margin-bottom: 5%;
left: 0;
line-height: 50px;
margin-top: -100px;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
}
h3 {
color: rgb(77, 77, 77);
font-weight: 100;
font-size: 2em;
}
h4 {
color: rgb(77, 77, 77);
font-weight: 100;
font-size: 1.5em;
}
@media (min-width: 640px) {
main {
max-width: none;
}
}
</style>