From d8784ecd03be1cc90887242ae340a0bbf069da18 Mon Sep 17 00:00:00 2001 From: realtradam Date: Thu, 20 Jun 2024 15:16:03 -0400 Subject: add mobile sliding sidepanel --- src/components/Home.tsx | 4 ++-- src/components/Layout.tsx | 29 +++++++++++++++++++++++++---- src/index.css | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 91e241a..1dbc574 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -5,10 +5,10 @@ export default function Home () { <>
-
Welcome
+
Welcome
-
+
diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 6daf865..9abfdf0 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,4 +1,5 @@ import { Outlet, Link } from "react-router-dom"; +import { useState } from "react"; import Button from "./Button"; export type userData = { userData: { name: string } }; @@ -8,11 +9,30 @@ export default function Layout ({userData}: userData) const loginLink = () => { window.open(`https://github.com/login/oauth/authorize?client_id=${import.meta.env.VITE_GITHUB_CLIENTID}`); }; - console.log(userData); + + 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); + } + }; + return ( <>
- diff --git a/src/index.css b/src/index.css index 72845f6..153686f 100644 --- a/src/index.css +++ b/src/index.css @@ -9,8 +9,45 @@ @apply py-2 px-4 bg-blue-200; } } - */ + +@keyframes sidebar-enter { + from { + left: -16rem; + } + to { + left: 0; + } +} + +@keyframes sidebar-exit { + from { + left: 0; + } + to { + left: -16rem; + } +} + +.sidebarInit { + left: -16rem; +} + +.sidebarOpen { + animation-name: sidebar-enter; + left: 0; +} + +.sidebarClosed { + animation-name: sidebar-exit; + left: -16rem; +} + +#sidebar { + animation-duration: 0.5s; + animation-iteration-count: 1; +} + .gameCard { aspect-ratio: 5/7; width: 300px; -- cgit v1.2.3