1
- import React from 'react' ;
1
+ import React , { useState , useEffect } from 'react' ;
2
2
import Link from 'next/link' ;
3
+ import { motion } from 'framer-motion' ;
3
4
import {
4
5
DropdownMenu ,
5
6
DropdownMenuContent ,
@@ -8,62 +9,86 @@ import {
8
9
} from "@/components/ui/dropdown-menu" ;
9
10
10
11
export default function Hamburger ( ) {
12
+ const [ isOpenDropdown , setIsOpenDropdown ] = useState ( false ) ;
13
+
14
+ useEffect ( ( ) => {
15
+ const handleResize = ( ) => {
16
+ setIsOpenDropdown ( false ) ;
17
+ } ;
18
+
19
+ window . addEventListener ( 'resize' , handleResize ) ;
20
+ return ( ) => window . removeEventListener ( 'resize' , handleResize ) ;
21
+ } , [ ] ) ;
11
22
12
23
return (
13
- < DropdownMenu modal = { false } >
24
+ < DropdownMenu modal = { false } open = { isOpenDropdown } onOpenChange = { setIsOpenDropdown } >
14
25
< DropdownMenuTrigger asChild >
15
- < button className = "p-2 rounded-lg transition-all" >
16
- < svg
17
- className = "w-10 h-10 hover:scale-110 hover:rotate-2 transition-all"
18
- fill = "none"
19
- stroke = "white"
20
- viewBox = "0 0 24 24"
21
- xmlns = "http://www.w3.org/2000/svg"
22
- >
23
- < path strokeLinecap = "round"
24
- strokeLinejoin = "round"
25
- d = "M4 6h16M4 12h16m-7 6h7"
26
+ < button className = "p-2 rounded-lg" >
27
+ < div className = "w-10 h-10 flex flex-col justify-center items-center" >
28
+ < motion . div
29
+ className = "h-0.5 w-6 bg-white"
30
+ animate = { {
31
+ rotate : isOpenDropdown ? 45 : 0 ,
32
+ y : isOpenDropdown ? 2 : - 4 ,
33
+ } }
34
+ transition = { { duration : 0.3 , ease : "easeInOut" } }
35
+ />
36
+ < motion . div
37
+ className = "h-0.5 w-6 bg-white"
38
+ animate = { {
39
+ opacity : isOpenDropdown ? 0 : 1 ,
40
+ x : isOpenDropdown ? - 10 : 0 ,
41
+ } }
42
+ transition = { { duration : 0.2 , ease : "easeInOut" } }
43
+ />
44
+ < motion . div
45
+ className = "h-0.5 w-6 bg-white"
46
+ animate = { {
47
+ rotate : isOpenDropdown ? - 45 : 0 ,
48
+ y : isOpenDropdown ? - 2 : 4 ,
49
+ } }
50
+ transition = { { duration : 0.3 , ease : "easeInOut" } }
26
51
/>
27
- </ svg >
52
+ </ div >
28
53
</ button >
29
54
</ DropdownMenuTrigger >
30
55
31
56
< DropdownMenuContent
32
57
align = "end"
33
- className = "w-44 bg-[#3977F9] border-none shadow-lg rounded-2xl text-white"
58
+ className = "w-44 bg-[#3977F9] border-none shadow-lg rounded-2xl text-white dropdown-content overflow-hidden "
34
59
>
35
60
36
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
61
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
37
62
< Link href = "/about" className = "w-full block" >
38
63
About Us
39
64
</ Link >
40
65
</ DropdownMenuItem >
41
66
42
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
67
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
43
68
< Link href = "/events" className = "w-full block" >
44
69
Events
45
70
</ Link >
46
71
</ DropdownMenuItem >
47
72
48
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
73
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
49
74
< Link href = "/resources" className = "w-full block" >
50
75
Resources
51
76
</ Link >
52
77
</ DropdownMenuItem >
53
78
54
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
79
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
55
80
< Link href = "/sponsors" className = "w-full block" >
56
81
Sponsors
57
82
</ Link >
58
83
</ DropdownMenuItem >
59
84
60
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
85
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
61
86
< Link href = "/contact-us" className = "w-full block" >
62
87
Contact Us
63
88
</ Link >
64
89
</ DropdownMenuItem >
65
90
66
- < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer" >
91
+ < DropdownMenuItem asChild className = "text-white text-lg py-2 px-4 rounded-2xl focus:bg-white/10 hover:bg-white/10 cursor-pointer dropdown-item " >
67
92
< a
68
93
target = "_blank"
69
94
href = "https://csesoc-merch.square.site/"
0 commit comments