-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.tsx
More file actions
171 lines (150 loc) · 6.51 KB
/
Copy pathHeader.tsx
File metadata and controls
171 lines (150 loc) · 6.51 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { useState, useEffect } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Button } from "@/components/ui/button";
import { FiGithub, FiMenu, FiX } from 'react-icons/fi';
import { FiHeart } from 'react-icons/fi';
const Header = () => {
const [isScrolled, setIsScrolled] = useState(false);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const location = useLocation();
useEffect(() => {
const handleScroll = () => {
setIsScrolled(window.scrollY > 10);
};
window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, []);
const toggleMobileMenu = () => {
setMobileMenuOpen(!mobileMenuOpen);
};
const isHomePage = location.pathname === '/';
return (
<header className={`fixed top-0 w-full z-50 transition-all duration-300 ${
isScrolled ? "bg-background/95 backdrop-blur-sm shadow-sm" : "bg-transparent"
}`}>
<div className="container mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-16">
<div className="flex items-center">
<Link to="/" className="text-primary font-bold text-xl">
SECURITY COMMITS
</Link>
</div>
<nav className="hidden md:flex items-center space-x-8">
{isHomePage ? (
<a href="#about" className="text-foreground hover:text-primary transition-colors">About</a>
) : (
<Link to="/" className="text-foreground hover:text-primary transition-colors">About</Link>
)}
{isHomePage ? (
<a href="#news" className="text-foreground hover:text-primary transition-colors">News</a>
) : (
<Link to="/" className="text-foreground hover:text-primary transition-colors">News</Link>
)}
<Link to="/convention" className="text-foreground hover:text-primary transition-colors">Convention</Link>
{/* {isHomePage ? (
<a href="#examples" className="text-foreground hover:text-primary transition-colors">Examples</a>
) : (
<Link to="/" className="text-foreground hover:text-primary transition-colors">Examples</Link>
)} */}
{/* <Link to="/reference" className="text-foreground hover:text-primary transition-colors">Reference</Link> */}
{/* <Link to="/blog" className="text-foreground hover:text-primary transition-colors">Blog</Link> */}
<Link to="/docs" className="text-foreground hover:text-primary transition-colors">Docs</Link>
<div className="flex space-x-0">
<Button variant="outline" size="sm" className="flex items-center gap-2 rounded-r-none border-r-0" asChild>
<a href="https://github.com/TQRG/secom" target="_blank" rel="noopener noreferrer">
<FiGithub size={16} />
<span>GitHub</span>
</a>
</Button>
<Button variant="outline" size="sm" className="flex items-center gap-2 bg-rose-100 hover:bg-rose-200 border-rose-300 text-rose-600 hover:text-rose-700 rounded-l-none" asChild>
<a href="https://github.com/sponsors/sofiaoreis" target="_blank" rel="noopener noreferrer">
<FiHeart size={16} />
<span>Sponsor</span>
</a>
</Button>
</div>
</nav>
<div className="md:hidden">
<Button variant="ghost" size="icon" onClick={toggleMobileMenu}>
{mobileMenuOpen ? <FiX size={20} /> : <FiMenu size={20} />}
</Button>
</div>
</div>
</div>
{/* Mobile menu */}
<div className={`md:hidden ${mobileMenuOpen ? 'block' : 'hidden'} bg-background border-b`}>
<div className="px-2 pt-2 pb-3 space-y-1 sm:px-3">
{isHomePage ? (
<a
href="#about"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
About
</a>
) : (
<Link
to="/"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
About
</Link>
)}
{isHomePage ? (
<a
href="#news"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
News
</a>
) : (
<Link
to="/"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
News
</Link>
)}
<Link
to="/convention"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
Convention
</Link>
<Link
to="/docs"
className="block px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
onClick={() => setMobileMenuOpen(false)}
>
Docs
</Link>
<a
href="https://github.com/TQRG/secom"
className="flex items-center gap-2 px-3 py-2 rounded-md text-base font-medium hover:bg-secondary hover:text-primary"
target="_blank"
rel="noopener noreferrer"
onClick={() => setMobileMenuOpen(false)}
>
<FiGithub size={16} />
GitHub
</a>
<a
href="https://github.com/sponsors/sofiaoreis"
className="flex items-center gap-2 px-3 py-2 rounded-md text-base font-medium bg-rose-100 text-rose-600 hover:bg-rose-200 hover:text-rose-700"
target="_blank"
rel="noopener noreferrer"
onClick={() => setMobileMenuOpen(false)}
>
<FiHeart size={16} />
Sponsor
</a>
</div>
</div>
</header>
);
};
export default Header;