interstellar_ai/app/page.tsx

60 lines
1.5 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';
2024-09-18 14:52:04 +02:00
import InputBackend from './InputBackend';
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);
};
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'}`}>
2024-09-18 14:52:04 +02:00
<InputBackend />
2024-09-18 11:17:34 +02:00
</div>
2024-09-18 09:47:23 +02:00
</div>
</div>
);
};
2024-09-18 10:03:36 +02:00
export default LandingPage;