Skip to content

Commit fa67b88

Browse files
committed
UI Polish: Add suggested prompts and refine styling
1 parent 4fca322 commit fa67b88

1 file changed

Lines changed: 55 additions & 30 deletions

File tree

components/chat-widget.tsx

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@ export function ChatWidget() {
2727
}
2828
}, [messages, isOpen]);
2929

30-
const handleSubmit = async (e: React.FormEvent) => {
31-
e.preventDefault();
32-
if (!input.trim() || isLoading) return;
30+
// Suggestions configuration
31+
const suggestions = [
32+
{ icon: "💡", label: "What's your most impressive project?" },
33+
{ icon: "🚀", label: "Why are you a good fit for a startup?" },
34+
{ icon: "🛠️", label: "What are your core skills?" },
35+
];
36+
37+
const handleSend = async (text: string) => {
38+
if (!text.trim() || isLoading) return;
3339

34-
const userMsg = input.trim();
40+
const userMsg = text.trim();
3541
setMessages((prev) => [...prev, { role: "user", text: userMsg }]);
3642
setInput("");
3743
setIsLoading(true);
3844

3945
try {
40-
// Call the Server Action (Secure Backend)
46+
// Call the Server Action
4147
const result = await chatWithGemini(userMsg);
4248

4349
if (result.error) {
@@ -56,6 +62,11 @@ export function ChatWidget() {
5662
}
5763
};
5864

65+
const handleSubmit = (e: React.FormEvent) => {
66+
e.preventDefault();
67+
handleSend(input);
68+
};
69+
5970
return (
6071
<>
6172
{/* Floating Toggle Button */}
@@ -117,72 +128,86 @@ export function ChatWidget() {
117128
animate={{ opacity: 1, y: 0, scale: 1 }}
118129
exit={{ opacity: 0, y: 20, scale: 0.95 }}
119130
transition={{ duration: 0.2 }}
120-
className="fixed bottom-24 right-6 z-50 w-[90vw] md:w-[400px] h-[500px] max-h-[70vh] flex flex-col rounded-xl overflow-hidden border border-cyan/30 bg-[#030304]/95 backdrop-blur-xl shadow-2xl"
131+
className="fixed bottom-24 right-6 z-50 w-[90vw] md:w-[400px] h-[550px] max-h-[75vh] flex flex-col rounded-2xl overflow-hidden border border-zinc-800 bg-zinc-950/95 backdrop-blur-xl shadow-2xl"
121132
>
122133
{/* Header */}
123-
<div className="flex items-center justify-between px-4 py-3 border-b border-cyan/20 bg-cyan/5">
134+
<div className="flex items-center justify-between px-4 py-4 border-b border-zinc-800 bg-zinc-900/50">
124135
<div className="flex items-center gap-2">
125-
<Cpu className="w-4 h-4 text-cyan" />
126-
<span className="font-mono text-xs font-bold tracking-widest text-cyan uppercase">
127-
AI Assistant // Online
136+
<span className="font-sans text-sm font-semibold tracking-wide text-zinc-100">
137+
Ask DevendraAI
128138
</span>
129139
</div>
140+
<button onClick={() => setIsOpen(false)} className="text-zinc-500 hover:text-white transition-colors">
141+
<X className="w-5 h-5" />
142+
</button>
130143
</div>
131144

132145
{/* Messages Area */}
133146
<div
134147
ref={scrollRef}
135-
className="flex-1 overflow-y-auto p-4 space-y-4 font-mono text-sm scrollbar-thin scrollbar-thumb-cyan/20 scrollbar-track-transparent"
148+
className="flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-zinc-700/50 scrollbar-track-transparent"
136149
>
137150
{messages.map((msg, i) => (
138151
<div
139152
key={i}
140153
className={`flex ${msg.role === "user" ? "justify-end" : "justify-start"}`}
141154
>
142155
<div
143-
className={`max-w-[85%] p-3 rounded-lg border ${
156+
className={`max-w-[85%] p-3.5 rounded-2xl text-sm leading-relaxed ${
144157
msg.role === "user"
145-
? "bg-cyan/10 border-cyan/30 text-cyan-50 rounded-br-none"
146-
: "bg-zinc-900/80 border-zinc-800 text-amber-50/90 rounded-bl-none border-l-2 border-l-amber-500/50"
158+
? "bg-purple-600 text-white rounded-br-none"
159+
: "bg-zinc-800/80 text-zinc-200 rounded-bl-none border border-zinc-700/50"
147160
}`}
148161
>
149-
{msg.role === "model" && (
150-
<span className="block text-[10px] text-zinc-500 mb-1 tracking-wider uppercase">
151-
AI_RESPONSE
152-
</span>
153-
)}
154-
<p className="leading-relaxed whitespace-pre-wrap">{msg.text}</p>
162+
<p className="whitespace-pre-wrap">{msg.text}</p>
155163
</div>
156164
</div>
157165
))}
158166

167+
{/* Suggested Prompts (Only show if only 1 message exists) */}
168+
{messages.length === 1 && (
169+
<div className="flex flex-col gap-2 mt-4 px-1">
170+
{suggestions.map((s, i) => (
171+
<button
172+
key={i}
173+
onClick={() => handleSend(s.label)}
174+
className="flex items-center gap-3 p-3 rounded-xl bg-zinc-900/50 border border-zinc-800 hover:border-purple-500/50 hover:bg-zinc-800 transition-all text-left group"
175+
>
176+
<span className="text-lg">{s.icon}</span>
177+
<span className="text-sm text-zinc-400 group-hover:text-purple-300 transition-colors">
178+
{s.label}
179+
</span>
180+
</button>
181+
))}
182+
</div>
183+
)}
184+
159185
{isLoading && (
160186
<div className="flex justify-start">
161-
<div className="bg-zinc-900/50 border border-zinc-800 p-3 rounded-lg rounded-bl-none flex items-center gap-2">
162-
<Loader2 className="w-4 h-4 text-cyan animate-spin" />
163-
<span className="text-xs text-zinc-500 animate-pulse">Processing Query...</span>
187+
<div className="bg-zinc-800/80 border border-zinc-700/50 p-3 rounded-2xl rounded-bl-none flex items-center gap-2">
188+
<Loader2 className="w-4 h-4 text-purple-400 animate-spin" />
189+
<span className="text-xs text-zinc-400">Thinking...</span>
164190
</div>
165191
</div>
166192
)}
167193
</div>
168194

169195
{/* Input Area */}
170-
<form onSubmit={handleSubmit} className="p-4 border-t border-cyan/20 bg-background/50">
171-
<div className="relative flex items-center gap-2">
172-
<span className="text-cyan font-mono">{">"}</span>
196+
<form onSubmit={handleSubmit} className="p-4 bg-zinc-900/30">
197+
<div className="relative flex items-center gap-2 bg-zinc-900/80 border border-zinc-800 rounded-full px-2 py-1.5 focus-within:border-purple-500/50 focus-within:ring-1 focus-within:ring-purple-500/20 transition-all">
173198
<input
174199
type="text"
175200
value={input}
176201
onChange={(e) => setInput(e.target.value)}
177-
placeholder="Execute query..."
178-
className="flex-1 bg-transparent border-none outline-none font-mono text-sm text-foreground placeholder:text-muted-foreground/50 focus:ring-0"
202+
placeholder="Ask about skills, projects..."
203+
className="flex-1 bg-transparent border-none outline-none text-sm text-zinc-200 placeholder:text-zinc-500 px-3 py-2 focus:ring-0"
179204
/>
180205
<button
181206
type="submit"
182207
disabled={isLoading || !input.trim()}
183-
className="p-2 rounded-md hover:bg-cyan/10 text-cyan disabled:opacity-50 transition-colors"
208+
className="p-2 rounded-full bg-purple-600 hover:bg-purple-500 text-white disabled:opacity-50 disabled:bg-zinc-700 transition-all"
184209
>
185-
<Send className="w-4 h-4" />
210+
<Send className="w-4 h-4 ml-0.5" />
186211
</button>
187212
</div>
188213
</form>

0 commit comments

Comments
 (0)