elk/components/status/StatusAttachment.vue

37 lines
838 B
Vue
Raw Normal View History

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