forked from devvsakib/DevToolsArena
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.jsx
More file actions
148 lines (139 loc) · 4.44 KB
/
Header.jsx
File metadata and controls
148 lines (139 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import {
MdPeople,
MdInsertDriveFile,
MdClose,
MdMenu,
MdHome,
MdStore,
} from "react-icons/md";
import { AiFillGithub } from "react-icons/ai";
import { Link } from "react-router-dom";
import { HiMoon, HiSun } from "react-icons/hi";
import { ThemeContext } from "../../context/ThemeContext";
import { useContext, useState, useEffect} from "react";
function Header({notice }) {
const { theme, toggleTheme } = useContext(ThemeContext);
const [open, setOpen] = useState(false);
const [countStar, setCountStar] = useState(0);
useEffect(() => {
fetch("https://api.github.com/repos/devvsakib/github-error-solve")
.then((response) => response.json())
.then((data) => setCountStar(data.stargazers_count))
.catch((error) => console.error("Error fetching GitHub stars:", error));
}, []);
const navLink = [
{
name: "Home",
link: "/",
icon: <MdHome size="1.2rem" />,
},
{
name: "Doc",
link: "/doc",
icon: <MdInsertDriveFile size="1.2rem" />,
},
{
name: "DevArea",
link: "/devarea",
icon: <MdStore size="1.2rem" />,
},
{
name: "Resources",
link: "/resources",
icon: <MdStore size="1.2rem" />,
},
];
const githubLink = {
name: "Github",
link: "https://github.com/devvsakib/github-error-solve",
icon: <AiFillGithub size="1.2rem" />,
isExternalURL: true,
};
return (
<header className="p-4 shadow-lg backdrop-blur-sm z-50">
<div className="w-full md:w-5/6 mx-auto flex flex-row md:flex-row justify-between items-center">
{/* Logo */}
<Link to={"/"}>
<img
src="/assets/logo.png"
className="w-36 bg-transparent invert dark:invert-0"
alt="GES"
/>
</Link>
{/* GitHub, theme toggle and menu icon for mobile */}
<div className="flex items-center gap-3 md:hidden">
<a target="_blank" href={githubLink.link}>
<div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full text-sm">
<span className="githubBtn">
{githubLink.icon}
</span>
{
countStar && (
<div className="flex items-center gap-1">
{countStar}
</div>
)
}
</div>
</a>
<div className="text-lg cursor-pointer" onClick={toggleTheme}>
<HiMoon className="dark:hidden" />
<HiSun className="hidden dark:inline" />
</div>
<div
onClick={() => setOpen((val) => !val)}
className="cursor-pointer"
>
{open ? <MdClose size="1.2rem" /> : <MdMenu size="1.2rem" />}
</div>
</div>
{/* Nav link items */}
<div
className={`
md:flex md:items-center
md:pb-0 md:gap-6
md:static md:z-auto
md:w-auto md:pl-0
md:bg-transparent
grid gap-2 absolute
z-[-1] left-0 w-full py-2 pl-8
transition-all duration-500 ease-in
${open ? (theme === "dark" ? "bg-dark/90" : "bg-white/90") : ""}
${open ? "top-14" : "top-[-490px]"}`}
>
{navLink.map((link, index) => (
<div key={`${link.name}-${index}`}>
<Link className="flex items-center gap-1" to={link.link}>
{/* {link.icon} */}
{link.name}
</Link>
</div>
))}
{/* GitHub link for desktop */}
<div className="hidden md:block">
<a target="_blank" href={githubLink.link}>
<div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full">
<span className="githubBtn">
{githubLink.icon}
</span>
{
countStar && (
<div className="flex items-center gap-1">
{countStar}
</div>
)
}
</div>
</a>
</div>
{/* Theme toggle for desktop */}
<div className="text-lg cursor-pointer hidden md:block" onClick={toggleTheme}>
<HiMoon className="dark:hidden" />
<HiSun className="hidden dark:inline" />
</div>
</div>
</div>
</header>
);
}
export default Header;