akhaliq HF Staff commited on
Commit
9f46f4b
·
verified ·
1 Parent(s): d4f52d9

Upload components/ChatInput.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/ChatInput.jsx +50 -0
components/ChatInput.jsx ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ImageUpload from './ImageUpload'
2
+
3
+ export default function ChatInput({
4
+ input,
5
+ setInput,
6
+ uploadedImage,
7
+ setUploadedImage,
8
+ onImageUpload,
9
+ onSubmit,
10
+ onKeyPress,
11
+ isLoading,
12
+ }) {
13
+ return (
14
+ <div className="border-t border-gray-200 p-4 bg-white">
15
+ <div className="flex items-end space-x-2">
16
+ <ImageUpload
17
+ onImageUpload={onImageUpload}
18
+ uploadedImage={uploadedImage}
19
+ onRemove={() => setUploadedImage(null)}
20
+ />
21
+ <div className="flex-1">
22
+ <textarea
23
+ value={input}
24
+ onChange={(e) => setInput(e.target.value)}
25
+ onKeyDown={onKeyPress}
26
+ placeholder={uploadedImage ? "Ask a question about the image..." : "Type your message..."}
27
+ rows={1}
28
+ className="w-full resize-none rounded-lg border border-gray-300 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
29
+ disabled={isLoading}
30
+ />
31
+ </div>
32
+ <button
33
+ onClick={onSubmit}
34
+ disabled={isLoading || (!input.trim() && !uploadedImage)}
35
+ className={`px-4 py-2 rounded-lg font-medium transition-colors ${
36
+ isLoading || (!input.trim() && !uploadedImage)
37
+ ? 'bg-gray-300 text-gray-500 cursor-not-allowed'
38
+ : 'bg-blue-600 text-white hover:bg-blue-700'
39
+ }`}
40
+ aria-label="Send message"
41
+ >
42
+ {isLoading ? '⏳' : 'Send'}
43
+ </button>
44
+ </div>
45
+ <p className="text-xs text-gray-500 mt-2">
46
+ Press Enter to send • Shift+Enter for new line
47
+ </p>
48
+ </div>
49
+ )
50
+ }