Skip to content

Commit

Permalink
Update gallery and pagination components
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Nov 4, 2023
1 parent a18ca07 commit cfc919c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/Gallery/GalleryMainImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ref="imageElement"
class="max-h-80 h-max w-100 cursor-zoom-in m-auto object-contain"
:src="image.original"
:alt="image.depictions.map((d) => d.label).join(';')"
:alt="image.depictions?.map((d) => d.label).join(';')"
@click="emit('open:viewer')"
/>
</div>
Expand Down
11 changes: 4 additions & 7 deletions src/components/Gallery/GalleryThumbnailList.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<template>
<div class="flex flex-row overflow-x-auto print:flex-wrap">
<div
<div class="flex flex-row overflow-x-auto print:flex-wrap gap-1.5">
<div
v-for="(image, index) in images"
:key="image.id"
class="
pr-1.5
last:pr-0"
>
<GalleryThumbnail
:image="image"
:class="{ 'border border-secondary-color': current === index }"
:title="image.depictions.map(d => d.label).join(';')"
:title="image.depictions?.map((d) => d.label).join(';')"
@click="emit('selectIndex', index)"
/>
</div>
Expand All @@ -32,4 +29,4 @@ defineProps({
})
const emit = defineEmits(['selectIndex'])
</script>
</script>
2 changes: 1 addition & 1 deletion src/components/ImageViewer/ImageViewer.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
v-show="!errorMessage"
ref="imageElement"
class="mx-auto cursor-zoom-out w-auto max-w-full max-h-full h-auto my-auto"
:alt="image.depictions.map((d) => d.label).join(';')"
:alt="image?.depictions?.map((d) => d.label).join(';')"
:src="image.original"
@click="emit('close')"
/>
Expand Down
54 changes: 40 additions & 14 deletions src/components/Pagination/VPagination.global.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,42 @@
</li>

<li
v-if="modelValue > props.rangePages"
class="border border-base-border px-2 py-1.5"
>
<span class="page gap"> ... </span>
</li>

<template
v-for="n in pages"
class="page-item"
:key="n"
>
<button
type="button"
aria-label="Go to page 1"
class="border border-base-border px-2 py-1.5"
:disabled="currentPage === n"
:class="
currentPage === n
? 'text-primary-content bg-primary-color'
: 'text-base-content'
"
@click="() => (currentPage = n)"
<li
v-if="n < rangeMax && rangeMin < n"
class="page-item"
>
{{ n }}
</button>
<button
type="button"
aria-label="Go to page 1"
class="border border-base-border px-2 py-1.5"
:disabled="currentPage === n"
:class="
currentPage === n
? 'text-primary-content bg-primary-color'
: 'text-base-content'
"
@click="() => (currentPage = n)"
>
{{ n }}
</button>
</li>
</template>

<li
v-if="pages - modelValue >= rangePages"
class="border border-base-border px-2 py-1.5"
>
<span class="page gap"> ... </span>
</li>

<li class="page-item">
Expand Down Expand Up @@ -93,6 +111,11 @@ const props = defineProps({
per: {
type: Number,
required: true
},
rangePages: {
type: Number,
default: 5
}
})
Expand All @@ -105,4 +128,7 @@ const currentPage = computed({
emit('update:modelValue', value)
}
})
const rangeMax = computed(() => props.modelValue + props.rangePages)
const rangeMin = computed(() => props.modelValue - props.rangePages)
</script>

0 comments on commit cfc919c

Please sign in to comment.