From 2a8545f11267de06447b3c56d8beca8d27596dab Mon Sep 17 00:00:00 2001
From: realtradam <github@tradam.dev>
Date: Sat, 29 Jun 2024 18:30:20 -0400
Subject: work on rendering games

---
 react-frontend/src/components/Layout.tsx | 37 +++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

(limited to 'react-frontend/src/components/Layout.tsx')

diff --git a/react-frontend/src/components/Layout.tsx b/react-frontend/src/components/Layout.tsx
index 274e579..08d1315 100644
--- a/react-frontend/src/components/Layout.tsx
+++ b/react-frontend/src/components/Layout.tsx
@@ -1,4 +1,4 @@
-import { Dispatch } from 'react';
+import { Dispatch, useState } from 'react';
 import { Outlet, Link, useNavigate } from "react-router-dom";
 import { IconButton, Button, ButtonGroup } from 'rsuite';
 import { Icon } from '@rsuite/icons';
@@ -6,6 +6,8 @@ import { FaUser } from "react-icons/fa6";
 import { FaGamepad } from "react-icons/fa";
 import { GiCowboyHolster } from "react-icons/gi";
 import { GrAdd } from "react-icons/gr";
+import { FaChevronRight } from "react-icons/fa";
+import { FaChevronLeft } from "react-icons/fa";
 import { UserType } from "../routes/index";
 
 export type userData = { name: string };
@@ -30,12 +32,41 @@ export default function Layout(prop : { userData: userData, setUserData : Dispat
 	const loggedout_element = <IconButton onClick={loginLink} appearance="primary" color="green" icon={<Icon as={FaUser}/>}>Log In</IconButton>;
 	const loggedin_element = <ButtonGroup className="flex"><Button appearance="ghost" color="red" style={{width:"100%"}}>{prop.userData.name}</Button><Button onClick={logoutLink} appearance="subtle" style={{paddingLeft:"1.4em", paddingRight:"1.4em"}}>Log Out</Button></ButtonGroup>;
 
-	console.log(prop);
+	const [sidebarOpen, setSidebarOpen] = useState(false);
+	const [sidebarClosed, setSidebarClosed] = useState(false);
+	const [sidebarInit, setSidebarInit] = useState(true);
+	const handleSidebarOpen = () => {
+		if(sidebarInit) {
+			setSidebarOpen(true);
+			setSidebarInit(false);
+		}
+		else {
+			setSidebarOpen(!sidebarOpen);
+			setSidebarClosed(!sidebarClosed);
+		}
+	};
+	const handleSidebarClickaway = () => {
+		if(!sidebarInit)
+			{
+				setSidebarOpen(false);
+				setSidebarClosed(true);
+			}
+	};
 
 	return(
 		<>
+			<div onClick={handleSidebarOpen} className={`${sidebarOpen ? 'sidebarOpen' : ''} ${sidebarClosed ? 'sidebarClosed' : ''} ${sidebarInit ? 'sidebarInit' : ''} sidebar-animation flex items-center justify-center md:hidden fixed shadow-xl ml-[19rem] m-4 h-12 w-12 text-stone-50 bg-red-800 rounded-[5px] z-[5]`}>
+				<div className={`${sidebarClosed || sidebarInit ? '' : 'hidden'} flex items-center justify-center`}>
+					<Icon as={FaChevronRight}/>
+				</div>
+				<div className={`${sidebarOpen ? '' : 'hidden'} flex items-center justify-center`}>
+					<Icon as={FaChevronLeft}/>
+				</div>
+			</div>
 			<div className="w-screen h-screen flex border-none">
-				<div className="flex flex-col h-screen overflow-y-auto overflow-x-hidden w-72 shrink-0 bg-stone-100">
+				<div className={`md:block hidden flex flex-col h-full overflow-y-auto overflow-x-hidden w-72 shrink-0 bg-stone-100`}>
+				</div>
+				<div className={`${sidebarOpen ? 'sidebarOpen' : ''} ${sidebarClosed ? 'sidebarClosed' : ''} ${sidebarInit ? 'sidebarInit' : ''} z-[5] sidebar-animation flex flex-col h-screen overflow-y-auto overflow-x-hidden w-72 shrink-0 bg-stone-100 fixed`}>
 					<div className="flex flex-col bg-stone-800">
 						<div className="m-4 mb-0 flex flex-col flex-grow">
 							{ prop.userData.name ? loggedin_element : loggedout_element }
-- 
cgit v1.2.3

