Skip to content

Commit

Permalink
Update image viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
José Luis Pereira committed Jul 18, 2022
1 parent 4872836 commit 5e3282e
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/components/Gallery/GalleryThumbnail.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div
class="bg-white dark:bg-gray-800 flex flex-col justify-center cursor-pointer w-24 h-24 dark:border-gray-600 rounded-md border box-border"
class="bg-white dark:bg-gray-800 flex flex-col justify-center cursor-pointer w-24 h-20 dark:border-gray-600 rounded border box-border"
:title="title"
>
<img
class="max-h-24 max-w-24 h-24 w-24 object-cover rounded-md"
class="max-h-24 max-w-24 h-24 w-24 object-cover rounded"
:src="image.thumb"
>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Gallery/GalleryThumbnailList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-for="(image, index) in images"
:key="image.id"
class="
pr-2
pr-1.5
last:pr-0"
>
<GalleryThumbnail
Expand Down
17 changes: 17 additions & 0 deletions src/components/Gallery/ImageToolbar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div class="p-2 box-border flex justify-between">
<div>
<slot />
</div>
<button
type="button"
class="p-2 cursor-pointer text-white opacity-50 "
>
<IconClose />
</button>
</div>
</template>

<script setup>
</script>
74 changes: 41 additions & 33 deletions src/components/Gallery/ImageViewer.vue
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
<template>
<div
class="fixed z-[10000] bg-opacity-60 bg-black overflow-y-hidden overflow-x-hidden w-full h-full top-0 left-0 flex flex-col items-center justify-center backdrop-blur-md"
class="fixed z-[10000] h-full bg-opacity-90 bg-black overflow-y-hidden overflow-x-hidden w-full top-0 left-0 flex flex-col items-center justify-center backdrop-blur-md"
@click="emit('close')"
>
<div
class="min-w-96 dark:bg-slate-900 rounded-lg shadow-sm mb-24"
class="min-w-96 dark:bg-slate-900 rounded-lg shadow-sm mb-24"
@click.stop
>
<VSpinner v-if="isLoading" />
<div class="relative rounded-t-lg w-auto bg-white">
<div class="absolute rounded-t-lg w-auto max-h-full h-auto top-12 bottom-40 left-0 right-0 flex justify-center align-middle">
<VSpinner v-if="isLoading" />
<img
ref="imageElement"
class="mx-auto cursor-zoom-out max-w-7 w-auto max-w-full max-h-[70vh]"
class="mx-auto cursor-zoom-out w-auto max-w-full max-h-full h-auto my-auto"
:src="image.original"
@click="emit('close')"
>
</div>

<ControlNextImage
v-if="next"
class="right-0 absolute my-auto top-1/2 -translate-y-1/2"
@click="emit('next')"
/>
<ControlPreviousImage
v-if="previous"
class="left-0 absolute my-auto top-1/2 -translate-y-1/2"
@click="emit('previous')"
/>
</div>
</div>
<div class="bottom-0 fixed overflow-x-auto max-w-full pb-2">
<div
class="
bg-white
dark:bg-slate-900
dark:text-white
text-white
text-sm
attributions
bottom-0
h-24
p-4
rounded-b-lg
p-6
align-middle
flex
justify-between
flex-col
text-center"
text-center
[text-shadow:0_1px_5px_rgba(0,0,0,1)]
"
>
<ImageDepictions
class="my-auto"
Expand All @@ -42,34 +52,32 @@
:attribution="image.attribution"
/>
</div>

<ControlNextImage
v-if="next"
class="right-0 absolute my-auto top-1/2 -translate-y-1/2"
@click="emit('next')"
/>
<ControlPreviousImage
v-if="previous"
class="left-0 absolute my-auto top-1/2 -translate-y-1/2"
@click="emit('previous')"
<GalleryThumbnailList
:current="index"
:images="images"
@select-index="emit('selectIndex', $event)"
@click.stop
/>
</div>
<GalleryThumbnailList
class="bottom-0 fixed overflow-x-auto max-w-full pb-2"
:current="index"
:images="images"
@select-index="emit('selectIndex', $event)"
@click.stop
/>
<ImageToolbar
class="w-full absolute top-0 h-12 left-0"
>
<ImageViewerCounter
:current-image="index"
:total-images="images.length"
/>
</ImageToolbar>
</div>
</template>

<script setup>
import { onMounted, onUnmounted, ref, watch, computed } from 'vue'
import ImageAttribution from './ImageAttribution.vue';
import ImageDepictions from './ImageDepictions.vue';
import ImageAttribution from './ImageAttribution.vue'
import ImageDepictions from './ImageDepictions.vue'
import ImageViewerCounter from './ImageViewerCounter.vue'
import ControlNextImage from './ControlImageNext.vue'
import ControlPreviousImage from './ControlImagePrevious.vue'
import ImageToolbar from './ImageToolbar.vue'
const props = defineProps({
index: {
Expand Down
16 changes: 16 additions & 0 deletions src/components/Gallery/ImageViewerCounter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<span>{{ currentImage + 1 }}/{{ totalImages }}</span>
</template>

<script setup>
defineProps({
currentImage: {
type: Number,
required: true
},
totalImages: {
type: Number,
required: true
}
})
</script>
19 changes: 19 additions & 0 deletions src/components/Icon/IconClose.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</template>

<script setup>
</script>

0 comments on commit 5e3282e

Please sign in to comment.