aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views/ItemThumbnail.vue
diff options
context:
space:
mode:
authorpacien2022-09-03 01:34:26 +0200
committerpacien2022-09-03 01:34:26 +0200
commita8452594c6571e8003baa2aca14747eeeee08152 (patch)
treea894d99c22a601197869c7a6928d40bb4ae2c392 /viewer/src/views/ItemThumbnail.vue
parentdd9c9804e9e3da9880c711f53edb9c4a19d782f8 (diff)
parent00510820a2794efcadbc83f7f8b54318fe198ecb (diff)
downloadldgallery-a8452594c6571e8003baa2aca14747eeeee08152.tar.gz
Merge branch 'vue3-refactoring-staging' into develop
Reviewed-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'viewer/src/views/ItemThumbnail.vue')
-rw-r--r--viewer/src/views/ItemThumbnail.vue99
1 files changed, 99 insertions, 0 deletions
diff --git a/viewer/src/views/ItemThumbnail.vue b/viewer/src/views/ItemThumbnail.vue
new file mode 100644
index 0000000..1c9e206
--- /dev/null
+++ b/viewer/src/views/ItemThumbnail.vue
@@ -0,0 +1,99 @@
1<!-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery.
3--
4-- Copyright (C) 2019-2022 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="{ [$style.preload]: loading }">
22 <!-- Can't use img loading="lazy" yet because @loadstart doesn't work on Chromium -->
23 <!-- Also it loads the picture before scroll init (too early) -->
24 <VLazyImage
25 v-if="thumbnailResourceUrl"
26 :src="thumbnailResourceUrl"
27 :style="pictureStyle"
28 :title="item.title"
29 @intersect="loading = true"
30 @load="loading = false"
31 />
32 <div
33 v-else
34 class="flex-column flex-center"
35 :class="$style.thumbnailOther"
36 >
37 <div>
38 <fa-icon
39 :icon="icon"
40 size="4x"
41 />
42 </div>
43 {{ item.title }}
44 </div>
45 </div>
46</template>
47
48<script setup lang="ts">
49import { Item } from '@/@types/gallery';
50import { useNavigation } from '@/services/navigation';
51import { useItemResource } from '@/services/ui/ldItemResourceUrl';
52import VLazyImage from 'v-lazy-image';
53import { computed, PropType, ref } from 'vue';
54
55const props = defineProps({
56 item: { type: Object as PropType<Item>, required: true },
57});
58
59const navigation = useNavigation();
60
61const loading = ref(false);
62
63const { thumbnailResourceUrl } = useItemResource(props.item);
64
65const pictureStyle = computed(() => {
66 const resolution = props.item.thumbnail?.resolution ?? { width: 1, height: 1 };
67 return { width: `${resolution.width}px`, height: `${resolution.height}px` };
68});
69
70const icon = computed(() => navigation.getIcon(props.item));
71</script>
72
73<style lang="scss" module>
74@import "~@/assets/scss/theme";
75
76.thumbnailOther {
77 width: $thumbnail-other-size;
78 height: $thumbnail-other-size;
79 padding-top: $body-line-height * 1em;
80 text-align: center;
81 word-break: break-word;
82 overflow: hidden;
83 > div {
84 min-height: $body-line-height * 3em;
85 }
86}
87
88.preload {
89 animation: preloadAnimation 1s infinite ease-in-out alternate;
90}
91@keyframes preloadAnimation {
92 from {
93 background-color: $content-bgcolor;
94 }
95 to {
96 background-color: $skeleton-color;
97 }
98}
99</style>