This commit is contained in:
2025-05-21 08:52:33 +03:00
parent e992d388fb
commit 4e5fca2402
68 changed files with 358 additions and 1398 deletions

View File

@@ -10,12 +10,7 @@ import {
DialogTitle,
DialogTrigger,
} from "~/components/ui/dialog"; // Shadcn UI Dialog
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "~/components/ui/tooltip"; // Shadcn UI Tooltip
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "~/components/ui/tooltip"; // Shadcn UI Tooltip
import type { UploadedFile } from "~/lib/api/types"; // Adjust path as needed
import { formatFileSize } from "~/lib/utils"; // Adjust path
import { FileIcon } from "./file-icon";
@@ -24,9 +19,7 @@ interface ChatMessageAttachmentProps {
file: UploadedFile;
}
export default function ChatMessageAttachment({
file,
}: ChatMessageAttachmentProps) {
export default function ChatMessageAttachment({ file }: ChatMessageAttachmentProps) {
if (file.contentType.startsWith("image/")) {
return <ImageAttachment file={file} />;
}
@@ -38,29 +31,17 @@ function GenericFileAttachment({ file }: ChatMessageAttachmentProps) {
<TooltipProvider delayDuration={100}>
<div className="flex items-center gap-3 rounded-lg border bg-card p-3 shadow-sm ">
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md">
<FileIcon
className="h-8 w-8 text-muted-foreground"
contentType={file.contentType}
/>
<FileIcon className="h-8 w-8 text-muted-foreground" contentType={file.contentType} />
</div>
<div className="flex-1 overflow-hidden">
<p className="truncate text-sm font-medium text-card-foreground">
{file.filename}
</p>
<p className="text-xs text-muted-foreground">
{formatFileSize(file.size)}
</p>
<p className="truncate text-sm font-medium text-card-foreground">{file.filename}</p>
<p className="text-xs text-muted-foreground">{formatFileSize(file.size)}</p>
</div>
<div className="flex items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a
href={file.url}
target="_blank"
rel="noreferrer"
download={file.filename}
>
<a href={file.url} target="_blank" rel="noreferrer" download={file.filename}>
<Download className="h-4 w-4" />
<span className="sr-only">Download</span>
</a>
@@ -71,15 +52,9 @@ function GenericFileAttachment({ file }: ChatMessageAttachmentProps) {
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a
href={file.url}
target="_blank"
rel="noreferrer"
>
<a href={file.url} target="_blank" rel="noreferrer">
<ExternalLink className="h-4 w-4" />
<span className="sr-only">
Open in new tab
</span>
<span className="sr-only">Open in new tab</span>
</a>
</Button>
</TooltipTrigger>
@@ -97,10 +72,7 @@ function ImageAttachment({ file }: ChatMessageAttachmentProps) {
<TooltipProvider delayDuration={100}>
<div className="group relative w-48 cursor-pointer sm:w-64">
<DialogTrigger asChild>
<AspectRatio
ratio={16 / 9}
className="overflow-hidden rounded-lg border bg-muted"
>
<AspectRatio ratio={16 / 9} className="overflow-hidden rounded-lg border bg-muted">
<img
src={file.url}
alt={file.filename}
@@ -121,9 +93,7 @@ function ImageAttachment({ file }: ChatMessageAttachmentProps) {
<DialogContent className="max-w-3xl p-0">
<DialogHeader className="p-4 pb-0">
<DialogTitle className="truncate">
{file.filename}
</DialogTitle>
<DialogTitle className="truncate">{file.filename}</DialogTitle>
</DialogHeader>
<div className="p-4 pt-0 max-h-[70vh] overflow-y-auto">
<img
@@ -135,8 +105,7 @@ function ImageAttachment({ file }: ChatMessageAttachmentProps) {
<DialogFooter className="flex-col items-stretch gap-2 border-t p-4 sm:flex-row sm:justify-end sm:space-x-2">
<Button variant="outline" asChild>
<a href={file.url} target="_blank" rel="noreferrer">
<ExternalLink className="mr-2 h-4 w-4" /> Open
original
<ExternalLink className="mr-2 h-4 w-4" /> Open original
</a>
</Button>
<Button asChild>