@@ -8,8 +8,6 @@ import Link from 'next/link'
8
8
import { useRouter } from 'next/router'
9
9
import { NavigationGroup } from './config'
10
10
import NavLink from './NavLink'
11
- import { VisibleSectionHighlight } from './VisibleSectionHighlight'
12
- import { remToPx } from '@/lib/remToPx'
13
11
14
12
interface NavGroupProps {
15
13
group : NavigationGroup
@@ -25,54 +23,64 @@ export function NavGroup({ group, className }: NavGroupProps) {
25
23
[ useRouter ( ) , useSectionStore ( ( s : any ) => s . sections ) ] ,
26
24
isInsideMobileNavigation ,
27
25
)
28
-
29
26
let isActiveGroup =
30
27
group . group . href === router . pathname ||
31
28
( group . links &&
32
29
group . links . findIndex ( ( link ) => link . href === router . pathname ) !== - 1 )
33
30
34
- const groupTitleHeight = document . getElementById (
35
- `${ group . group . href } -link` ,
36
- ) ?. offsetHeight
37
-
38
31
return (
39
32
< li className = { clsx ( 'relative mt-6' , className ) } >
40
33
< motion . h2
41
34
layout = "position"
42
35
className = "text-xs font-semibold text-zinc-900 dark:text-white"
43
36
>
44
37
< Link
45
- id = { `${ group . group . href } -link` }
46
38
href = { group . group . href }
47
39
aria-current = { isActiveGroup ? 'page' : undefined }
48
- className = { lora . className }
40
+ className = { ` ${ lora . className } relative block` }
49
41
>
50
- { group . group . title }
42
+ { group . group . title } { ' ' }
43
+ { group . group . href === router . pathname && (
44
+ < div
45
+ className = { clsx (
46
+ 'absolute' ,
47
+ 'top-[-4px]' ,
48
+ 'bottom-[-4px]' ,
49
+ 'left-[-8px]' ,
50
+ 'right-0' ,
51
+ 'bg-indigo-600/30' ,
52
+ 'dark:bg-white/2.5' ,
53
+ 'rounded-[8px]' ,
54
+ ) }
55
+ />
56
+ ) }
51
57
</ Link >
52
58
</ motion . h2 >
53
- < div className = "mt-3 pl-2" >
54
- < AnimatePresence initial = { ! isInsideMobileNavigation } >
55
- { isActiveGroup && (
56
- < VisibleSectionHighlight pathname = { router . pathname } />
57
- ) }
58
- </ AnimatePresence >
59
- < div
60
- style = { { top : groupTitleHeight ! + remToPx ( 1 ) } }
61
- className = "absolute bottom-0 left-2 w-px bg-zinc-900/10 dark:bg-white/5"
62
- />
59
+ < div className = "relative mt-3 pl-2" >
60
+ < div className = "absolute inset-y-0 left-2 w-px bg-zinc-900/10 dark:bg-white/5" />
63
61
< ul role = "list" className = "border-l border-transparent" >
64
62
{ group . links ?. map ( ( link ) => (
65
63
< motion . li
66
64
key = { link . href }
67
65
layout = "position"
68
66
className = { `${ spectral . className } ` }
69
67
>
70
- < NavLink
71
- id = { `${ link . href } -link` }
72
- href = { link . href }
73
- active = { link . href === router . pathname }
74
- >
68
+ < NavLink href = { link . href } active = { link . href === router . pathname } >
75
69
{ link . title }
70
+ { link . href === router . pathname && (
71
+ < div
72
+ className = { clsx (
73
+ 'absolute' ,
74
+ 'top-[-4px]' ,
75
+ 'bottom-[-4px]' ,
76
+ 'left-[-16px]' ,
77
+ 'right-0' ,
78
+ 'bg-indigo-600/30' ,
79
+ 'dark:bg-white/2.5' ,
80
+ 'rounded-[8px]' ,
81
+ ) }
82
+ />
83
+ ) }
76
84
</ NavLink >
77
85
< AnimatePresence mode = "popLayout" initial = { false } >
78
86
{ link . href === router . pathname && sections . length > 0 && (
@@ -89,7 +97,7 @@ export function NavGroup({ group, className }: NavGroupProps) {
89
97
} }
90
98
>
91
99
{ sections . map ( ( section : any ) => (
92
- < li id = { ` ${ section . id } -li` } key = { section . id } >
100
+ < li key = { section . id } >
93
101
< NavLink
94
102
href = { `${ link . href } #${ section . id } ` }
95
103
tag = { section . tag }
0 commit comments