({
asset,
vaultRoot,
onOpen,
onContextMenu
}: {
asset: AssetMeta
vaultRoot: string | null
onOpen: () => void
onContextMenu?: (e: React.MouseEvent) => void
})
| 1053 | } |
| 1054 | |
| 1055 | function AssetCard({ |
| 1056 | asset, |
| 1057 | vaultRoot, |
| 1058 | onOpen, |
| 1059 | onContextMenu |
| 1060 | }: { |
| 1061 | asset: AssetMeta |
| 1062 | vaultRoot: string | null |
| 1063 | onOpen: () => void |
| 1064 | onContextMenu?: (e: React.MouseEvent) => void |
| 1065 | }): JSX.Element { |
| 1066 | const url = assetUrl(vaultRoot, asset.path) |
| 1067 | |
| 1068 | return ( |
| 1069 | <button |
| 1070 | type="button" |
| 1071 | onClick={onOpen} |
| 1072 | onContextMenu={onContextMenu} |
| 1073 | draggable |
| 1074 | onDragStart={(e) => setDragPayload(e, { kind: 'asset', path: asset.path })} |
| 1075 | className="flex h-full min-h-[154px] flex-col overflow-hidden rounded-xl border border-paper-300/70 bg-paper-50/24 text-left transition-colors hover:border-paper-400 hover:bg-paper-100/40" |
| 1076 | > |
| 1077 | <div className="flex min-h-0 flex-1 items-center justify-center bg-paper-200/25"> |
| 1078 | {asset.kind === 'image' && url ? ( |
| 1079 | <img |
| 1080 | src={url} |
| 1081 | alt={asset.name} |
| 1082 | className="max-h-[170px] w-full object-cover" |
| 1083 | loading="lazy" |
| 1084 | /> |
| 1085 | ) : ( |
| 1086 | <div className="px-4 text-xs uppercase tracking-[0.18em] text-ink-500"> |
| 1087 | {asset.kind} |
| 1088 | </div> |
| 1089 | )} |
| 1090 | </div> |
| 1091 | <div className="border-t border-paper-300/70 px-3 py-2"> |
| 1092 | <div className="truncate text-sm font-medium text-ink-900">{asset.name}</div> |
| 1093 | <div className="mt-0.5 flex items-center justify-between gap-2 text-xs text-ink-500"> |
| 1094 | <span className="truncate">{asset.path}</span> |
| 1095 | <span className="shrink-0">{formatBytes(asset.size)}</span> |
| 1096 | </div> |
| 1097 | </div> |
| 1098 | </button> |
| 1099 | ) |
| 1100 | } |
| 1101 | |
| 1102 | function AssetRow({ |
| 1103 | asset, |
nothing calls this directly
no test coverage detected