2022-11-30 12:27:19 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
const emit = defineEmits(['close'])
|
|
|
|
|
|
|
|
const current = computed(() => mediaPreviewList.value[mediaPreviewIndex.value])
|
|
|
|
const hasNext = computed(() => mediaPreviewIndex.value < mediaPreviewList.value.length - 1)
|
|
|
|
const hasPrev = computed(() => mediaPreviewIndex.value > 0)
|
|
|
|
|
|
|
|
const keys = useMagicKeys()
|
|
|
|
|
|
|
|
whenever(keys.arrowLeft, prev)
|
|
|
|
whenever(keys.arrowRight, next)
|
|
|
|
|
|
|
|
function next() {
|
|
|
|
if (hasNext.value)
|
|
|
|
mediaPreviewIndex.value++
|
|
|
|
}
|
|
|
|
|
|
|
|
function prev() {
|
|
|
|
if (hasPrev.value)
|
|
|
|
mediaPreviewIndex.value--
|
|
|
|
}
|
|
|
|
|
|
|
|
function onClick(e: MouseEvent) {
|
|
|
|
const path = e.composedPath() as HTMLElement[]
|
2022-12-20 06:34:58 +09:00
|
|
|
const el = path.find(el => ['A', 'BUTTON', 'IMG', 'VIDEO', 'P'].includes(el.tagName?.toUpperCase()))
|
2022-11-30 12:27:19 +09:00
|
|
|
if (!el)
|
|
|
|
emit('close')
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-12-20 06:34:58 +09:00
|
|
|
<div relative h-full w-full flex pt-12 @click="onClick">
|
2022-12-04 15:27:08 +09:00
|
|
|
<button
|
2022-12-14 18:10:42 +09:00
|
|
|
v-if="hasNext" pointer-events-auto btn-action-icon bg="black/20" :aria-label="$t('action.previous')"
|
|
|
|
hover:bg="black/40" dark:bg="white/30" dark:hover:bg="white/20" absolute top="1/2" right-1
|
|
|
|
:title="$t('action.next')" @click="next"
|
2022-12-04 15:27:08 +09:00
|
|
|
>
|
|
|
|
<div i-ri:arrow-right-s-line text-white />
|
2022-11-30 12:27:19 +09:00
|
|
|
</button>
|
2022-12-04 15:27:08 +09:00
|
|
|
<button
|
2022-12-14 18:10:42 +09:00
|
|
|
v-if="hasPrev" pointer-events-auto btn-action-icon bg="black/20" aria-label="action.next"
|
|
|
|
hover:bg="black/40" dark:bg="white/30" dark:hover:bg="white/20" absolute top="1/2" left-1
|
|
|
|
:title="$t('action.prev')" @click="prev"
|
2022-12-04 15:27:08 +09:00
|
|
|
>
|
|
|
|
<div i-ri:arrow-left-s-line text-white />
|
2022-11-30 12:27:19 +09:00
|
|
|
</button>
|
2022-12-14 18:10:42 +09:00
|
|
|
<img
|
|
|
|
:src="current.url || current.previewUrl" :alt="current.description || ''" max-h-full max-w-full ma
|
2022-12-02 16:02:44 +09:00
|
|
|
>
|
2022-12-14 18:10:42 +09: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"
|
|
|
|
dark:hover:bg="white/20" pointer-events-auto shrink-0 @click="emit('close')"
|
|
|
|
>
|
2022-12-20 05:31:12 +09:00
|
|
|
<div i-ri:close-line text-white />
|
2022-12-14 18:10:42 +09:00
|
|
|
</button>
|
2023-01-01 23:29:11 +09:00
|
|
|
<div bg="black/30" dark:bg="white/10" ms-4 my-auto text-white rounded-full flex="~ center" overflow-hidden>
|
2022-12-14 18:10:42 +09:00
|
|
|
<div v-if="mediaPreviewList.length > 1" p="y-1 x-2" rounded-r-0 shrink-0>
|
|
|
|
{{ mediaPreviewIndex + 1 }} / {{ mediaPreviewList.length }}
|
|
|
|
</div>
|
|
|
|
<p
|
2023-01-01 23:29:11 +09:00
|
|
|
v-if="current.description" bg="dark/30" dark:bg="white/10" p="y-1 x-2" rounded-ie-full line-clamp-1
|
2022-12-14 18:10:42 +09:00
|
|
|
ws-pre-wrap break-all :title="current.description" w-full
|
|
|
|
>
|
|
|
|
{{ current.description }}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-30 12:27:19 +09:00
|
|
|
</div>
|
|
|
|
</template>
|