elk/components/status/StatusAttachment.vue

37 lines
838 B
Vue
Raw Normal View History

2022-11-14 03:33:09 +00:00
<script setup lang="ts">
import type { Attachment } from 'masto'
const { attachment } = defineProps<{
attachment: Attachment
}>()
2022-11-21 13:21:53 +00:00
const aspectRatio = computed(() => {
if (attachment.meta?.original?.aspect)
return attachment.meta.original.aspect
if (attachment.meta?.small?.aspect)
return attachment.meta.small.aspect
return undefined
})
2022-11-14 03:33:09 +00:00
</script>
<template>
2022-11-21 13:21:53 +00:00
<template v-if="attachment.type === 'image' || attachment.type === 'gifv'">
<CommonBlurhash
:blurhash="attachment.blurhash"
2022-11-14 03:33:09 +00:00
class="status-attachment-image"
:src="attachment.previewUrl!"
:alt="attachment.description!"
2022-11-14 14:54:30 +00:00
border="~ border"
2022-11-21 13:21:53 +00:00
:style="{
aspectRatio,
}"
2022-11-14 03:33:09 +00:00
object-cover rounded-lg
2022-11-21 13:21:53 +00:00
/>
2022-11-14 03:33:09 +00:00
</template>
<template v-else>
2022-11-21 13:21:53 +00:00
TODO:
<pre>{{ attachment }}
</pre>
2022-11-14 03:33:09 +00:00
</template>
</template>