import type { LiveDownload } from "../hooks/useDownloads"; import type { FeedItem } from "../types"; import { humanEta } from "./format"; import { CONTROL_H } from "./ui"; interface Props { item: FeedItem; live?: LiveDownload; online: boolean; onDownload: () => void; onCancel: () => void; onDelete: () => void; } const CHIP = `inline-flex ${CONTROL_H} shrink-0 cursor-pointer items-center justify-center rounded-lg ` + "px-2.5 text-[12px] font-medium"; export default function DownloadButton({ item, live, online, onDownload, onCancel, onDelete, }: Props) { const state = live?.state ?? item.state ?? null; const pct = live?.pct ?? item.pct ?? null; const error = live?.error ?? item.error ?? null; if (state === "done") { // Neutral until hovered, then reveals red — destruction is never // pre-coloured on a control that is not currently destructive. return ( ); } if (state === "running" || state === "queued") { const known = state === "running" && pct != null; return ( ); } const failed = state === "failed"; return ( ); }