diff --git a/frontend/package.json b/frontend/package.json index 6c9fe50..faa5e74 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "frontend", "private": true, - "version": "0.1.0", + "version": "0.5.0", "type": "module", "scripts": { "dev": "vite --config vite.config.dev.ts", diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 67cf578..dd9592a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -10,6 +10,8 @@ import ResetPasswordPage from "./pages/ResetPasswordPage"; import CategoryPage from "./pages/CategoryPage"; import CategoriesPage from "./pages/AllCategoriesPage"; import ResultsPage from "./pages/ResultsPage"; +import { SidebarProvider } from "./context/SidebarContext"; +import { QuickSettingsProvider } from "./context/QuickSettingsContext"; function App() { const [isLoggedIn, setIsLoggedIn] = useState(false); @@ -35,31 +37,38 @@ function App() { value={{ isLoggedIn, username, user_id, setIsLoggedIn, setUsername }} > - - - : - } - /> - - } /> - } /> - } - > - } - > - }> - }> - } /> - } /> - - + + + + + + ) : ( + + ) + } + /> + } /> + } /> + } + > + } + > + }> + }> + } /> + } /> + + + + ); diff --git a/frontend/src/components/Layout/DynamicPageContent.tsx b/frontend/src/components/Layout/DynamicPageContent.tsx new file mode 100644 index 0000000..65c1d2f --- /dev/null +++ b/frontend/src/components/Layout/DynamicPageContent.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import Navbar from "../Navigation/Navbar"; +import { useSidebar } from "../../context/SidebarContext"; + +interface DynamicPageContentProps { + children: React.ReactNode; + navbarVariant?: "home" | "default"; + className?: string; + style?: React.CSSProperties; +} + +const DynamicPageContent: React.FC = ({ + children, + navbarVariant = "default", + className = "", + style +}) => { + const { showSideBar } = useSidebar(); + + return ( +
+ +
+ {children} +
+
+ ); +}; + +export default DynamicPageContent; \ No newline at end of file diff --git a/frontend/src/components/Layout/ListRow.tsx b/frontend/src/components/Layout/ListRow.tsx index 9346fe6..12b8504 100644 --- a/frontend/src/components/Layout/ListRow.tsx +++ b/frontend/src/components/Layout/ListRow.tsx @@ -44,7 +44,7 @@ const ListRow: React.FC = ({ return (

{title}

diff --git a/frontend/src/components/Navigation/Navbar.tsx b/frontend/src/components/Navigation/Navbar.tsx index 01ce3c2..4555dfc 100644 --- a/frontend/src/components/Navigation/Navbar.tsx +++ b/frontend/src/components/Navigation/Navbar.tsx @@ -1,6 +1,6 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import Logo from "../Layout/Logo"; -import Button from "../Input/Button"; +import Button, { ToggleButton } from "../Input/Button"; import Sidebar from "./Sidebar"; import { Sidebar as SidebarIcon } from "lucide-react"; import { @@ -13,6 +13,8 @@ import AuthModal from "../Auth/AuthModal"; import { useAuthModal } from "../../hooks/useAuthModal"; import { useAuth } from "../../context/AuthContext"; import QuickSettings from "../Settings/QuickSettings"; +import { useSidebar } from "../../context/SidebarContext"; +import { useQuickSettings } from "../../context/QuickSettingsContext"; interface NavbarProps { variant?: "home" | "default"; @@ -21,8 +23,8 @@ interface NavbarProps { const Navbar: React.FC = ({ variant = "default" }) => { const { isLoggedIn } = useAuth(); const { showAuthModal, setShowAuthModal } = useAuthModal(); - const [showSideBar, setShowSideBar] = useState(false); - const [showQuickSettings, setShowQuickSettings] = useState(false); + const { showSideBar, setShowSideBar } = useSidebar(); + const { showQuickSettings, setShowQuickSettings } = useQuickSettings(); const handleLogout = () => { console.log("Logging out..."); @@ -42,10 +44,32 @@ const Navbar: React.FC = ({ variant = "default" }) => { setShowSideBar(!showSideBar); }; + // Keyboard shortcut to toggle sidebar + useEffect(() => { + const handleKeyPress = (e: KeyboardEvent) => { + if ( + e.key === "s" && + document.activeElement == document.body && + isLoggedIn + ) { + handleSideBar(); + } + if (e.key === "q" && document.activeElement == document.body) { + handleQuickSettings(); + } + }; + + document.addEventListener("keydown", handleKeyPress); + + return () => { + document.removeEventListener("keydown", handleKeyPress); + }; + }, [showSideBar, showQuickSettings, setShowSideBar, isLoggedIn]); + return (