vision-agent / components /empty-screen.tsx
MingruiZhang's picture
mutil image selection
93dd66e
raw
history blame
1.88 kB
import { useAtom } from 'jotai';
import { useDropzone } from 'react-dropzone';
import { datasetAtom } from '../state';
import Image from 'next/image';
import useImageUpload from '../lib/hooks/useImageUpload';
const examples = [
'https://landing-lens-support.s3.us-east-2.amazonaws.com/vision-agent-examples/cereal-example.jpg',
'https://landing-lens-support.s3.us-east-2.amazonaws.com/vision-agent-examples/people-example.jpeg',
'https://landing-lens-support.s3.us-east-2.amazonaws.com/vision-agent-examples/house-exmaple.jpg',
'https://landing-lens-support.s3.us-east-2.amazonaws.com/vision-agent-examples/safari-example.png',
];
export function EmptyScreen() {
const [, setTarget] = useAtom(datasetAtom);
const { getRootProps, getInputProps } = useImageUpload();
return (
<div className="mx-auto max-w-2xl px-4">
<div className="rounded-lg border bg-background p-8">
<h1 className="mb-2 text-lg font-semibold">Welcome to Vision Agent</h1>
<p>Lets start by choosing an image</p>
<div
{...getRootProps()}
className="dropzone border-2 border-dashed border-gray-400 w-full h-64 flex items-center justify-center rounded-lg mt-4 cursor-pointer"
>
<input {...getInputProps()} />
<p className="text-gray-400 text-lg">
Drag or drop image here, or click to select images
</p>
</div>
<p className="mt-4 mb-2">
You can also choose from below examples we provided
</p>
<div className="flex">
{examples.map((example, index) => (
<Image
src={example}
key={index}
width={120}
height={120}
alt="example images"
className="object-cover rounded mr-3 shadow-md hover:scale-105 cursor-pointer transition-transform"
onClick={() =>
setTarget([{ url: example, name: 'i-1', selected: false }])
}
/>
))}
</div>
</div>
</div>
);
}