2022-11-30 06:27:19 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
const emit = defineEmits(['close'])
|
|
|
|
|
2023-01-04 11:15:24 +03:00
|
|
|
const locked = useScrollLock(document.body)
|
2022-11-30 06:27:19 +03:00
|
|
|
|
2023-01-04 11:15:24 +03:00
|
|
|
// Use to avoid strange error when directlying assigning to v-model on ModelMediaPreviewCarousel
|
|
|
|
const index = mediaPreviewIndex
|
2023-01-01 22:59:31 +03:00
|
|
|
|
2023-01-04 11:15:24 +03:00
|
|
|
const current = computed(() => mediaPreviewList.value[mediaPreviewIndex.value])
|
|
|
|
const hasNext = computed(() => index.value < mediaPreviewList.value.length - 1)
|
|
|
|
const hasPrev = computed(() => index.value > 0)
|
2023-01-02 00:13:14 +03:00
|
|
|
|
2022-11-30 06:27:19 +03:00
|
|
|
const keys = useMagicKeys()
|
|
|
|
|
|
|
|
whenever(keys.arrowLeft, prev)
|
|
|
|
whenever(keys.arrowRight, next)
|
|
|
|
|
|
|
|
function next() {
|
|
|
|
if (hasNext.value)
|
2023-01-04 11:15:24 +03:00
|
|
|
index.value++
|
2022-11-30 06:27:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function prev() {
|
|
|
|
if (hasPrev.value)
|
2023-01-04 11:15:24 +03:00
|
|
|
index.value--
|
2022-11-30 06:27:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onClick(e: MouseEvent) {
|
|
|
|
const path = e.composedPath() as HTMLElement[]
|
2022-12-20 00:34:58 +03:00
|
|
|
const el = path.find(el => ['A', 'BUTTON', 'IMG', 'VIDEO', 'P'].includes(el.tagName?.toUpperCase()))
|
2022-11-30 06:27:19 +03:00
|
|
|
if (!el)
|
|
|
|
emit('close')
|
|
|
|
}
|
2023-01-04 11:15:24 +03:00
|
|
|
|
|
|
|
onMounted(() => locked.value = true)
|
|
|
|
onUnmounted(() => locked.value = false)
|
2022-11-30 06:27:19 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-04 11:15:24 +03:00
|
|
|
<div relative h-full w-full flex pt-12 w-100vh @click="onClick">
|
2022-12-04 09:27:08 +03:00
|
|
|
<button
|
2022-12-14 12:10:42 +03:00
|
|
|
v-if="hasNext" pointer-events-auto btn-action-icon bg="black/20" :aria-label="$t('action.previous')"
|
2023-01-08 10:49:32 +03:00
|
|
|
hover:bg="black/40" dark:bg="white/30" dark-hover:bg="white/20" absolute top="1/2" right-1 z5
|
2022-12-14 12:10:42 +03:00
|
|
|
:title="$t('action.next')" @click="next"
|
2022-12-04 09:27:08 +03:00
|
|
|
>
|
|
|
|
<div i-ri:arrow-right-s-line text-white />
|
2022-11-30 06:27:19 +03:00
|
|
|
</button>
|
2022-12-04 09:27:08 +03:00
|
|
|
<button
|
2022-12-14 12:10:42 +03:00
|
|
|
v-if="hasPrev" pointer-events-auto btn-action-icon bg="black/20" aria-label="action.next"
|
2023-01-08 10:49:32 +03:00
|
|
|
hover:bg="black/40" dark:bg="white/30" dark:hover-bg="white/20" absolute top="1/2" left-1 z5
|
2022-12-14 12:10:42 +03:00
|
|
|
:title="$t('action.prev')" @click="prev"
|
2022-12-04 09:27:08 +03:00
|
|
|
>
|
|
|
|
<div i-ri:arrow-left-s-line text-white />
|
2022-11-30 06:27:19 +03:00
|
|
|
</button>
|
2023-01-04 11:15:24 +03:00
|
|
|
|
|
|
|
<div flex flex-row items-center mxa>
|
2023-01-18 00:54:03 +03:00
|
|
|
<div flex="~ col center" max-h-full max-w-full>
|
|
|
|
<ModalMediaPreviewCarousel v-model="index" :media="mediaPreviewList" @close="emit('close')" />
|
|
|
|
|
|
|
|
<div bg="black/30" dark:bg="white/10" ms-4 mb-6 mt-4 text-white rounded-full flex="~ center shrink-0" overflow-hidden>
|
|
|
|
<div v-if="mediaPreviewList.length > 1" p="y-1 x-3" rounded-r-0 shrink-0>
|
|
|
|
{{ index + 1 }} / {{ mediaPreviewList.length }}
|
|
|
|
</div>
|
|
|
|
<p
|
|
|
|
v-if="current.description" bg="dark/30" dark:bg="white/10" p="y-1 x-3" rounded-ie-full line-clamp-1
|
|
|
|
ws-pre-wrap break-all :title="current.description" w-full
|
|
|
|
>
|
|
|
|
{{ current.description }}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-04 11:15:24 +03:00
|
|
|
</div>
|
2022-12-14 12:10:42 +03:00
|
|
|
|
|
|
|
<div absolute top-0 w-full flex justify-between>
|
|
|
|
<button
|
|
|
|
btn-action-icon bg="black/30" aria-label="action.close" hover:bg="black/40" dark:bg="white/30"
|
2023-01-08 10:49:32 +03:00
|
|
|
dark:hover-bg="white/20" pointer-events-auto shrink-0 @click="emit('close')"
|
2022-12-14 12:10:42 +03:00
|
|
|
>
|
2022-12-19 23:31:12 +03:00
|
|
|
<div i-ri:close-line text-white />
|
2022-12-14 12:10:42 +03:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-11-30 06:27:19 +03:00
|
|
|
</div>
|
|
|
|
</template>
|