From 73cb1db6d9b1e1e2abe0ca3fc19e545e5aa52ca8 Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 18 Dec 2024 10:20:36 -0600 Subject: [PATCH] Add basic tab selection --- .../UnifiedSidenav/UnifiedSidenav.js | 28 +++++++++++++++---- src/layouts/index.js | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/components/UnifiedSidenav/UnifiedSidenav.js b/src/components/UnifiedSidenav/UnifiedSidenav.js index f1e985c9c..c2d405e4a 100644 --- a/src/components/UnifiedSidenav/UnifiedSidenav.js +++ b/src/components/UnifiedSidenav/UnifiedSidenav.js @@ -22,7 +22,10 @@ const caretStyle = css` min-width: 16px; `; -function CollapsibleNavItem({ items, label, level = 1 }) { +function isSelectedTab(slug) { + return window.location.pathname === `${slug}/`; +} +function CollapsibleNavItem({ items, label, url, level = 1 }) { const [isOpen, setIsOpen] = useState(false); const iconType = isOpen ? 'CaretDown' : 'CaretRight'; @@ -31,11 +34,18 @@ function CollapsibleNavItem({ items, label, level = 1 }) { setIsOpen(!isOpen); }; + console.log(); return ( <> - setIsOpen(!isOpen)}> + setIsOpen(!isOpen)} + > - {label} + {label} {isOpen && items.map((item) => )} @@ -56,11 +66,19 @@ function UnifiedTocNavItem({ label, group, url, collapsible, items, level = 1 }) // collapsible is for items that have nested links if (collapsible) { - return ; + return ( + + ); } return ( - + {label} ); diff --git a/src/layouts/index.js b/src/layouts/index.js index 19e0ce0e6..b41fd45ed 100644 --- a/src/layouts/index.js +++ b/src/layouts/index.js @@ -119,7 +119,7 @@ const DefaultLayout = ({ children, data: { page }, pageContext: { slug, repoBran {!isInPresentationMode ?
:
} {isUnifiedToc ? ( - + ) : sidenav && !isInPresentationMode ? (