Files
Open-Assistant/website/src/components/Messages.tsx
T
AbdBarho 0987a64a85 Implement *_reply for the web
Also, start extracting shared components
2022-12-27 11:36:20 +01:00

19 lines
553 B
TypeScript

export interface Message {
text: string;
is_assistant: boolean;
}
const getColor = (isAssistant: boolean) => (isAssistant ? "bg-slate-800" : "bg-sky-900");
export const Messages = ({ messages }: { messages: Message[] }) => {
const items = messages.map(({ text, is_assistant }: Message, i: number) => {
return (
<div key={i + text} className={`${getColor(is_assistant)} p-4 my-1 rounded-xl text-white whitespace-pre-wrap`}>
{text}
</div>
);
});
// Maybe also show a legend of the colors?
return <>{items}</>;
};