-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathHeader.jsx
More file actions
53 lines (48 loc) · 1.42 KB
/
Header.jsx
File metadata and controls
53 lines (48 loc) · 1.42 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
import { useState, useEffect } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCodeFork, faStar } from "@fortawesome/free-solid-svg-icons";
function Header({ theme }) {
const [repoData, setRepoData] = useState({ stars: 0, forks: 0 });
useEffect(() => {
const fetchRepoData = async () => {
try {
const response = await fetch("https://api.github.com/repos/FreeOps-Tools/LogIQ");
const data = await response.json();
setRepoData({
stars: data.stargazers_count || 0,
forks: data.forks_count || 0,
});
} catch (error) {
console.error("Error fetching GitHub data:", error);
}
};
fetchRepoData();
}, []);
return (
<header className="header">
<a href="/">
<img src="/logiq.svg" alt="Vite logo" width={50} height={50} style={{ padding: "10px" }} />
</a>
<h1 className={`logo ${theme}`}>LogIQ</h1>
<nav>
<ul>
<li>
<FontAwesomeIcon
icon={faStar}
style={{ color: "#DAAA3F", marginRight: "5px" }}
/>
{repoData.stars}
</li>
<li>
<FontAwesomeIcon
icon={faCodeFork}
style={{ color: "#768390", marginRight: "5px" }}
/>
{repoData.forks}
</li>
</ul>
</nav>
</header>
);
}
export default Header;