2025-05-05 20:12:41 +02:00
|
|
|
<template>
|
|
|
|
|
<Dialog>
|
2025-12-09 22:32:22 +01:00
|
|
|
<Card
|
|
|
|
|
class="w-full h-full overflow-hidden relative p-0 *:first:w-full *:first:h-full *:first:object-contain *:first:bg-muted/20"
|
|
|
|
|
>
|
2025-05-05 20:12:41 +02:00
|
|
|
<DialogTrigger v-if="lightbox" :as-child="true">
|
2026-01-09 21:47:12 +01:00
|
|
|
<slot />
|
2025-05-05 20:12:41 +02:00
|
|
|
</DialogTrigger>
|
2026-01-09 21:47:12 +01:00
|
|
|
<slot v-else />
|
2025-05-05 20:12:41 +02:00
|
|
|
<!-- Alt text viewer -->
|
|
|
|
|
<Popover v-if="attachment.description">
|
|
|
|
|
<div class="absolute top-0 right-0 p-2">
|
|
|
|
|
<PopoverTrigger :as-child="true">
|
2025-12-09 22:32:22 +01:00
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="icon"
|
|
|
|
|
title="View alt text"
|
|
|
|
|
>
|
2026-01-09 21:47:12 +01:00
|
|
|
<Captions />
|
2025-05-05 20:12:41 +02:00
|
|
|
</Button>
|
|
|
|
|
</PopoverTrigger>
|
|
|
|
|
</div>
|
|
|
|
|
<PopoverContent>
|
|
|
|
|
<p class="text-sm">{{ attachment.description }}</p>
|
|
|
|
|
</PopoverContent>
|
|
|
|
|
</Popover>
|
|
|
|
|
</Card>
|
2025-12-09 22:32:22 +01:00
|
|
|
<DialogContent
|
|
|
|
|
:hide-close="true"
|
|
|
|
|
class="duration-200 bg-transparent border-none overflow-hidden !animate-none gap-6 w-screen h-screen !max-w-none"
|
|
|
|
|
>
|
2025-05-05 20:12:41 +02:00
|
|
|
<div class="grid grid-rows-[auto_1fr_auto]">
|
|
|
|
|
<div class="flex flex-row gap-2 w-full">
|
2025-12-09 22:32:22 +01:00
|
|
|
<DialogTitle class="sr-only">
|
|
|
|
|
{{ attachment.type }}
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<Button
|
|
|
|
|
as="a"
|
|
|
|
|
:href="attachment?.url"
|
|
|
|
|
target="_blank"
|
|
|
|
|
:download="true"
|
|
|
|
|
variant="outline"
|
|
|
|
|
size="icon"
|
|
|
|
|
class="ml-auto"
|
|
|
|
|
>
|
2026-01-09 21:47:12 +01:00
|
|
|
<Download />
|
2025-05-05 20:12:41 +02:00
|
|
|
</Button>
|
|
|
|
|
<DialogClose :as-child="true">
|
|
|
|
|
<Button variant="outline" size="icon">
|
2026-01-09 21:47:12 +01:00
|
|
|
<X />
|
2025-05-05 20:12:41 +02:00
|
|
|
</Button>
|
|
|
|
|
</DialogClose>
|
|
|
|
|
</div>
|
2025-12-09 22:32:22 +01:00
|
|
|
<div
|
|
|
|
|
class="flex items-center justify-center overflow-hidden *:max-h-[80vh] *:max-w-[80vw] *:w-full *:h-full *:object-contain"
|
|
|
|
|
>
|
2026-01-09 21:47:12 +01:00
|
|
|
<slot />
|
2025-05-05 20:12:41 +02:00
|
|
|
</div>
|
|
|
|
|
<DialogDescription class="flex items-center justify-center">
|
2025-12-09 22:32:22 +01:00
|
|
|
<Card
|
|
|
|
|
v-if="attachment.description"
|
|
|
|
|
class="max-w-md max-h-48 overflow-auto text-sm"
|
|
|
|
|
>
|
2025-05-05 20:12:41 +02:00
|
|
|
<p>{{ attachment.description }}</p>
|
|
|
|
|
</Card>
|
|
|
|
|
</DialogDescription>
|
|
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { Attachment } from "@versia/client/schemas";
|
2025-05-05 20:12:41 +02:00
|
|
|
import { Captions, Download, File, X } from "lucide-vue-next";
|
2025-05-26 11:19:15 +02:00
|
|
|
import type { z } from "zod";
|
2025-05-05 20:12:41 +02:00
|
|
|
import { Button } from "~/components/ui/button";
|
|
|
|
|
import { Card } from "~/components/ui/card";
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogClose,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogDescription,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogTrigger,
|
|
|
|
|
} from "~/components/ui/dialog";
|
|
|
|
|
import {
|
|
|
|
|
Popover,
|
|
|
|
|
PopoverContent,
|
|
|
|
|
PopoverTrigger,
|
|
|
|
|
} from "~/components/ui/popover";
|
|
|
|
|
|
|
|
|
|
const { attachment, lightbox = false } = defineProps<{
|
2025-05-26 11:19:15 +02:00
|
|
|
attachment: z.infer<typeof Attachment>;
|
2025-05-05 20:12:41 +02:00
|
|
|
lightbox?: boolean;
|
|
|
|
|
}>();
|
|
|
|
|
</script>
|