diff --git a/resources/js/Components/MobileMenu.tsx b/resources/js/Components/MobileMenu.tsx index 4177313..419e080 100644 --- a/resources/js/Components/MobileMenu.tsx +++ b/resources/js/Components/MobileMenu.tsx @@ -1,9 +1,10 @@ import { Sheet, SheetContent, SheetTrigger } from "@/Components/ui/sheet"; import { Button } from "@/Components/ui/button"; -import { Home, Menu } from "lucide-react"; +import { AlignJustifyIcon, Menu } from "lucide-react"; import { Link } from "@inertiajs/react"; import { MenuItemProp } from "@/types"; import ApplicationLogo from "@/Components/ApplicationLogo"; +import { DropdownMenuSeparator } from "./ui/dropdown-menu"; const MobileMenu = ({ links }: { links: MenuItemProp[] }) => { return ( @@ -19,31 +20,41 @@ const MobileMenu = ({ links }: { links: MenuItemProp[] }) => { - + Acme Inc - {links.map((link, index) => { - return ( - - - {link.title} - - ); - })} + + + + + {links.map((link, index) => ( + + ))} + ); }; +const MobileMenuItem = ({ link }: { link: MenuItemProp }) => { + const Icon = (link.icon ?? AlignJustifyIcon) as React.ElementType; + + return ( + + + {link.title} + + ); +}; + export default MobileMenu; diff --git a/resources/js/Components/Sidebar.tsx b/resources/js/Components/Sidebar.tsx index 823974b..56e71bb 100644 --- a/resources/js/Components/Sidebar.tsx +++ b/resources/js/Components/Sidebar.tsx @@ -1,5 +1,5 @@ import { Link, usePage } from "@inertiajs/react"; -import { Home } from "lucide-react"; +import { AlignJustifyIcon, Home, Icon } from "lucide-react"; import { cn } from "@/lib/utils"; import { buttonVariants } from "@/Components/ui/button"; import { @@ -10,6 +10,7 @@ import { } from "@/Components/ui/tooltip"; import { MenuItemProp } from "@/types"; import ApplicationLogo from "@/Components/ApplicationLogo"; +import { ReactNode } from "react"; type Props = { links: MenuItemProp[]; @@ -22,6 +23,8 @@ type MenuItemProps = { }; const CollapsedMenuItem = ({ link, isActive }: MenuItemProps) => { + const Icon = (link.icon ?? AlignJustifyIcon) as React.ElementType; + return ( @@ -37,7 +40,7 @@ const CollapsedMenuItem = ({ link, isActive }: MenuItemProps) => { "dark:bg-muted dark:text-muted-foreground dark:hover:bg-muted dark:hover:text-white" )} > - + {} {link.title} @@ -49,6 +52,8 @@ const CollapsedMenuItem = ({ link, isActive }: MenuItemProps) => { }; const ExpandedMenuItem = ({ link, isActive }: MenuItemProps) => { + const Icon = (link.icon ?? AlignJustifyIcon) as React.ElementType; + return ( { "justify-start" )} > - + {} {link.title} ); }; const Sidebar = ({ links, isCollapsed }: Props) => { - const { url, component } = usePage(); + const { url } = usePage(); return ( diff --git a/resources/js/Layouts/AuthenticatedLayout.tsx b/resources/js/Layouts/AuthenticatedLayout.tsx index f389d23..584d1b9 100644 --- a/resources/js/Layouts/AuthenticatedLayout.tsx +++ b/resources/js/Layouts/AuthenticatedLayout.tsx @@ -1,7 +1,7 @@ import { PropsWithChildren, ReactNode, useState } from "react"; import { Link } from "@inertiajs/react"; import { MenuItemProp, User } from "@/types"; -import { CircleUser, Search } from "lucide-react"; +import { CircleUser, Search, UserIcon } from "lucide-react"; import { Button } from "@/Components/ui/button"; import { DropdownMenu, @@ -33,6 +33,7 @@ const links: MenuItemProp[] = [ title: "Profile", href: route("profile.edit"), variant: "ghost", + icon: UserIcon, }, ]; diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 5f276dd..15a9890 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -1,3 +1,6 @@ +import { LucideProps } from "lucide-react"; +import { ForwardRefExoticComponent, ReactNode, RefAttributes } from "react"; + export interface User { id: number; name: string; @@ -16,6 +19,11 @@ export type PageProps< export type MenuItemProp = { title: string; href: string; + icon?: + | ForwardRefExoticComponent< + Omit & RefAttributes + > + | ReactNode; variant: | "link" | "default"