blob: 7daeeb5099e6c07b5d0c7f5f075fc08885dd092a (
plain)
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
|
import { useState } from 'react'
function NavLink({to, children}) {
return <a href={to} className={`mx-4`}>
{children}
</a>
}
function MobileNav({open, setOpen}) {
return (
<div className={`absolute top-0 left-0 h-screen w-screen bg-white transform ${open ? "-translate-x-0" : "-translate-x-full"} `}>
<div className="flex flex-col ml-4">
<a onClick={() => setTimeout(() => {setOpen(!open)}, 100)}>
About
</a>
<a onClick={() => setTimeout(() => {setOpen(!open)}, 100)}>
Contact
</a>
</div>
</div>
)
}
export default function Navbar() {
const [open, setOpen] = useState(false)
return (
<nav>
<MobileNav open={open} setOpen={setOpen}/>
<div className="w-3/12 flex items-center">Michal</div>
<div className="w-9/12 flex justify-end items-center">
<div className="z-50 flex relative w-8 h-8 flex-col justify-between items-center md:hidden" onClick={() => {
setOpen(!open)
}}>
{/* hamburger button */}
<span className={`h-1 w-full bg-black rounded-lg transform transition duration-300 ease-in-out ${open ? "rotate-45 translate-y-3.5" : ""}`} />
<span className={`h-1 w-full bg-black rounded-lg transition-all duration-300 ease-in-out ${open ? "w-0" : "w-full"}`} />
<span className={`h-1 w-full bg-black rounded-lg transform transition duration-300 ease-in-out ${open ? "-rotate-45 -translate-y-3.5" : ""}`} />
</div>
<div className="hidden md:flex">
<NavLink to="/contact">CONTACT</NavLink>
<NavLink to="/about">ABOUT</NavLink>
</div>
</div>
</nav>
)
}
|