From 2de29dda3696aa6b3e62b22cc5dd71f20616a8b3 Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Sat, 4 Jan 2025 15:44:01 -0800 Subject: [PATCH] improve AppSidebarNav --- .../web/ui/layout/sidebar/app-sidebar-nav.tsx | 6 +++-- apps/web/ui/layout/sidebar/sidebar-nav.tsx | 27 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx index 94c586b403..a2ed30981d 100644 --- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx +++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx @@ -38,11 +38,12 @@ const NAV_AREAS: SidebarNavAreas<{ flags?: Record; programs?: { id: string }[]; session?: Session | null; + showNews?: boolean; }> = { // Top-level - default: ({ slug, queryString, programs }) => ({ + default: ({ slug, queryString, programs, showNews }) => ({ showSwitcher: true, - showNews: true, + showNews, direction: "left", content: [ { @@ -267,6 +268,7 @@ export function AppSidebarNav({ flags, programs, session: session || undefined, + showNews: pathname.startsWith(`/${slug}/programs/`) ? false : true, }} toolContent={toolContent} newsContent={newsContent} diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsx index 3f5ae0d7c5..2bc2a21a65 100644 --- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx +++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx @@ -1,5 +1,6 @@ import { AnimatedSizeContainer, ClientOnly, Icon, NavWordmark } from "@dub/ui"; import { cn } from "@dub/utils"; +import { AnimatePresence, motion } from "framer-motion"; import { ChevronDown, ChevronLeft } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; @@ -16,7 +17,6 @@ export type NavItemCommon = { name: string; href: string; exact?: boolean; - hasIndicator?: boolean; }; export type NavSubItemType = NavItemCommon; @@ -123,9 +123,22 @@ export function SidebarNav>({ ))} -
- {showNews && newsContent} -
+ + {showNews && ( + + {newsContent} + + )} + ); })} @@ -139,7 +152,7 @@ export function SidebarNav>({ } function NavItem({ item }: { item: NavItemType | NavSubItemType }) { - const { name, href, exact, hasIndicator } = item; + const { name, href, exact } = item; const Icon = "icon" in item ? item.icon : undefined; const items = "items" in item ? item.items : undefined; @@ -180,12 +193,10 @@ function NavItem({ item }: { item: NavItemType | NavSubItemType }) { /> )} {name} - {(items || hasIndicator) && ( + {items && (
{items ? ( - ) : hasIndicator ? ( -
) : null}
)}