123 lines
2.8 KiB
TypeScript
123 lines
2.8 KiB
TypeScript
import { createStyles } from 'antd-style';
|
|
import { ChatMessage } from './ChatMessage';
|
|
import { WelcomeScreen } from './WelcomeScreen';
|
|
import { ChatInput } from './ChatInput';
|
|
import type { Message } from '../types';
|
|
|
|
const useStyles = createStyles(({ css }) => ({
|
|
container: css`
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100vh;
|
|
overflow: hidden;
|
|
`,
|
|
messagesWrapper: css`
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
padding: 24px;
|
|
|
|
&::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb {
|
|
background: rgba(255, 255, 255, 0.08);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
&::-webkit-scrollbar-thumb:hover {
|
|
background: rgba(255, 255, 255, 0.15);
|
|
}
|
|
`,
|
|
messages: css`
|
|
max-width: 52rem;
|
|
margin: 0 auto;
|
|
width: 100%;
|
|
`,
|
|
inputArea: css`
|
|
padding: 24px;
|
|
background: rgba(17, 17, 17, 0.7);
|
|
backdrop-filter: blur(20px);
|
|
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
|
box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.6);
|
|
`,
|
|
inputContainer: css`
|
|
max-width: 52rem;
|
|
margin: 0 auto;
|
|
`,
|
|
disclaimer: css`
|
|
text-align: center;
|
|
font-size: 12px;
|
|
color: rgba(255, 255, 255, 0.45);
|
|
margin-top: 16px;
|
|
`,
|
|
}));
|
|
|
|
interface ChatContainerProps {
|
|
messages: Message[];
|
|
isTyping: boolean;
|
|
onSendMessage: (content: string) => void;
|
|
}
|
|
|
|
export const ChatContainer: React.FC<ChatContainerProps> = ({
|
|
messages,
|
|
isTyping,
|
|
onSendMessage,
|
|
}) => {
|
|
const { styles } = useStyles();
|
|
|
|
const handleSend = (content: string) => {
|
|
if (content.trim()) {
|
|
onSendMessage(content);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<div className={styles.messagesWrapper}>
|
|
<div className={styles.messages}>
|
|
{messages.length === 0 ? (
|
|
<WelcomeScreen />
|
|
) : (
|
|
<>
|
|
{messages.map((message) => (
|
|
<ChatMessage key={message.id} message={message} />
|
|
))}
|
|
{isTyping && (
|
|
<ChatMessage
|
|
message={{
|
|
id: 'typing',
|
|
role: 'assistant',
|
|
content: '...',
|
|
timestamp: new Date(),
|
|
}}
|
|
isTyping
|
|
/>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
<div className={styles.inputArea}>
|
|
<div className={styles.inputContainer}>
|
|
<ChatInput
|
|
placeholder="Envía un mensaje..."
|
|
onSend={handleSend}
|
|
/>
|
|
<div className={styles.disclaimer}>
|
|
Nexus puede cometer errores. Considera verificar información importante.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|