diff --git a/app/globals.css b/app/globals.css index 449c304..8e74f37 100644 --- a/app/globals.css +++ b/app/globals.css @@ -315,3 +315,5 @@ display: none; } */ + + diff --git a/components/BotWidget.tsx b/components/BotWidget.tsx index b98fdae..9def334 100644 --- a/components/BotWidget.tsx +++ b/components/BotWidget.tsx @@ -11,7 +11,7 @@ export default function BotWidget() { const [messages, setMessages] = useState([ { role: "bot", - content: "👋 Hi! I’m your DSAMate Bot. Tell me what you’ve done so far!", + content: "👋 Hi! I'm your DSAMate Bot. Tell me what you've done so far!", }, ]); const [loading, setLoading] = useState(false); @@ -72,88 +72,101 @@ export default function BotWidget() { }; return ( -
+
+ {/* Bot Button - Responsive sizing */} + {/* Chat Window - Responsive positioning and sizing */} {open && ( -
-
+
+ + {/* Messages Container - Responsive padding and text sizing */} +
{messages.map((msg, i) => { - let contentElement; + let contentElement; - // Try to parse JSON - try { - const data = JSON.parse(msg.content); - if (Array.isArray(data) && data[0]?.title && data[0]?.description) { - // Render as question cards - contentElement = ( -
- {data.map((q, idx) => ( -
-

{q.title}

-

{q.description}

-

- Topic: {q.topic} | Level: {q.level} -

-
- ))} -
- ); - } else { - contentElement = {msg.content}; - } - } catch { - // Parse markdown-style formatting - const formattedContent = msg.content - .replace(/\*\*(.*?)\*\*/g, '$1') // **bold** - .replace(/\*(.*?)\*/g, '$1') // *italic* - .replace(/^(\d+\.)\s/gm, '$1 '); // numbered lists - - contentElement = ( - - ); - } + // Try to parse JSON + try { + const data = JSON.parse(msg.content); + if (Array.isArray(data) && data[0]?.title && data[0]?.description) { + // Render as question cards + contentElement = ( +
+ {data.map((q, idx) => ( +
+

{q.title}

+

{q.description}

+

+ Topic: {q.topic} | Level: {q.level} +

+
+ ))} +
+ ); + } else { + contentElement = {msg.content}; + } + } catch { + // Parse markdown-style formatting + const formattedContent = msg.content + .replace(/\*\*(.*?)\*\*/g, '$1') // **bold** + .replace(/\*(.*?)\*/g, '$1') // *italic* + .replace(/^(\d+\.)\s/gm, '$1 '); // numbered lists + + contentElement = ( + + ); + } - return ( -
- {contentElement} -
- ); -})} + return ( +
+ {contentElement} +
+ ); + })}
-
-
+ {/* Input Area - Responsive padding and sizing */} +
+
setInput(e.target.value)} placeholder="What have you covered so far?" - className="flex-grow border p-2 rounded text-black" + className="flex-grow border p-2 sm:p-3 rounded-lg text-black focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all + text-sm sm:text-base" disabled={loading} onKeyDown={(e) => { if (e.key === "Enter" && !loading) { @@ -164,21 +177,25 @@ export default function BotWidget() {
{loading && ( -

🤖 Thinking...

+

+ 🤖 Thinking... +

)}
)}
); -} +} \ No newline at end of file