-
Notifications
You must be signed in to change notification settings - Fork 0
/
Header.tsx
73 lines (62 loc) · 1.83 KB
/
Header.tsx
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
"use client";
import { ComponentProps } from "react";
import Nav from "./Nav";
import Group from "./Group";
import Search from "./Search";
import NavLinkItem from "./NavLinkItem";
import useBreakpoint from "@/hooks/useBreakpoint";
import useMobileMenuToggle from "@/hooks/useMobileMenuToggle";
import { cn } from "@/utils/cn";
const Header = () => {
const { matches: isMobileScreen } = useBreakpoint("md");
const { open: mobileMenuOpen, Component: MobileMenuIcon } =
useMobileMenuToggle();
return (
<header
className={cn("fixed left-0 right-0 top-0 flex flex-col bg-white", {
["bottom-0"]: mobileMenuOpen,
})}
>
<Nav className="h-14 items-center border-b">
<a href="/" className="mr-8 text-blue-400">
AEON
</a>
<Group fill>{!isMobileScreen && <Links />}</Group>
<Group className="gap-3">
<Search alwaysOpen={!isMobileScreen} />
{isMobileScreen && <MobileMenuIcon />}
</Group>
</Nav>
{isMobileScreen && (
<div
className={cn("overflow-hidden", {
["mt-6 flex-1"]: mobileMenuOpen,
})}
>
<Nav
className={cn(
"scrollbar-hide no-scrollbar h-0 overflow-auto transition-all duration-500",
{
["h-full"]: mobileMenuOpen,
}
)}
>
{mobileMenuOpen && <Links className="w-full flex-col gap-6" />}
</Nav>
</div>
)}
</header>
);
};
const Links = ({ className }: ComponentProps<"ul">) => {
return (
<ul className={cn("flex gap-3", className)}>
{["Showcase", "Docs", "Blog", "Analytics", "Templates", "Enterprize"].map(
(link) => (
<NavLinkItem key={link}>{link}</NavLinkItem>
)
)}
</ul>
);
};
export default Header;