aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views/ItemThumbnail.vue
diff options
context:
space:
mode:
authorZéro~Informatique2022-07-26 08:44:34 +0200
committerpacien2022-09-03 01:30:42 +0200
commit00510820a2794efcadbc83f7f8b54318fe198ecb (patch)
treea894d99c22a601197869c7a6928d40bb4ae2c392 /viewer/src/views/ItemThumbnail.vue
parent88aa098c07e067f9f737fbeba1f52a9bd5042e53 (diff)
downloadldgallery-00510820a2794efcadbc83f7f8b54318fe198ecb.tar.gz
viewer: migrate to vue 3, general refactoring and cleanup
Non-exhaustive list of fixes and improvements done at the same time: - html default background to grey (avoids white flash during init) - unified links behavior - added more theme variables - removed the flex-expand transition (it wasn't working) and replaced it with a slide - fixed LdLoading not centered on the content - title on removable tags - fixed an issue with encoded URI from vue-router - unified Item resource URLs - removed the iframe for PlainTextViewer (it wasn't working properly) and replaced it with a pre - fixed clear and search buttons tabindex - fixed the information panel bumping up during the fade animation of tag's dropdown - fixed some focus outlines not appearing correctly - moved CSS variables to the :root context - Code cleaning GitHub: closes #217 GitHub: closes #300 GitHub: closes #297 GitHub: closes #105 GitHub: closes #267 GitHub: closes #275 GitHub: closes #228 GitHub: closes #215 GitHub: closes #112
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>