Spaces:
Running
Running
import { useState } from 'react'; | |
import { Send } from 'lucide-react'; | |
const ImageRefiner = ({ | |
onRefine, | |
isLoading, | |
hasGeneratedContent | |
}) => { | |
const [inputValue, setInputValue] = useState(''); | |
const handleSubmit = (e) => { | |
e.preventDefault(); | |
if (!inputValue.trim()) return; | |
onRefine(inputValue); | |
setInputValue(''); | |
}; | |
if (!hasGeneratedContent) return null; | |
return ( | |
<form onSubmit={handleSubmit} className="flex gap-2"> | |
<input | |
type="text" | |
value={inputValue} | |
onChange={(e) => setInputValue(e.target.value)} | |
placeholder="Type to refine the image..." | |
disabled={isLoading} | |
className="flex-1 px-4 py-2 bg-white border border-gray-200 rounded-xl text-gray-800 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-400 disabled:opacity-50 disabled:cursor-not-allowed" | |
/> | |
<button | |
type="submit" | |
disabled={isLoading || !inputValue.trim()} | |
className="p-2 bg-gray-900 text-white rounded-xl hover:bg-gray-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed" | |
> | |
<Send className="w-5 h-5" /> | |
</button> | |
</form> | |
); | |
}; | |
export default ImageRefiner; |