Last active
October 10, 2023 08:53
-
-
Save aiherrera/a7faa76e662d2240cb316500ceaaa6be to your computer and use it in GitHub Desktop.
Chat example - Message component
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
import { FC } from 'react' | |
export interface MessageProps { | |
message: string | |
sender: 'user' | 'ai' | |
} | |
const Message: FC<MessageProps> = ({ message, sender }) => { | |
const isUser = sender === 'user' | |
return ( | |
<div | |
className={`w-full p-4 px-16 py-6 dark:border-gray-900/50 ${ | |
isUser ? 'bg-gray-800' : 'bg-gray-700' | |
}`} | |
> | |
<div className={`flex w-full`}> | |
<div | |
className={`mr-5 flex h-10 w-10 items-center justify-center rounded-sm bg-slate-500 ${ | |
isUser ? 'bg-orange-600' : 'bg-violet-500' | |
} text-slate-100`} | |
> | |
{isUser ? 'U' : 'Ai'} | |
</div> | |
<div className="markdown prose prose-slate dark:prose-invert dark w-full break-words text-slate-200"> | |
{message} | |
</div> | |
</div> | |
</div> | |
) | |
} | |
export default Message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment