1
1
import Image from "next/image" ;
2
2
import Link from "next/link" ;
3
- import React from "react" ;
3
+ import React , { useState , useRef } from "react" ;
4
4
5
5
const Header = ( ) => {
6
+ const [ isDropdownOpen , setIsDropdownOpen ] = useState ( false ) ;
7
+ const timeoutRef = useRef ( null ) ;
8
+
9
+ const handleMouseEnter = ( ) => {
10
+ clearTimeout ( timeoutRef . current ) ;
11
+ setIsDropdownOpen ( true ) ;
12
+ } ;
13
+
14
+ const handleMouseLeave = ( ) => {
15
+ timeoutRef . current = setTimeout ( ( ) => {
16
+ setIsDropdownOpen ( false ) ;
17
+ } , 200 ) ;
18
+ } ;
19
+
6
20
return (
7
21
< div className = "h-[72px] w-full flex items-center justify-between bg-[#D9D9D9]" >
8
22
< div className = "flex justify-between w-full px-10" >
9
- < div className = "w-[201px] ml-5" >
23
+ < div className = "w-[201px] ml-5" >
10
24
< Image
11
25
src = "/assets/Home/Logo_Home.png"
12
26
alt = ""
@@ -18,9 +32,37 @@ const Header = () => {
18
32
< Link href = "/" className = "text-[#000000] w-auto" >
19
33
Home
20
34
</ Link >
21
- < Link href = "/blog" className = "text-[#000000] w-auto" >
22
- Explore
23
- </ Link >
35
+ < div
36
+ className = "relative w-auto"
37
+ onMouseEnter = { handleMouseEnter }
38
+ onMouseLeave = { handleMouseLeave }
39
+ >
40
+ < div className = "text-[#000000] cursor-pointer w-auto" >
41
+ Explore
42
+ </ div >
43
+ { isDropdownOpen && (
44
+ < div className = "absolute top-full mt-2 w-40 bg-white shadow-lg rounded-md" >
45
+ < Link
46
+ href = "/intro"
47
+ className = "block px-4 py-2 rounded-t-md text-[#000000] hover:bg-gray-200"
48
+ >
49
+ Intro
50
+ </ Link >
51
+ < Link
52
+ href = "/git-and-github/how-to-install-git-git-tutorial"
53
+ className = "block px-4 py-2 text-[#000000] hover:bg-gray-200"
54
+ >
55
+ Git and GitHub
56
+ </ Link >
57
+ < Link
58
+ href = "/blog/5-best-apps-vloggers-should-have-on-a-phone"
59
+ className = "block px-4 py-2 rounded-b-md text-[#000000] hover:bg-gray-200"
60
+ >
61
+ All Blogs
62
+ </ Link >
63
+ </ div >
64
+ ) }
65
+ </ div >
24
66
< Link href = "/" className = "text-[#000000] w-auto" >
25
67
About
26
68
</ Link >
0 commit comments