From 97e4bc9bad34f7bb3437e09ba6503fbeba777038 Mon Sep 17 00:00:00 2001 From: Giancarlo Buomprisco Date: Thu, 6 Feb 2025 10:00:00 +0700 Subject: [PATCH] Refactor sidebar navigation menu item rendering and styling (#150) - Improve sidebar menu item layout and responsiveness - Extract and optimize classNames for link and span elements - Remove conditional rendering of `renderAction` - Enhance dynamic styling for collapsed and expanded sidebar states --- packages/ui/src/shadcn/sidebar.tsx | 45 +++++++++++++----------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/packages/ui/src/shadcn/sidebar.tsx b/packages/ui/src/shadcn/sidebar.tsx index 9ea913cb9..4df3be872 100644 --- a/packages/ui/src/shadcn/sidebar.tsx +++ b/packages/ui/src/shadcn/sidebar.tsx @@ -526,7 +526,7 @@ const SidebarMenuItem: React.FC> = ({
  • {children.map((child) => { - if (child.renderAction) { - return ( - - {child.renderAction} - - ); - } - const isActive = isRouteActive( child.path, currentPath, child.end, ); + const linkClassName = cn( + 'flex items-center', + { + 'mx-auto w-full gap-0! [&>svg]:flex-1': + !open, + }, + ); + + const spanClassName = cn( + 'w-auto transition-opacity duration-300', + { + 'w-0 opacity-0': !open, + }, + ); + return ( svg]:flex-1': - !open, - }, - )} + className={linkClassName} href={child.path} > {child.Icon} - + +