-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatgptCloneUI.js
68 lines (63 loc) · 2.99 KB
/
ChatgptCloneUI.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { useState } from "react";
import { Send, Menu, Plus, Globe, Lightbulb, Image, FileText, MessagesSquare, Brain } from "lucide-react";
export default function ChatUI() {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState("");
const [sidebarOpen, setSidebarOpen] = useState(false);
const sendMessage = () => {
if (!input.trim()) return;
const newMessage = { text: input, sender: "user" };
setMessages([...messages, newMessage, { text: "Thinking...", sender: "ai" }]);
setInput("");
setTimeout(() => {
setMessages((prev) => prev.slice(0, -1).concat({ text: "Hello! How can I help?", sender: "Ai" }));
}, 1000);
};
return (
<div className="flex h-screen bg-gray-900 text-white">
<div className={`w-64 bg-gray-800 p-4 space-y-4 ${sidebarOpen ? "block" : "hidden"} sm:block`}>
<h2 className="text-lg font-bold">ChatGPT</h2>
<button onClick={() => setSidebarOpen(false)} className="sm:hidden text-white">Close</button>
</div>
<div className="flex-1 flex flex-col items-center justify-center text-center p-4">
<h1 className="text-2xl font-bold mb-4">What can I help with?</h1>
<div className="w-full max-w-2xl bg-gray-800 p-4 rounded-lg flex items-center shadow-md">
<Plus className="text-gray-400" />
<input
type="text"
className="flex-1 bg-transparent text-white p-2 outline-none"
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Ask anything"
onKeyDown={(e) => e.key === "Enter" && sendMessage()}
/>
<button onClick={sendMessage} className="ml-2 p-2 bg-blue-600 text-white rounded-lg">
<Send size={20} />
</button>
</div>
<div className="flex space-x-4 mt-4">
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<Globe size={16} /> <span>Search</span>
</button>
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<Lightbulb size={16} /> <span>Reason</span>
</button>
</div>
<div className="flex space-x-4 mt-4">
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<Image size={16} /> <span>Create image</span>
</button>
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<FileText size={16} /> <span>Summarize text</span>
</button>
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<MessagesSquare size={16} /> <span>Get advice</span>
</button>
<button className="bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2">
<Brain size={16} /> <span>Brainstorm</span>
</button>
</div>
</div>
</div>
);
}