2022-11-30 12:27:19 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
const emit = defineEmits(['close'])
|
|
|
|
|
2023-01-04 17:15:24 +09:00
|
|
|
const locked = useScrollLock(document.body)
|
2022-11-30 12:27:19 +09:00
|
|
|
|
2023-01-04 17:15:24 +09:00
|
|
|
// Use to avoid strange error when directlying assigning to v-model on ModelMediaPreviewCarousel
|
|
|
|
const index = mediaPreviewIndex
|
2023-01-02 04:59:31 +09:00
|
|
|
|
2023-01-04 17:15:24 +09: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 06:13:14 +09:00
|
|
|
|
2022-11-30 12:27:19 +09:00
|
|
|
const keys = useMagicKeys()
|
|
|
|
|
|
|
|
whenever(keys.arrowLeft, prev)
|
|
|
|
whenever(keys.arrowRight, next)
|
|
|
|
|
|
|
|
function next() {
|
|
|
|
if (hasNext.value)
|
2023-01-04 17:15:24 +09:00
|
|
|
index.value++
|
2022-11-30 12:27:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function prev() {
|
|
|
|
if (hasPrev.value)
|
2023-01-04 17:15:24 +09:00
|
|
|
index.value--
|
2022-11-30 12:27:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
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')
|
|
|
|
}
|
2023-01-04 17:15:24 +09:00
|
|
|
|
|
|
|
onMounted(() => locked.value = true)
|
|
|
|
onUnmounted(() => locked.value = false)
|
2022-11-30 12:27:19 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-01-04 17:15:24 +09:00
|
|
|
<div relative h-full w-full flex pt-12 w-100vh @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')"
|
2023-01-08 16:49:32 +09:00
|
|
|
hover:bg="black/40" dark:bg="white/30" dark-hover:bg="white/20" absolute top="1/2" right-1 z5
|
2022-12-14 18:10:42 +09:00
|
|
|
: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"
|
2023-01-08 16:49:32 +09:00
|
|
|
hover:bg="black/40" dark:bg="white/30" dark:hover-bg="white/20" absolute top="1/2" left-1 z5
|
2022-12-14 18:10:42 +09:00
|
|
|
: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>
|
2023-01-04 17:15:24 +09:00
|
|
|
|
2023-06-13 03:46:53 +09:00
|
|
|
<div flex="~ col center" h-full w-full>
|
|
|
|
<ModalMediaPreviewCarousel v-model="index" :media="mediaPreviewList" @close="emit('close')" />
|
2023-01-18 06:54:03 +09:00
|
|
|
|
2023-06-13 03:46:53 +09:00
|
|
|
<div bg="black/30" dark:bg="white/10" 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 }}
|
2023-01-18 06:54:03 +09:00
|
|
|
</div>
|
2023-06-13 03:46:53 +09:00
|
|
|
<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>
|
2023-01-18 06:54:03 +09:00
|
|
|
</div>
|
2023-01-04 17:15:24 +09:00
|
|
|
</div>
|
2022-12-14 18:10:42 +09:00
|
|
|
|
2023-01-22 16:47:49 +09:00
|
|
|
<div absolute top-0 w-full flex justify-end>
|
2022-12-14 18:10:42 +09:00
|
|
|
<button
|
|
|
|
btn-action-icon bg="black/30" aria-label="action.close" hover:bg="black/40" dark:bg="white/30"
|
2023-01-08 16:49:32 +09:00
|
|
|
dark:hover-bg="white/20" pointer-events-auto shrink-0 @click="emit('close')"
|
2022-12-14 18:10:42 +09:00
|
|
|
>
|
2022-12-20 05:31:12 +09:00
|
|
|
<div i-ri:close-line text-white />
|
2022-12-14 18:10:42 +09:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-11-30 12:27:19 +09:00
|
|
|
</div>
|
|
|
|
</template>
|