interstellar_ai/app/page.tsx

111 lines
4 KiB
TypeScript
Raw Normal View History

2024-09-19 12:18:04 +02:00
"use client";
2024-09-18 09:47:23 +02:00
import React, { useState, useEffect, useRef } from 'react';
2024-09-20 10:34:16 +02:00
import Header from './components/Header';
import AI from './components/AI';
import FAQ from './components/Faq'; // Ensure the import path is correct
import Documentation from './components/Documentation'; // Ensure the import path is correct
import History from './components/History';
import Models from './components/Models';
import Credits from './components/Credits';
2024-10-02 12:18:40 +02:00
import { applyIOMarketTheme, applyWhiteTheme, applyBlackTheme, applyCustomTheme, applyBasicCustomTheme } from './components/settings/theme'
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);
const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation' | 'Credits'>('AI'); // Added 'Credits' here
2024-09-18 09:47:23 +02:00
const conversationRef = useRef<HTMLDivElement>(null);
2024-10-02 12:18:40 +02:00
const [primaryColor, setPrimaryColor] = useState(localStorage.getItem("primaryColor") || "#fefefe");
const [secondaryColor, setSecondaryColor] = useState(localStorage.getItem("secondaryColor") || "#fefefe");
const [accentColor, setAccentColor] = useState(localStorage.getItem("accentColor") || "#fefefe");
const [basicBackgroundColor, setBasicBackgroundColor] = useState(localStorage.getItem("basicBackgroundColor") || "#fefefe");
const [basicTextColor, setBasicTextColor] = useState(localStorage.getItem("basicTextColor") || "#fefefe");
useEffect(()=>{
setPrimaryColor(localStorage.getItem("primaryColor") || "#fefefe")
setSecondaryColor(localStorage.getItem("secondaryColor") || "#fefefe")
setAccentColor(localStorage.getItem("accentColor") || "#fefefe")
setBasicBackgroundColor(localStorage.getItem("basicBackgroundColor") || "#fefefe")
setBasicTextColor(localStorage.getItem("basicTextColor") || "#fefefe")
})
2024-09-18 09:47:23 +02:00
const toggleDivs = () => {
setShowDivs(prevState => !prevState);
};
const handleViewChange = (view: 'AI' | 'FAQ' | 'Documentation' | 'Credits') => { // Added 'Credits' here as well
2024-09-19 09:54:00 +02:00
setView(view);
if (view !== 'AI') {
setShowDivs(false);
}
};
2024-09-30 16:07:01 +02:00
const [selectedTheme, setSelectedTheme] = useState<string>('');
useEffect(() => {
const savedTheme = localStorage.getItem('selectedTheme');
if (savedTheme) {
setSelectedTheme(savedTheme);
// Apply the saved theme on initial load
switch (savedTheme) {
case 'IOMARKET':
applyIOMarketTheme();
break;
case 'WHITE':
applyWhiteTheme();
break;
case 'BLACK':
applyBlackTheme();
break;
case 'CUSTOM':
applyCustomTheme();
2024-09-30 16:07:01 +02:00
break;
2024-10-02 12:18:40 +02:00
case 'BASIC-CUSTOM':
applyBasicCustomTheme(
primaryColor,
secondaryColor,
accentColor,
basicBackgroundColor,
basicTextColor
);
break;
2024-09-30 16:07:01 +02:00
default:
applyIOMarketTheme();
break;
}
}
}, []); // Runs only once when the component mounts
2024-09-18 09:47:23 +02:00
return (
<>
<Header
toggleDivs={toggleDivs}
showDivs={showDivs}
onViewChange={handleViewChange}
showHistoryModelsToggle={true}
showToggle={view === 'AI'} // Pass the condition here
/>
2024-09-27 16:48:17 +02:00
<div className="container">
<div className={`left-panel ${showDivs ? 'visible' : 'hidden'}`}>
{showDivs && (
<div className="history-models">
<History />
<Models />
</div>
)}
</div>
<div className={`conversation-container ${showDivs ? 'collapsed' : 'expanded'}`} ref={conversationRef}>
{view === 'AI' && <AI />}
{view === 'FAQ' && <FAQ />}
{view === 'Documentation' && <Documentation />}
{view === 'Credits' && <Credits />} {/* Now Credits will render properly */}
</div>
2024-09-19 12:18:04 +02:00
</div>
</>
2024-09-18 09:47:23 +02:00
);
};
2024-09-18 10:03:36 +02:00
export default LandingPage;