feat: global ui & functional update
This commit is contained in:
@@ -42,10 +42,12 @@ export function NavMain({
|
||||
url: string;
|
||||
icon?: LucideIcon;
|
||||
isActive?: boolean;
|
||||
tooltip?: string;
|
||||
items?: {
|
||||
title: string;
|
||||
url: string;
|
||||
icon?: LucideIcon;
|
||||
tooltip?: string;
|
||||
}[];
|
||||
}[];
|
||||
guideState?: NavGuideState;
|
||||
@@ -60,13 +62,15 @@ export function NavMain({
|
||||
<SidebarMenu>
|
||||
{items.map((item) => {
|
||||
const hasSubmenu = item.items && item.items.length > 0;
|
||||
const isActive = pathname === item.url;
|
||||
const isActive = hasSubmenu
|
||||
? pathname.startsWith(item.url)
|
||||
: pathname === item.url || (item.title === "Главная" ? false : pathname.startsWith(item.url + "/"));
|
||||
const hasActiveSubmenu =
|
||||
hasSubmenu && item.items!.some((sub) => pathname === sub.url);
|
||||
const shouldForceOpen = guideState?.expandedItems?.includes(item.title);
|
||||
const shouldHighlightButton = item.title === "Аналитика"
|
||||
? false
|
||||
: isActive;
|
||||
: isActive || hasActiveSubmenu;
|
||||
const isGuideHighlight = highlightedItem === item.title;
|
||||
const highlightedButtonClass = isGuideHighlight
|
||||
? "ring-2 ring-primary/70"
|
||||
@@ -79,7 +83,7 @@ export function NavMain({
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<SidebarMenuButton
|
||||
tooltip={item.title}
|
||||
tooltip={item.tooltip ? { children: item.tooltip, side: "right" } : item.title}
|
||||
isActive={shouldHighlightButton}
|
||||
className={cn(highlightedButtonClass)}
|
||||
>
|
||||
@@ -161,7 +165,7 @@ export function NavMain({
|
||||
<>
|
||||
<CollapsibleTrigger asChild>
|
||||
<SidebarMenuButton
|
||||
tooltip={item.title}
|
||||
tooltip={item.tooltip ? { children: item.tooltip, side: "right" } : item.title}
|
||||
isActive={shouldHighlightButton}
|
||||
className={cn(highlightedButtonClass)}
|
||||
>
|
||||
@@ -234,7 +238,7 @@ export function NavMain({
|
||||
) : (
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
tooltip={item.title}
|
||||
tooltip={item.tooltip ? { children: item.tooltip, side: "right" } : item.title}
|
||||
isActive={shouldHighlightButton}
|
||||
className={cn(highlightedButtonClass)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user