Files
frontend/apps/as/src/shared/ui/uploaded-file-chip.tsx
T

60 lines
1.4 KiB
TypeScript

"use client";
import { Paperclip, X } from "lucide-react";
import { TextShimmer } from "./text-shimmer";
interface UploadedFileChipProps {
fileName: string;
isUploading?: boolean;
onRemove?: () => void;
onDownload?: () => void;
}
function UploadedFileChip({
fileName,
isUploading = false,
onRemove,
onDownload,
}: UploadedFileChipProps) {
const canDownload = Boolean(onDownload) && !isUploading;
return (
<div className="inline-flex items-center justify-between gap-2 rounded-sm border bg-accent px-3 py-2">
<Paperclip className="size-5 shrink-0" />
{canDownload ? (
<button
type="button"
className="cursor-pointer text-left hover:underline"
aria-label={`${fileName} 다운로드`}
onClick={onDownload}
>
<TextShimmer className="text-xl" active={isUploading}>
{fileName}
</TextShimmer>
</button>
) : (
<TextShimmer className="text-xl" active={isUploading}>
{fileName}
</TextShimmer>
)}
{onRemove ? (
<button
type="button"
aria-label="삭제"
onClick={(event) => {
event.preventDefault();
onRemove();
}}
disabled={isUploading}
>
<X className="size-5 shrink-0 text-destructive" />
</button>
) : null}
</div>
);
}
export { UploadedFileChip };
export type { UploadedFileChipProps };