diff --git a/app/page.tsx b/app/page.tsx index 3c77911..cb1b2ec 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,21 +7,30 @@ import Documentation from './components/Documentation'; // Ensure the import pat import History from './components/History'; import Models from './components/Models'; import Credits from './components/Credits'; -import { applyIOMarketTheme, applyWhiteTheme, applyBlackTheme, applyCustomTheme, applyBasicCustomTheme } from './components/settings/theme'; +import { + applyIOMarketTheme, + applyWhiteTheme, + applyBlackTheme, + applyCustomTheme, + applyBasicCustomTheme +} from './components/settings/theme'; import './styles/master.css'; const LandingPage: React.FC = () => { + // State to control visibility of the left panels const [showDivs, setShowDivs] = useState(true); + // State to track which view is currently displayed const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation' | 'Credits'>('AI'); const conversationRef = useRef(null); - const [primaryColor, setPrimaryColor] = useState("#fefefe"); - const [secondaryColor, setSecondaryColor] = useState("#fefefe"); - const [accentColor, setAccentColor] = useState("#fefefe"); - const [basicBackgroundColor, setBasicBackgroundColor] = useState("#fefefe"); - const [basicTextColor, setBasicTextColor] = useState("#fefefe"); + // State for theme colors + const [primaryColor, setPrimaryColor] = useState("#fefefe"); + const [secondaryColor, setSecondaryColor] = useState("#fefefe"); + const [accentColor, setAccentColor] = useState("#fefefe"); + const [basicBackgroundColor, setBasicBackgroundColor] = useState("#fefefe"); + const [basicTextColor, setBasicTextColor] = useState("#fefefe"); - // Synchronize state with local storage on mount + // Synchronize theme colors with local storage on component mount useEffect(() => { if (typeof localStorage !== 'undefined') { setPrimaryColor(localStorage.getItem("primaryColor") || "#fefefe"); @@ -32,18 +41,21 @@ const LandingPage: React.FC = () => { } }, [primaryColor, secondaryColor, accentColor, basicBackgroundColor, basicTextColor]); + // Toggle visibility of the left panels const toggleDivs = () => { setShowDivs(prevState => !prevState); }; + // Change the current view based on user selection const handleViewChange = (view: 'AI' | 'FAQ' | 'Documentation' | 'Credits') => { setView(view); + // Hide left panels if the selected view is not 'AI' if (view !== 'AI') { setShowDivs(false); } }; - // Apply theme based on selectedTheme and color settings + // Apply the selected theme and color settings based on local storage useEffect(() => { if (typeof localStorage !== 'undefined') { const savedTheme = localStorage.getItem('selectedTheme'); @@ -52,8 +64,8 @@ const LandingPage: React.FC = () => { case 'IOMARKET': applyIOMarketTheme(); break; - case 'WHITE': - applyWhiteTheme(); + case 'WHITE': + applyWhiteTheme(); break; case 'BLACK': applyBlackTheme(); @@ -61,8 +73,8 @@ const LandingPage: React.FC = () => { case 'CUSTOM': applyCustomTheme(); break; - case 'BASIC-CUSTOM': - applyBasicCustomTheme( + case 'BASIC-CUSTOM': + applyBasicCustomTheme( primaryColor, secondaryColor, accentColor, @@ -71,15 +83,16 @@ const LandingPage: React.FC = () => { ); break; default: - applyIOMarketTheme(); + applyIOMarketTheme(); // Fallback theme break; } } } - }, [primaryColor, secondaryColor, accentColor, basicBackgroundColor, basicTextColor]); // Watch color states and apply themes accordingly + }, [primaryColor, secondaryColor, accentColor, basicBackgroundColor, basicTextColor]); // Apply themes whenever color states change return ( <> + {/* Header component with props for toggling and view change */}
{
{showDivs && (
+ {/* Show History and Models components if left panels are visible */}
)}
+ {/* Render the selected view based on the current state */} {view === 'AI' && } {view === 'FAQ' && } {view === 'Documentation' && }