diff --git a/components/ui/account-switcher.tsx b/components/ui/account-switcher.tsx index 51bc7c30f..13ee55c3f 100644 --- a/components/ui/account-switcher.tsx +++ b/components/ui/account-switcher.tsx @@ -1,7 +1,8 @@ "use client"; import { Check, ChevronsUpDown, Plus } from "lucide-react"; -import * as React from "react"; +import { Account } from "@/types"; +import { cn } from "@/lib/utils"; import { DropdownMenu, @@ -24,19 +25,17 @@ import { SidebarMenuButton, useSidebar, } from "@/components/ui/sidebar"; +import React from "react"; interface AccountSwitcherProps { - accounts: { - name: string; - logo: React.ComponentType<{ className?: string }>; - email: string; - }[]; + accounts: Account[]; } export function AccountSwitcher({ accounts }: AccountSwitcherProps) { const [selectedAccount, setSelectedAccount] = React.useState(accounts[0]); - const { isMobile } = useSidebar(); + const { isMobile, state } = useSidebar(); + const collapsed = state === "collapsed"; return ( @@ -47,7 +46,12 @@ export function AccountSwitcher({ accounts }: AccountSwitcherProps) { size="lg" className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground" > -
+
diff --git a/components/ui/app-sidebar.tsx b/components/ui/app-sidebar.tsx index 70445ff75..6fab948a0 100644 --- a/components/ui/app-sidebar.tsx +++ b/components/ui/app-sidebar.tsx @@ -16,8 +16,8 @@ import { Pencil, } from "lucide-react"; import { Gmail, Outlook, Vercel } from "@/components/icons/icons"; -import { Button } from "@/components/ui/button"; -import * as React from "react"; +import { SidebarData } from "@/types"; +import React from "react"; import { Sidebar, @@ -25,6 +25,9 @@ import { SidebarFooter, SidebarHeader, SidebarRail, + SidebarMenu, + SidebarMenuItem, + SidebarMenuButton, } from "@/components/ui/sidebar"; import { useSidebar } from "@/components/ui/sidebar"; import { AccountSwitcher } from "./account-switcher"; @@ -33,9 +36,7 @@ import { SidebarToggle } from "./sidebar-toggle"; import { NavMain } from "./nav-main"; import { NavUser } from "./nav-user"; -// This is sample data that matches the screenshot - -const data = { +const data: SidebarData = { user: { name: "nizzy", email: "nizabizaher@gmail.com", @@ -153,7 +154,29 @@ const data = { export function AppSidebar({ ...props }: React.ComponentProps) { const [composeOpen, setComposeOpen] = React.useState(false); - const { isMobile } = useSidebar(); + const sidebarContext = useSidebar(); + const { isMobile } = sidebarContext; + + const handleComposeClick = React.useCallback(() => { + setComposeOpen(true); + }, []); + + // Memoized compose button component + const ComposeButton = React.memo(function ComposeButton() { + return ( + + + + + Compose + + + + ); + }); return ( <> @@ -161,19 +184,20 @@ export function AppSidebar({ ...props }: React.ComponentProps) { + - - setComposeOpen(false)} /> + setComposeOpen(false)} + aria-label="Compose email dialog" + /> ); diff --git a/types/index.ts b/types/index.ts new file mode 100644 index 000000000..818ac9204 --- /dev/null +++ b/types/index.ts @@ -0,0 +1,30 @@ +export interface User { + name: string; + email: string; + avatar: string; +} + +export interface Account { + name: string; + logo: React.ComponentType<{ className?: string }>; + email: string; +} + +export interface NavItem { + title: string; + url: string; + icon?: React.ComponentType<{ className?: string }>; + isActive?: boolean; + badge?: number; +} + +export interface NavSection { + title: string; + items: NavItem[]; +} + +export interface SidebarData { + user: User; + accounts: Account[]; + navMain: NavSection[]; +}