From 32ddbca5c8e8ce58b35614b579d3ad83a1cd99fb Mon Sep 17 00:00:00 2001 From: Sam Piper Date: Wed, 9 Oct 2024 14:34:33 +0100 Subject: [PATCH] feat: Add onLinkClick prop to UserNav and ListItem components - feat: Enable custom onLinkClick handler in UserNav component - feat: Support onClick event in ListItem component for enhanced interactivity - refactor: Import React in UserNav component for consistency --- .../navbar/appSwitcher/ListItem.tsx | 4 +++- .../components/navbar/appSwitcher/index.tsx | 20 ++++++++++++---- apps/forge/src/components/navbar/index.tsx | 4 ++-- .../src/components/navbar/userNav/index.tsx | 23 ++++++++++++++----- 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/apps/forge/src/components/navbar/appSwitcher/ListItem.tsx b/apps/forge/src/components/navbar/appSwitcher/ListItem.tsx index 7982a14..8d139e8 100644 --- a/apps/forge/src/components/navbar/appSwitcher/ListItem.tsx +++ b/apps/forge/src/components/navbar/appSwitcher/ListItem.tsx @@ -7,10 +7,11 @@ interface ListItemProps extends AnchorHTMLAttributes { icon?: ReactNode; title: string; to: string; + onClick?: () => void; } const ListItem = React.forwardRef( - ({ className, title, icon, children, to, ...props }, ref) => { + ({ className, title, icon, children, to, onClick, ...props }, ref) => { return (
  • @@ -21,6 +22,7 @@ const ListItem = React.forwardRef( "flex items-center space-x-3 select-none rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground", className, )} + onClick={onClick} {...props} > {icon && {icon}} diff --git a/apps/forge/src/components/navbar/appSwitcher/index.tsx b/apps/forge/src/components/navbar/appSwitcher/index.tsx index 6eb082f..d2938c5 100644 --- a/apps/forge/src/components/navbar/appSwitcher/index.tsx +++ b/apps/forge/src/components/navbar/appSwitcher/index.tsx @@ -1,3 +1,4 @@ +import React from "react"; import ContextMenuWrapper from "@/components/navbar/appSwitcher/ContextMenu.tsx"; import ListItem from "@/components/navbar/appSwitcher/ListItem"; import useCurrentApp from "@/hooks/useCurrentApp.ts"; @@ -13,9 +14,19 @@ import { } from "@ui/components/ui/navigation-menu"; import { BookOpen, PenLine, Printer } from "lucide-react"; -export default function AppSwitcher() { +interface AppSwitcherProps { + onLinkClick?: () => void; +} + +export default function AppSwitcher({ onLinkClick }: AppSwitcherProps) { const currentapp = useCurrentApp(); + const handleLinkClick = () => { + if (onLinkClick) { + onLinkClick(); + } + }; + return ( @@ -32,6 +43,7 @@ export default function AppSwitcher() { "flex h-full w-full select-none flex-col justify-end rounded-md p-6 no-underline outline-none focus:shadow-md bg-gradient-to-b from-red-300 to-white dark:bg-gradient-to-b dark:from-red-950 dark:to-black", )} to="/" + onClick={handleLinkClick} >
    iForge

    @@ -40,13 +52,13 @@ export default function AppSwitcher() {

  • - }> + } onClick={onLinkClick}> iForge Sign In System - }> + } onClick={onLinkClick}> Handle your iForge training here. - }> + } onClick={onLinkClick}> 3D Printing (WIP) diff --git a/apps/forge/src/components/navbar/index.tsx b/apps/forge/src/components/navbar/index.tsx index 9dcf2ed..1f1d030 100644 --- a/apps/forge/src/components/navbar/index.tsx +++ b/apps/forge/src/components/navbar/index.tsx @@ -21,7 +21,7 @@ export default function NavBar() {
    - +
    {/* Desktop Navigation */} @@ -31,7 +31,7 @@ export default function NavBar() {
    - + {/* Mobile Menu Button */}