-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💅 Basic style chat interface with tailwind
- Loading branch information
Showing
9 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
import React from 'react'; | ||
|
||
const ChatBubble = ({ message, isUser }) => { | ||
return ( | ||
<div className={`chat-bubble ${isUser ? 'user' : 'chatgpt'}`}> | ||
<p>{message}</p> | ||
</div> | ||
); | ||
}; | ||
const bubbleClasses = isUser | ||
? 'bg-blue-500 text-white rounded-br-none self-end' | ||
: 'bg-gray-200 text-black rounded-bl-none self-start'; | ||
|
||
const tailClasses = isUser | ||
? 'right-0 -mr-2 bg-blue-500' | ||
: 'left-0 -ml-2 bg-gray-200'; | ||
|
||
return ( | ||
<div className={`p-2 rounded-lg ${bubbleClasses} relative w-max mb-4`}> | ||
<p>{message}</p> | ||
<div | ||
className={`w-4 h-4 absolute top-0 mt-2 rounded-bl-lg ${tailClasses}`} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
|
||
export default ChatBubble; | ||
export default ChatBubble; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
import React, { useState } from 'react'; | ||
|
||
const ChatInput = ({ onSubmit }) => { | ||
const [message, setMessage] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
if (message.trim()) { | ||
onSubmit(message); | ||
setMessage(''); | ||
} | ||
}; | ||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
if (!message.trim()) return; | ||
|
||
return ( | ||
<form className="chat-input" onSubmit={handleSubmit}> | ||
<input | ||
type="text" | ||
placeholder="Type your message..." | ||
value={message} | ||
onChange={(e) => setMessage(e.target.value)} | ||
/> | ||
<button type="submit">Send</button> | ||
</form> | ||
); | ||
onSubmit(message); | ||
setMessage(''); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleSubmit} className="flex items-center gap-4"> | ||
<input | ||
type="text" | ||
value={message} | ||
onChange={(e) => setMessage(e.target.value)} | ||
placeholder="Type your message here..." | ||
className="flex-grow border-2 border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:border-blue-300" | ||
/> | ||
<button type="submit" className="bg-blue-500 text-white px-4 py-2 rounded-lg"> | ||
Send | ||
</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default ChatInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@import 'tailwindcss/base'; | ||
@import 'tailwindcss/components'; | ||
@import 'tailwindcss/utilities'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: [], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
} |