2024-04-22 09:38:51 +02:00
|
|
|
<template>
|
2024-06-05 02:03:15 +02:00
|
|
|
<div tabindex="0" aria-label="Open attachment in lightbox"
|
2024-04-22 09:38:51 +02:00
|
|
|
class="aspect-video w-full rounded ring-white/5 shadow overflow-hidden ring-1 hover:ring-2 duration-100">
|
2024-05-05 07:33:50 +02:00
|
|
|
<img v-if="attachment.type === 'image'" tabindex="-1"
|
2024-04-22 09:38:51 +02:00
|
|
|
class="object-cover w-full h-full rounded duration-150 hover:scale-[102%] ease-in-out" :src="attachment.url"
|
2024-06-05 02:03:15 +02:00
|
|
|
:alt="attachment.description ?? ''" :title="attachment.description ?? ''" @click="openLightbox"
|
|
|
|
|
@keydown="openLightbox" />
|
2024-04-22 09:38:51 +02:00
|
|
|
<video v-else-if="attachment.type === 'video'" class="object-cover w-full h-full rounded" controls
|
|
|
|
|
:alt="attachment.description ?? ''" :title="attachment.description ?? ''">
|
|
|
|
|
<source :src="attachment.url" type="video/mp4" />
|
|
|
|
|
Your browser does not support the video tag.
|
|
|
|
|
</video>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-04-25 08:56:01 +02:00
|
|
|
import type { Attachment } from "~/types/mastodon/attachment";
|
2024-04-22 09:38:51 +02:00
|
|
|
|
2024-06-05 02:03:15 +02:00
|
|
|
const props = defineProps<{
|
2024-04-22 09:38:51 +02:00
|
|
|
attachment: Attachment;
|
|
|
|
|
}>();
|
2024-06-05 02:03:15 +02:00
|
|
|
|
|
|
|
|
const openLightbox = () => {
|
|
|
|
|
useEvent("attachment:view", props.attachment);
|
|
|
|
|
};
|
2024-04-22 09:38:51 +02:00
|
|
|
</script>
|