MCPcopy Create free account
hub / github.com/abi/screenshot-to-code / UpdateImagePreview

Function UpdateImagePreview

frontend/src/components/UpdateImageUpload.tsx:23–54  ·  view source on GitHub ↗
({ updateImages, setUpdateImages }: Props)

Source from the content-addressed store, hash-verified

21}
22
23export function UpdateImagePreview({ updateImages, setUpdateImages }: Props) {
24 const removeImage = (index: number) => {
25 const newImages = updateImages.filter((_, i) => i !== index);
26 setUpdateImages(newImages);
27 };
28
29 if (updateImages.length === 0) return null;
30
31 return (
32 <div className="px-3 pt-3">
33 <div className="flex flex-wrap gap-2 py-1">
34 {updateImages.map((image, index) => (
35 <div key={index} className="relative flex-shrink-0 group overflow-visible">
36 <div className="flex h-14 w-14 items-center justify-center rounded-lg border border-gray-200 bg-white p-1 shadow-sm dark:border-zinc-700 dark:bg-zinc-900">
37 <img
38 src={image}
39 alt={`Reference ${index + 1}`}
40 className="max-h-full max-w-full object-contain"
41 />
42 </div>
43 <button
44 onClick={() => removeImage(index)}
45 className="absolute -right-1 -top-1 z-10 flex h-5 w-5 items-center justify-center rounded-full border border-white bg-gray-900 text-white opacity-0 shadow transition-opacity group-hover:opacity-100 hover:bg-red-600 dark:border-zinc-900"
46 >
47 <Cross2Icon className="h-2.5 w-2.5" />
48 </button>
49 </div>
50 ))}
51 </div>
52 </div>
53 );
54}
55
56function UpdateImageUpload({ updateImages, setUpdateImages }: Props) {
57 const fileInputRef = useRef<HTMLInputElement>(null);

Callers

nothing calls this directly

Calls 1

removeImageFunction · 0.85

Tested by

no test coverage detected