From 9cd834d839fa63765057542bac370e3d409340ec Mon Sep 17 00:00:00 2001 From: Aakash Date: Mon, 2 Oct 2023 00:34:54 +0530 Subject: [PATCH 1/2] Added the feature : Making headings as Accordions on Side Bar Nav --- components/layout/sidebar-nav.tsx | 73 ++++++++++++++++++------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/components/layout/sidebar-nav.tsx b/components/layout/sidebar-nav.tsx index f56d694..3ef228e 100644 --- a/components/layout/sidebar-nav.tsx +++ b/components/layout/sidebar-nav.tsx @@ -22,36 +22,49 @@ export function DocsSidebarNav({ items }: DocsSidebarNavProps) { return items.length ? (
{items.map((item, index) => ( -
-

- {item.title} -

- {item.items ? ( -
- {item.items.map((item) => ( - <> - {item.href ? ( - - ) : ( - - -
- - {item.title} -
- - - -
-
- )} - - ))} -
- ) : null} +
+ + +
+ + {item.title} + +
+ + {item.items ? ( +
+ {item.items.map(item => ( + <> + {item.href ? ( + + ) : ( + + +
+ + {" "} + {item.title} + +
+ + + +
+
+ )} + + ))} +
+ ) : null} +
+
+
))}
From 5455b246437cc092d1250531aa920c943723ed92 Mon Sep 17 00:00:00 2001 From: Aakash Date: Mon, 2 Oct 2023 13:49:13 +0530 Subject: [PATCH 2/2] modified for darkmode --- components/layout/sidebar-nav.tsx | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/components/layout/sidebar-nav.tsx b/components/layout/sidebar-nav.tsx index 3ef228e..7eddb97 100644 --- a/components/layout/sidebar-nav.tsx +++ b/components/layout/sidebar-nav.tsx @@ -1,23 +1,23 @@ -"use client"; +"use client" -import Link from "next/link"; -import { usePathname } from "next/navigation"; +import Link from "next/link" +import { usePathname } from "next/navigation" -import { cn } from "@/lib/utils"; -import { NavItem, SidebarNav, SidebarNavItem } from "@/types"; +import { cn } from "@/lib/utils" +import { NavItem, SidebarNav, SidebarNavItem } from "@/types" import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, -} from "../ui/accordion"; +} from "../ui/accordion" export interface DocsSidebarNavProps { - items: SidebarNav[]; + items: SidebarNav[] } export function DocsSidebarNav({ items }: DocsSidebarNavProps) { - const pathname = usePathname(); + const pathname = usePathname() return items.length ? (
@@ -26,7 +26,7 @@ export function DocsSidebarNav({ items }: DocsSidebarNavProps) {
- + {item.title}
@@ -68,12 +68,12 @@ export function DocsSidebarNav({ items }: DocsSidebarNavProps) {
))}
- ) : null; + ) : null } interface DocsSidebarNavItemsProps { - items: NavItem[] | undefined; - pathname: string | null; + items: NavItem[] | undefined + pathname: string | null } export function DocsSidebarNavItems({ @@ -85,15 +85,15 @@ export function DocsSidebarNavItems({ {items.map((item, index) => { return ( - ); + ) })} - ) : null; + ) : null } interface DocsSidebarNavItemsrops { - item: NavItem | SidebarNavItem; - pathname: string | null; + item: NavItem | SidebarNavItem + pathname: string | null } export function DocsSidebarNavItem({ @@ -113,5 +113,5 @@ export function DocsSidebarNavItem({ {item.title} - ); + ) }