feat: preview multiple images

This commit is contained in:
Anthony Fu 2022-11-30 11:27:19 +08:00
parent 568a333d7c
commit cf7cd1fd6c
7 changed files with 92 additions and 23 deletions

View file

@ -4,6 +4,7 @@ import type { Attachment } from 'masto'
const { attachment } = defineProps<{
attachment: Attachment
attachments?: Attachment[]
}>()
const src = $computed(() => attachment.remoteUrl || attachment.url || attachment.previewUrl!)
@ -62,10 +63,7 @@ const aspectRatio = computed(() => {
focus:ring="2 primary inset"
rounded-lg
aria-label="Open image preview dialog"
@click="openImagePreviewDialog({
src,
alt: attachment.description!,
})"
@click="openMediaPreview(attachments ? attachments : [attachment], attachments?.indexOf(attachment) || 0)"
>
<CommonBlurhash
:blurhash="attachment.blurhash"

View file

@ -9,7 +9,11 @@ const { status } = defineProps<{
<template>
<div class="status-media-container" :class="`status-media-container-${status.mediaAttachments.length}`">
<template v-for="attachment of status.mediaAttachments" :key="attachment.id">
<StatusAttachment :attachment="attachment" class="w-full h-full" />
<StatusAttachment
:attachment="attachment"
:attachments="status.mediaAttachments"
class="w-full h-full"
/>
</template>
</div>
</template>