From 99c3452a5f3a10a5301acf7e0298670ae845aa9f Mon Sep 17 00:00:00 2001 From: Lars Hampe Date: Sun, 20 Oct 2024 09:43:29 +0200 Subject: [PATCH] feat(app): use new sidebar navigation --- apps/app/src/components/Layout.tsx | 81 +++++++--------- apps/app/src/components/Sidebar.tsx | 91 ++++++++++++++++++ apps/app/src/components/SidebarUser.tsx | 96 +++++++++++++++++++ apps/app/src/main.tsx | 40 ++++---- .../changelog.$id.version.$versionId.tsx | 5 +- apps/app/tsconfig.tsbuildinfo | 2 +- 6 files changed, 245 insertions(+), 70 deletions(-) create mode 100644 apps/app/src/components/Sidebar.tsx create mode 100644 apps/app/src/components/SidebarUser.tsx diff --git a/apps/app/src/components/Layout.tsx b/apps/app/src/components/Layout.tsx index 7c7a84e..2b49259 100644 --- a/apps/app/src/components/Layout.tsx +++ b/apps/app/src/components/Layout.tsx @@ -1,58 +1,43 @@ -import { - Button, - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuTrigger, -} from '@boring.tools/ui' -import { SignOutButton, useUser } from '@clerk/clerk-react' -import { Link } from '@tanstack/react-router' +import { SidebarInset, SidebarTrigger } from '@boring.tools/ui' import type { ReactNode } from 'react' -import { Navigation } from './Navigation' -import { NavigationMobile } from './NavigationMobile' +import { Sidebar } from './Sidebar' export const description = 'A products dashboard with a sidebar navigation and a main content area. The dashboard has a header with a search input and a user menu. The sidebar has a logo, navigation links, and a card with a call to action. The main content area shows an empty state with a call to action.' export const Layout = ({ children }: { children: ReactNode | ReactNode[] }) => { - const { user } = useUser() return ( -
- -
-
- -
- - - - - - Settings - - Profile - - - - - - - - - + <> + {/* */} + + +
+
+ + {/* */} + {/* + + + + Building Your Application + + + + + Data Fetching + + + */} +
-
- {children} -
-
-
+
+
+
+ {children} +
+
+
+ + ) } diff --git a/apps/app/src/components/Sidebar.tsx b/apps/app/src/components/Sidebar.tsx new file mode 100644 index 0000000..1066ce5 --- /dev/null +++ b/apps/app/src/components/Sidebar.tsx @@ -0,0 +1,91 @@ +import { FileStackIcon } from 'lucide-react' + +import { + Collapsible, + Sidebar as SidebarComp, + SidebarContent, + SidebarFooter, + SidebarGroup, + SidebarHeader, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, +} from '@boring.tools/ui' +import { Link } from '@tanstack/react-router' +import { SidebarUser } from './SidebarUser' + +const items = [ + { + title: 'Changelog', + url: '/changelog', + icon: FileStackIcon, + isActive: true, + }, +] + +export function Sidebar() { + return ( + + + + + + +
+ BT +
+
+ boring.tools +
+ +
+
+
+
+ + + + {items.map((item) => ( + + + + + + {item.title} + + + {/* {item.items?.length ? ( + <> + + + + Toggle + + + + + {item.items?.map((subItem) => ( + + + + {subItem.title} + + + + ))} + + + + ) : null} */} + + + ))} + + + + + + +
+ ) +} diff --git a/apps/app/src/components/SidebarUser.tsx b/apps/app/src/components/SidebarUser.tsx new file mode 100644 index 0000000..0e781dd --- /dev/null +++ b/apps/app/src/components/SidebarUser.tsx @@ -0,0 +1,96 @@ +import { ChevronsUpDown } from 'lucide-react' + +import { + Avatar, + AvatarFallback, + AvatarImage, + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + useSidebar, +} from '@boring.tools/ui' +import { SignOutButton, useUser } from '@clerk/clerk-react' +import { Link } from '@tanstack/react-router' + +export function SidebarUser() { + const { isMobile } = useSidebar() + const { user } = useUser() + + return ( + + + + + + + + CN + +
+ {user?.fullName} + + {user?.primaryEmailAddress?.emailAddress} + +
+ +
+
+ + +
+ + + + {user?.firstName?.substring(0, 1)} + {user?.lastName?.substring(0, 1)} + + +
+ + {user?.fullName} + + + {user?.primaryEmailAddress?.emailAddress} + +
+
+
+ + + + Profile + + + + + + + + +
+
+
+
+ ) +} diff --git a/apps/app/src/main.tsx b/apps/app/src/main.tsx index d19edb7..b5ad488 100644 --- a/apps/app/src/main.tsx +++ b/apps/app/src/main.tsx @@ -1,4 +1,8 @@ -import { ThemeProvider, TooltipProvider } from '@boring.tools/ui' +import { + SidebarProvider, + ThemeProvider, + TooltipProvider, +} from '@boring.tools/ui' import { ClerkProvider } from '@clerk/clerk-react' import { RouterProvider, createRouter } from '@tanstack/react-router' import { StrictMode } from 'react' @@ -34,22 +38,24 @@ if (!rootElement.innerHTML) { const root = ReactDOM.createRoot(rootElement) root.render( - - - - - {import.meta.env.PROD && ( -