1
+ import { BaseHTMLAttributes } from "react"
1
2
import { motion } from "framer-motion"
2
3
import dynamic from "next/dynamic"
3
- import { Box , type BoxProps , Text , UnorderedList } from "@chakra-ui/react"
4
4
import {
5
5
Item ,
6
6
List ,
@@ -9,15 +9,16 @@ import {
9
9
Viewport ,
10
10
} from "@radix-ui/react-navigation-menu"
11
11
12
- import { Button } from "@/components/Buttons "
12
+ import { cn } from "@/lib/utils/cn "
13
13
14
- import { MAIN_NAV_ID , NAV_PY , SECTION_LABELS } from "@/lib/constants"
14
+ import { MAIN_NAV_ID , SECTION_LABELS } from "@/lib/constants"
15
15
16
+ import { Button } from "../../../../tailwind/ui/buttons/Button"
16
17
import type { NavSections } from "../types"
17
18
18
19
import { useNavMenu } from "./useNavMenu"
19
20
20
- type NavMenuProps = BoxProps & {
21
+ type NavMenuProps = BaseHTMLAttributes < HTMLDivElement > & {
21
22
sections : NavSections
22
23
}
23
24
@@ -28,73 +29,53 @@ const Menu = ({ sections, ...props }: NavMenuProps) => {
28
29
const MenuContent = dynamic ( ( ) => import ( "./MenuContent" ) )
29
30
30
31
return (
31
- < Box { ...props } >
32
+ < div { ...props } >
32
33
< Root
33
34
dir = { direction }
34
35
orientation = "horizontal"
35
36
onValueChange = { handleSectionChange }
36
37
delayDuration = { 0 }
37
38
>
38
- < List asChild >
39
- < UnorderedList
40
- id = { MAIN_NAV_ID }
41
- display = "flex"
42
- listStyleType = "none"
43
- m = "0"
44
- >
45
- { SECTION_LABELS . map ( ( sectionKey ) => {
46
- const { label, items } = sections [ sectionKey ]
47
- const isActive = activeSection === sectionKey
39
+ < List id = { MAIN_NAV_ID } className = "m-0 flex list-none" >
40
+ { SECTION_LABELS . map ( ( sectionKey ) => {
41
+ const { label, items } = sections [ sectionKey ]
42
+ const isActive = activeSection === sectionKey
48
43
49
- return (
50
- < Item key = { sectionKey } value = { label } >
51
- < Trigger asChild >
52
- < Button
53
- py = "2"
54
- px = { { base : "3" , lg : "4" } }
55
- variant = "ghost"
56
- whiteSpace = "nowrap"
57
- color = { isActive ? "primary.base" : "body.base" }
58
- _after = { {
59
- content : '""' ,
60
- position : "absolute" ,
61
- insetInline : 0 ,
62
- top : "100%" ,
63
- height : NAV_PY ,
64
- } }
65
- >
66
- { /* Animated highlight for active section */ }
67
- { isActive && (
68
- < Box
69
- as = { motion . div }
70
- layoutId = "active-section-highlight"
71
- position = "absolute"
72
- inset = "0"
73
- bg = "primary.lowContrast"
74
- rounded = "base"
75
- zIndex = { 0 }
76
- />
77
- ) }
78
- < Text as = "span" position = "relative" zIndex = { 1 } >
79
- { label }
80
- </ Text >
81
- </ Button >
82
- </ Trigger >
83
- { /* Desktop Menu content */ }
84
- < MenuContent
85
- items = { items }
86
- isOpen = { isOpen }
87
- sections = { sections }
88
- />
89
- </ Item >
90
- )
91
- } ) }
92
- </ UnorderedList >
44
+ return (
45
+ < Item key = { sectionKey } value = { label } >
46
+ < Trigger asChild >
47
+ < Button
48
+ className = { cn (
49
+ "relative whitespace-nowrap px-3 py-2 lg:px-4" ,
50
+ isActive ? "text-primary" : "text-body" ,
51
+ "after:absolute after:inset-x-0 after:top-full after:h-4 after:content-['']"
52
+ ) }
53
+ variant = "ghost"
54
+ >
55
+ { /* Animated highlight for active section */ }
56
+ { isActive && (
57
+ < motion . div
58
+ layoutId = "active-section-highlight"
59
+ className = "absolute inset-0 z-0 rounded bg-primary-low-contrast"
60
+ />
61
+ ) }
62
+ < span className = "relative z-10" > { label } </ span >
63
+ </ Button >
64
+ </ Trigger >
65
+ { /* Desktop Menu content */ }
66
+ < MenuContent
67
+ items = { items }
68
+ isOpen = { isOpen }
69
+ sections = { sections }
70
+ />
71
+ </ Item >
72
+ )
73
+ } ) }
93
74
</ List >
94
75
95
76
< Viewport />
96
77
</ Root >
97
- </ Box >
78
+ </ div >
98
79
)
99
80
}
100
81
0 commit comments