All files / src/features/items ArchivedItemCard.tsx

100% Statements 1/1
50% Branches 1/2
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                1x                                  
import type { Item } from "@/types";
import { Card, CardImage } from "@/components/ui";
import { itemDisplayName, itemInitial } from "@/lib/items";
import { BringBackButton } from "./BringBackButton";
 
// An archived item has no panel (its route resolves live items only), so the card
// offers the way back instead of a link.
export function ArchivedItemCard({ item, coverUrl }: { item: Item; coverUrl?: string }) {
  return (
    <Card variant="card" padding="none" className="flex h-full flex-col overflow-hidden">
      <div className="relative flex aspect-square items-center justify-center overflow-hidden bg-content-soft">
        <CardImage
          src={coverUrl}
          alt={itemDisplayName(item)}
          fallback={<span aria-hidden className="font-display text-5xl text-ink-soft">{itemInitial(item)}</span>}
        />
      </div>
      <div className="space-y-2 p-3">
        <h3 className="min-w-0 break-words text-ink line-clamp-2">{itemDisplayName(item)}</h3>
        {item.brand && <p className="truncate text-xs text-ink-soft">{item.brand}</p>}
        <BringBackButton itemId={item.id} />
      </div>
    </Card>
  );
}