From b96351499819d2a9953fad379f154ddf13fdf936 Mon Sep 17 00:00:00 2001 From: Kavin Valli Date: Tue, 15 Oct 2024 16:52:11 -0400 Subject: [PATCH] Sidebar UI fixes (#2752) * mobile nav * improve sidebar ui * Remove commented code Co-authored-by: Justin Torre --------- Co-authored-by: Justin Torre --- web/components/layout/auth/DesktopSidebar.tsx | 57 ++++- web/components/layout/auth/NavItem.tsx | 5 +- web/components/layout/auth/Sidebar.tsx | 4 +- web/components/layout/orgDropdown.tsx | 206 ++++++------------ web/components/layout/orgMoreDropdown.tsx | 195 +++++++++++++++++ 5 files changed, 324 insertions(+), 143 deletions(-) create mode 100644 web/components/layout/orgMoreDropdown.tsx diff --git a/web/components/layout/auth/DesktopSidebar.tsx b/web/components/layout/auth/DesktopSidebar.tsx index 21ff6c1139..0bd62b1faf 100644 --- a/web/components/layout/auth/DesktopSidebar.tsx +++ b/web/components/layout/auth/DesktopSidebar.tsx @@ -13,6 +13,7 @@ import { ChevronRightIcon, Cog6ToothIcon, QuestionMarkCircleIcon, + Bars3Icon, } from "@heroicons/react/24/outline"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -133,8 +134,46 @@ const DesktopSidebar = ({ NAVIGATION }: SidebarProps) => { }; }, [isCollapsed, expandedItems, setIsCollapsed]); + const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); + + const handleCollapseToggle = () => { + if (window.innerWidth < 768) { + // Mobile breakpoint + setIsMobileMenuOpen(false); + } else { + setIsCollapsed(!isCollapsed); + } + }; + return ( <> + {/* Mobile hamburger menu */} +
+ +
+ + {/* Mobile drawer overlay */} + {isMobileMenuOpen && ( +
{ + setIsCollapsed(false); + setIsMobileMenuOpen(false); + }} + /> + )} + + {/* Sidebar container */}
{ "transition-all duration-300" )} /> + + {/* Sidebar content */}
-
+
{!isCollapsed && } @@ -161,7 +206,7 @@ const DesktopSidebar = ({ NAVIGATION }: SidebarProps) => { - - Organizations -
- {ownedOrgs && ownedOrgs.length > 0 && ( -
- - Your Organizations - {ownedOrgs.length > 7 && ` (${ownedOrgs.length})`} - - - {ownedOrgs.map((org, idx) => { - const icon = ORGANIZATION_ICONS.find( - (icon) => icon.name === org.icon - ); - return ( - orgContext?.setCurrentOrg(org.id)} - > -
-
- {icon && ( - - )} - - {org.name} - -
- {org.id === orgContext?.currentOrg?.id && ( - - )} -
-
- ); - })} -
+ + +
+ {currentIcon && ( +
- - createNewOrgHandler()}> - Create New Org - - - User Settings - -
- Theme -
-
- -
- - {user?.email} - +
+
- + - Sign out +
+ + +
+ + + Invite members + + +
+ Dark mode + +
+
+
+ + + + + Sign out + diff --git a/web/components/layout/orgMoreDropdown.tsx b/web/components/layout/orgMoreDropdown.tsx new file mode 100644 index 0000000000..ca384dbeb4 --- /dev/null +++ b/web/components/layout/orgMoreDropdown.tsx @@ -0,0 +1,195 @@ +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; +import { CheckIcon, ChevronsUpDownIcon, PlusIcon } from "lucide-react"; +import { ORGANIZATION_ICONS } from "../templates/organization/orgConstants"; +import { ScrollArea } from "@/components/ui/scroll-area"; + +type Organization = { + id: string; + name: string; + icon: string; + color: string; +}; + +export default function OrgMoreDropdown({ + ownedOrgs, + memberOrgs, + customerOrgs, + createNewOrgHandler, + currentOrgId, + setCurrentOrg, +}: { + ownedOrgs: Organization[]; + memberOrgs: Organization[]; + customerOrgs: Organization[]; + createNewOrgHandler: () => void; + currentOrgId?: string; + setCurrentOrg?: (orgId: string) => void; +}) { + const content = ( + <> + {ownedOrgs && ownedOrgs.length > 0 && ( + + + Your Organizations + {ownedOrgs.length > 7 && ` (${ownedOrgs.length})`} + + + {ownedOrgs.map((org, idx) => { + const icon = ORGANIZATION_ICONS.find( + (icon) => icon.name === org.icon + ); + return ( + setCurrentOrg(org.id) : undefined + } + > +
+
+ {icon && ( + + )} + + {org.name} + +
+ {org.id === currentOrgId && ( + + )} +
+
+ ); + })} +
+
+ )} + {memberOrgs && memberOrgs.length > 0 && ( + <> + + + + Member Organizations + {memberOrgs.length > 7 && ` (${memberOrgs.length})`} + + + {memberOrgs.map((org, idx) => { + const icon = ORGANIZATION_ICONS.find( + (icon) => icon.name === org.icon + ); + return ( + setCurrentOrg(org.id) : undefined + } + > +
+
+ {icon && ( + + )} + + {org.name} + +
+ {org.id === currentOrgId && ( + + )} +
+
+ ); + })} +
+
+ + )} + {customerOrgs && customerOrgs.length > 0 && ( + <> + + + + Customers + {customerOrgs.length > 7 && ` (${customerOrgs.length})`} + + + {customerOrgs.map((org, idx) => { + const icon = ORGANIZATION_ICONS.find( + (icon) => icon.name === org.icon + ); + return ( + setCurrentOrg(org.id) : undefined + } + > +
+
+ {icon && ( + + )} + + {org.name} + +
+ {org.id === currentOrgId && ( + + )} +
+
+ ); + })} +
+
+ + )} + + createNewOrgHandler()} + > + + Create New Org + + + ); + + return ( + <> + {/* Mobile view */} +
{content}
+ + {/* Desktop view */} +
+ + + + + + {content} + + +
+ + ); +}