feat: support blurhash

This commit is contained in:
Anthony Fu 2022-11-21 21:21:53 +08:00
parent af2c6d622b
commit 757a93c2a2
8 changed files with 102 additions and 25 deletions

View file

@ -4,21 +4,33 @@ import type { Attachment } from 'masto'
const { attachment } = defineProps<{
attachment: Attachment
}>()
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
})
</script>
<template>
<template v-if="attachment.type === 'image'">
<img
<template v-if="attachment.type === 'image' || attachment.type === 'gifv'">
<CommonBlurhash
:blurhash="attachment.blurhash"
class="status-attachment-image"
:src="attachment.previewUrl!"
:alt="attachment.description!"
border="~ border"
:style="{
aspectRatio,
}"
object-cover rounded-lg
>
/>
</template>
<template v-else>
<div>
TODO: {{ attachment }}
</div>
TODO:
<pre>{{ attachment }}
</pre>
</template>
</template>

View file

@ -27,16 +27,13 @@ const { status } = defineProps<{
.status-media-container-2 {
display: grid;
grid-template-columns: 1fr 1fr;
aspect-ratio: 2/1;
}
.status-media-container-3 {
display: grid;
aspect-ratio: 16/9;
grid-template-columns: 1fr 1fr;
}
.status-media-container-4 {
display: grid;
aspect-ratio: 16/9;
grid-template-columns: 1fr 1fr;
}
</style>