From 0cd75975c2faa5251cd5d567c1167793dc517354 Mon Sep 17 00:00:00 2001 From: Bilal ABBAD Date: Wed, 30 Oct 2024 17:31:01 +0100 Subject: [PATCH] update on Menu accordion UX/UI (#4774) - scroll vertical is a props on ScrollArea MenuItem: - Accordion are open by default - Chevron is on the right - CSS updates --- .../src/components/search/search-anywhere.tsx | 4 +-- frontend/app/src/components/ui/accordion.tsx | 23 +++++++++------ .../app/src/components/ui/dropdown-menu.tsx | 6 ++-- .../app/src/components/ui/scroll-area.tsx | 11 +++++--- frontend/app/src/pages/ipam/layout.tsx | 2 +- frontend/app/src/pages/objects/layout.tsx | 2 +- .../components/menu-section-internal.tsx | 4 +++ .../components/menu-section-object.tsx | 28 +++++++++++-------- .../screens/layout/menu-navigation/styles.tsx | 2 +- 9 files changed, 50 insertions(+), 32 deletions(-) diff --git a/frontend/app/src/components/search/search-anywhere.tsx b/frontend/app/src/components/search/search-anywhere.tsx index c691c501de..f69f2a367d 100644 --- a/frontend/app/src/components/search/search-anywhere.tsx +++ b/frontend/app/src/components/search/search-anywhere.tsx @@ -23,9 +23,9 @@ const SearchAnywhereTriggerButton = ({ className, ...props }: ButtonProps) => { data-testid="search-anywhere-trigger" {...props} > -
+
diff --git a/frontend/app/src/components/ui/accordion.tsx b/frontend/app/src/components/ui/accordion.tsx index 244d0afbee..5c8fcb248c 100644 --- a/frontend/app/src/components/ui/accordion.tsx +++ b/frontend/app/src/components/ui/accordion.tsx @@ -11,22 +11,25 @@ export const AccordionItem = AccordionPrimitive.Item; export const AccordionTrigger = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( + React.ComponentPropsWithoutRef & { iconClassName?: string } +>(({ className, children, iconClassName, ...props }, ref) => ( iconify-icon]:rotate-90", + "flex flex-1 items-center py-4 font-medium transition-all [&[data-state=open]>div>iconify-icon]:rotate-90", className )} {...props} > - {children} + +
+ +
)); @@ -34,12 +37,14 @@ export const AccordionTrigger = React.forwardRef< export const AccordionContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +>(({ className, children, style, ...props }, ref) => ( -
{children}
+
+ {children} +
)); diff --git a/frontend/app/src/components/ui/dropdown-menu.tsx b/frontend/app/src/components/ui/dropdown-menu.tsx index 9c9a8630ce..dd7764a15f 100644 --- a/frontend/app/src/components/ui/dropdown-menu.tsx +++ b/frontend/app/src/components/ui/dropdown-menu.tsx @@ -104,10 +104,10 @@ export const DropdownMenuSubContent = forwardRef< export const DropdownMenuAccordion = forwardRef< ElementRef, - ComponentPropsWithoutRef ->((props, ref) => { + ComponentPropsWithoutRef & { defaultOpen?: boolean } +>(({ defaultOpen, ...props }, ref) => { return ( - + ); diff --git a/frontend/app/src/components/ui/scroll-area.tsx b/frontend/app/src/components/ui/scroll-area.tsx index 5d536bb255..e507689571 100644 --- a/frontend/app/src/components/ui/scroll-area.tsx +++ b/frontend/app/src/components/ui/scroll-area.tsx @@ -6,8 +6,11 @@ import * as React from "react"; export const ScrollArea = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( + React.ComponentPropsWithoutRef & { + scrollX?: boolean; + scrollY?: boolean; + } +>(({ className, children, scrollX = false, scrollY = true, ...props }, ref) => ( {children} - - + {scrollX && } + {scrollY && } )); diff --git a/frontend/app/src/pages/ipam/layout.tsx b/frontend/app/src/pages/ipam/layout.tsx index 7a214b0c06..f408cbc9fe 100644 --- a/frontend/app/src/pages/ipam/layout.tsx +++ b/frontend/app/src/pages/ipam/layout.tsx @@ -13,7 +13,7 @@ function IpamLayout() {
- +
diff --git a/frontend/app/src/pages/objects/layout.tsx b/frontend/app/src/pages/objects/layout.tsx index d99924d8eb..c961002e67 100644 --- a/frontend/app/src/pages/objects/layout.tsx +++ b/frontend/app/src/pages/objects/layout.tsx @@ -55,7 +55,7 @@ const ObjectPageLayout = () => { {treeSchema && ( <> - + = ({ item }) => ( {item.label} + ); diff --git a/frontend/app/src/screens/layout/menu-navigation/components/menu-section-object.tsx b/frontend/app/src/screens/layout/menu-navigation/components/menu-section-object.tsx index c759eaeedb..74bcd50596 100644 --- a/frontend/app/src/screens/layout/menu-navigation/components/menu-section-object.tsx +++ b/frontend/app/src/screens/layout/menu-navigation/components/menu-section-object.tsx @@ -34,14 +34,9 @@ const RecursiveObjectMenuItem: React.FC<{ isCollapsed?: boolean; level?: number; }> = ({ item, isCollapsed, level = 0 }) => { - const commonStyleProps = { - className: menuNavigationItemStyle, - style: { marginLeft: level * 20 }, - }; - if (!item.children?.length) { return ( - + {item.label} @@ -51,17 +46,28 @@ const RecursiveObjectMenuItem: React.FC<{ } return ( - - + + + {item.path ? ( - + {item.label} ) : ( item.label )} - + + {item.children.map((child) => (

{item.label}

{item.children.map((child) => ( diff --git a/frontend/app/src/screens/layout/menu-navigation/styles.tsx b/frontend/app/src/screens/layout/menu-navigation/styles.tsx index 744acbf33e..57ba3b5f19 100644 --- a/frontend/app/src/screens/layout/menu-navigation/styles.tsx +++ b/frontend/app/src/screens/layout/menu-navigation/styles.tsx @@ -1,2 +1,2 @@ export const menuNavigationItemStyle = - "flex items-center outline-none gap-2 px-3 py-2 rounded font-medium text-neutral-900 hover:bg-neutral-100 focus:bg-neutral-100 group data-[state=open]:bg-indigo-50 data-[state=open]:text-indigo-700"; + "flex items-center outline-none gap-2 p-2 rounded font-medium text-neutral-900 hover:bg-neutral-100 focus:bg-neutral-100 group data-[state=open]:bg-indigo-50 data-[state=open]:text-indigo-700";