diff options
author | Zero~Informatique | 2020-01-31 09:17:57 +0100 |
---|---|---|
committer | Zero~Informatique | 2020-01-31 09:27:06 +0100 |
commit | 170da2d55fec0359cbac780786383710b734eda7 (patch) | |
tree | eb6fe6f60e9b83a9e5886b504aa65521711fd4a3 /viewer/src/components/LdThumbnail.vue | |
parent | a7d459a2620fa9523dd7ce8c9de519133ad5b1b7 (diff) | |
download | ldgallery-170da2d55fec0359cbac780786383710b734eda7.tar.gz |
viewer: code cleaning, moved some views to components
Diffstat (limited to 'viewer/src/components/LdThumbnail.vue')
-rw-r--r-- | viewer/src/components/LdThumbnail.vue | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/viewer/src/components/LdThumbnail.vue b/viewer/src/components/LdThumbnail.vue new file mode 100644 index 0000000..44a4c00 --- /dev/null +++ b/viewer/src/components/LdThumbnail.vue | |||
@@ -0,0 +1,81 @@ | |||
1 | <!-- ldgallery - A static generator which turns a collection of tagged | ||
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | ||
5 | -- | ||
6 | -- This program is free software: you can redistribute it and/or modify | ||
7 | -- it under the terms of the GNU Affero General Public License as | ||
8 | -- published by the Free Software Foundation, either version 3 of the | ||
9 | -- License, or (at your option) any later version. | ||
10 | -- | ||
11 | -- This program is distributed in the hope that it will be useful, | ||
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | -- GNU Affero General Public License for more details. | ||
15 | -- | ||
16 | -- You should have received a copy of the GNU Affero General Public License | ||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
18 | --> | ||
19 | |||
20 | <template> | ||
21 | <div class="forcedsize" :class="{'preload': loading}"> | ||
22 | <v-lazy-image | ||
23 | v-if="item.thumbnail" | ||
24 | class="thumbnail" | ||
25 | :src="pictureSrc()" | ||
26 | :title="item.path" | ||
27 | @intersect="loading=true" | ||
28 | @load="loading=false" | ||
29 | /> | ||
30 | <div v-else class="flex-column flex-center"> | ||
31 | <fa-icon :icon="getIcon()" size="4x" /> | ||
32 | {{item.title}} | ||
33 | </div> | ||
34 | </div> | ||
35 | </template> | ||
36 | |||
37 | <script lang="ts"> | ||
38 | import { Component, Vue, Prop } from "vue-property-decorator"; | ||
39 | import Tools from "@/tools"; | ||
40 | |||
41 | @Component | ||
42 | export default class LdThumbnail extends Vue { | ||
43 | @Prop({ required: true }) readonly item!: Gallery.Item; | ||
44 | |||
45 | loading: boolean = false; | ||
46 | |||
47 | pictureSrc() { | ||
48 | return `${process.env.VUE_APP_DATA_URL}${this.item.thumbnail}`; | ||
49 | } | ||
50 | |||
51 | getIcon() { | ||
52 | return Tools.getIcon(this.item); | ||
53 | } | ||
54 | } | ||
55 | </script> | ||
56 | |||
57 | <style lang="scss"> | ||
58 | @import "@/assets/scss/theme.scss"; | ||
59 | |||
60 | .thumbnail { | ||
61 | max-width: 250px; | ||
62 | max-height: 250px; | ||
63 | } | ||
64 | .preload { | ||
65 | animation: preloadAnimation 1s infinite ease-in-out alternate; | ||
66 | } | ||
67 | @keyframes preloadAnimation { | ||
68 | from { | ||
69 | background-color: $content-bgcolor; | ||
70 | } | ||
71 | to { | ||
72 | background-color: $loader-color; | ||
73 | } | ||
74 | } | ||
75 | // Temporary size until we get the true thumbnail size | ||
76 | .forcedsize { | ||
77 | width: 250px; | ||
78 | height: 250px; | ||
79 | text-align: center; | ||
80 | } | ||
81 | </style> | ||