diff --git a/web/src/components/Sidebar/Sidebar.tsx b/web/src/components/Sidebar/Sidebar.tsx index 262bfca..ec67990 100644 --- a/web/src/components/Sidebar/Sidebar.tsx +++ b/web/src/components/Sidebar/Sidebar.tsx @@ -1,32 +1,28 @@ -import { useState } from 'react' - import { HomeIcon, UsersIcon, FolderIcon, DocumentDuplicateIcon, - ChevronLeftIcon, - ChevronRightIcon, - ArrowLeftOnRectangleIcon, // Logout icon - ArrowUturnLeftIcon, // Back icon + ArrowLeftOnRectangleIcon, + ArrowUturnLeftIcon, UserIcon, } from '@heroicons/react/24/outline' - import { Link } from '@redwoodjs/router' - import { useAuth } from 'src/auth' -function classNames(...classes) { +function classNames(...classes: string[]) { return classes.filter(Boolean).join(' ') } -const actions = [ - { name: 'Back', action: 'back', icon: ArrowUturnLeftIcon }, - { name: 'Logout', action: 'logout', icon: ArrowLeftOnRectangleIcon }, -] - -const Sidebar = () => { - const [isCollapsed, setIsCollapsed] = useState(false) +const Sidebar = ({ + isCollapsed = false, + setIsCollapsed, + setSidebarOpen, // Optional +}: { + isCollapsed: boolean + setIsCollapsed: (collapsed: boolean) => void + setSidebarOpen?: (open: boolean) => void // Mark as optional +}) => { const { logOut } = useAuth() const { currentUser } = useAuth() @@ -41,98 +37,90 @@ const Sidebar = () => { icon: UserIcon, }, ] - return ( -
- {/* Header with Title and Collapse Button */} -
- {!isCollapsed && ( - SWPPP-TOP + + const actions = [ + { + name: 'Back', + action: () => window.history.back(), + icon: ArrowUturnLeftIcon, + }, + { name: 'Logout', action: logOut, icon: ArrowLeftOnRectangleIcon }, + ] + + const NavigationItem = ({ name, href, Icon }) => ( +
  • + setIsCollapsed(!isCollapsed)} - className="text-gray-300 hover:text-gray-400 focus:outline-none" - > - {isCollapsed ? ( -
  • + ) + + const ActionItem = ({ name, action, Icon }) => ( +
  • + +
  • + ) + + return ( +
    +
    + SWPPP-TOP
    {/* Navigation */} - {/* Actions at the Bottom */} + {/* Actions */}
      {actions.map((action) => ( -
    • - -
    • + ))}
    diff --git a/web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx b/web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx index 2d2b361..927bc2b 100644 --- a/web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx +++ b/web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx @@ -1,13 +1,6 @@ import { useState, Fragment, ReactNode } from 'react' - -import { - Dialog, - DialogPanel, - Transition, - TransitionChild, -} from '@headlessui/react' +import { Dialog, Transition } from '@headlessui/react' import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline' - import Sidebar from 'src/components/Sidebar' interface AuthenticatedLayoutProps { @@ -16,97 +9,78 @@ interface AuthenticatedLayoutProps { const AuthenticatedLayout = ({ children }: AuthenticatedLayoutProps) => { const [sidebarOpen, setSidebarOpen] = useState(false) + const [isCollapsed, setIsCollapsed] = useState(false); return ( -
    +
    {/* Mobile Sidebar */} setSidebarOpen(false)} + onClose={setSidebarOpen} > - -
    - +
    + -
    - - - -
    - -
    -
    - -
    -
    -
    + + + {/* Close Button */} + + {' '} + +
    {/* Desktop Sidebar */} -
    - +
    + {' '}
    {/* Main Content */} -
    - {/* Mobile Sidebar Toggle */} -
    +
    + {/* Mobile Menu Toggle */} +
    -
    + {/* Main Section */} -
    -
    - {/* Example of a card/container following the style guide */} -
    - {children} -
    -
    -
    +
    {children}
    {/* Footer */} -