interstellar_ai/app/page.tsx

90 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-09-18 11:17:34 +02:00
"use client"
2024-09-18 10:03:36 +02:00
// LandingPage.tsx
2024-09-18 09:47:23 +02:00
import React, { useState, useEffect, useRef } from 'react';
2024-09-18 10:03:36 +02:00
import Header from './Header';
import History from './History';
import Models from './Models';
import Conversation from './Conversation';
import InputForm from './InputForm';
2024-09-18 11:17:34 +02:00
import './styles/master.css';
2024-09-18 09:47:23 +02:00
2024-09-18 10:03:36 +02:00
const LandingPage: React.FC = () => {
const [showDivs, setShowDivs] = useState(true);
2024-09-18 09:47:23 +02:00
const conversationRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const scrollToBottom = () => {
const conversation = conversationRef.current;
if (conversation) {
conversation.scrollTop = conversation.scrollHeight;
}
};
2024-09-18 10:03:36 +02:00
scrollToBottom();
2024-09-18 09:47:23 +02:00
const observer = new MutationObserver(scrollToBottom);
if (conversationRef.current) {
observer.observe(conversationRef.current, {
childList: true,
subtree: true,
});
}
return () => {
if (conversationRef.current) {
observer.disconnect();
}
};
}, []);
const toggleDivs = () => {
setShowDivs(prevState => !prevState);
};
2024-09-18 10:03:36 +02:00
const messages = [
'User: Hello!',
'AI: Hi there!',
'User: How are you?',
'AI: Im good, thank you!'
];
2024-09-18 11:17:34 +02:00
const handleResendClick = () => {
console.log('Resend button clicked');
// Handle resend action
};
const handleEditClick = () => {
console.log('Edit button clicked');
// Handle edit action
};
const handleCopyClick = () => {
console.log('Copy button clicked');
// Handle copy action
};
2024-09-18 09:47:23 +02:00
return (
<div className="App">
2024-09-18 10:03:36 +02:00
<Header toggleDivs={toggleDivs} showDivs={showDivs} />
2024-09-18 09:47:23 +02:00
<div className="container">
2024-09-18 11:17:34 +02:00
<div className={`left-panel ${showDivs ? '' : 'hidden'}`}>
<History />
<Models />
</div>
<div className={`conversation-container ${showDivs ? 'expanded' : 'collapsed'}`}>
<Conversation
ref={conversationRef}
messages={messages}
onResendClick={handleResendClick}
onEditClick={handleEditClick}
onCopyClick={handleCopyClick}
/>
<InputForm />
</div>
2024-09-18 09:47:23 +02:00
</div>
</div>
);
};
2024-09-18 10:03:36 +02:00
export default LandingPage;