Skip to content

Commit

Permalink
fix VersionedNavGroup missing type
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Nov 26, 2024
1 parent b3d5457 commit 3d15a60
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
13 changes: 8 additions & 5 deletions apps/web/src/components/Navigation/NavigationSubgroup.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { useEffect, useState } from 'react'
import { usePathname } from 'next/navigation'
import clsx from 'clsx'
import { ChevronDown, ChevronRight } from 'lucide-react'
import { usePathname } from 'next/navigation'
import { useEffect, useState } from 'react'

import { NavSubgroup } from './routes'
import { NavigationLink } from './NavigationLink'
import { NavSubgroup } from './routes'

export function NavigationSubgroup({ subgroup }: { subgroup: NavSubgroup }) {
const [isExpanded, setIsExpanded] = useState(false)
const pathname = usePathname()

const isActive = subgroup.links.some(link => link.href === pathname)
console.log('subgroup', subgroup)
const isActive = subgroup.links.some((link) => link.href === pathname)

// Automatically expand the subgroup if it's active
useEffect(() => {
Expand All @@ -36,7 +37,9 @@ export function NavigationSubgroup({ subgroup }: { subgroup: NavSubgroup }) {
>
<div className="flex items-center justify-start gap-1">
{subgroup.icon}
<h3 className="text-sm font-medium group-hover:text-white">{subgroup.title}</h3>
<h3 className="text-sm font-medium group-hover:text-white">
{subgroup.title}
</h3>
</div>
{isExpanded ? (
<ChevronDown className="w-4 h-4 ml-2 text-zinc-400 group-hover:text-white" />
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/components/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,14 @@ function VersionedNavigationGroup({
<>
{group.versionedItems[curVersion]?.map((item) => (
<React.Fragment key={item.title}>
<NavigationSubgroup subgroup={item as NavSubgroup} />
{(item as any).links ? (
<NavigationSubgroup subgroup={item as NavSubgroup} />
) : (
<NavigationLink
link={item as NavLink}
className="font-medium"
/>
)}
</React.Fragment>
))}
</>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Navigation/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface NavGroup {
export interface VersionedNavGroup {
title?: string
icon?: React.ReactNode
versionedItems: { [key: string]: NavSubgroup[] }
versionedItems: { [key: string]: Array<NavLink | NavSubgroup> }
}

export const docRoutes: NavGroup[] = [
Expand Down

0 comments on commit 3d15a60

Please sign in to comment.