-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.tsx
More file actions
157 lines (140 loc) · 3.95 KB
/
Menu.tsx
File metadata and controls
157 lines (140 loc) · 3.95 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
"use client";
import { useWindow } from "@/utils/hooks/window";
import { Contact } from "@/utils/types/contact";
import { Path } from "@/utils/types/paths";
import { motion } from "framer-motion";
import Link from "next/link";
import { twMerge } from "tailwind-merge";
import { ArrowCircleLink } from "../actions/ArrowCircleLink";
type MenuProps = {
routes: Path[];
open: boolean;
currentRoute: string;
cycleMenuCallback: () => void;
animationCompleteCallback: (arg0: boolean) => void;
contactInformation: Contact;
};
export function Menu({
routes,
open,
currentRoute,
animationCompleteCallback,
cycleMenuCallback,
contactInformation: { socials, contact },
}: MenuProps) {
const { height } = useWindow();
function currentRouteHandler(path: string) {
const currentPath = currentRoute.split("/").slice(0, 2).join("/");
return currentPath === path;
}
const animationConfiguration = {
duration: 0.7,
ease: [1, 0.165, 0.165, 1],
};
const animation = {
container: {
closed: {
left: "-120vw",
transition: {
ease: animationConfiguration.ease,
delay: animationConfiguration.duration / 2,
duration: animationConfiguration.duration,
staggerChildren: 0.1,
},
},
opened: {
left: 0,
transition: {
ease: animationConfiguration.ease,
duration: animationConfiguration.duration,
staggerChildren: 0.1,
delayChildren: animationConfiguration.duration / 2,
},
},
},
links: {
closed: {
x: -300,
opacity: 0,
transition: {
ease: animationConfiguration.ease,
},
},
opened: {
x: 0,
opacity: 1,
transition: {
ease: animationConfiguration.ease,
},
},
},
};
return (
<motion.nav
className="px-page fixed z-0 flex h-screen w-full flex-col justify-between gap-12 overflow-hidden bg-red-500 pt-28 pb-16"
onAnimationComplete={() => animationCompleteCallback(true)}
style={{
height: height,
}}
initial={false}
animate={open ? "opened" : "closed"}
variants={animation.container}
>
{/*
Navigation links
*/}
<div className="flex flex-col gap-2" onClick={cycleMenuCallback}>
{routes.map(({ name, path }, index) => (
<Link key={index} href={path} legacyBehavior>
<motion.a
className={twMerge(
"text-light-500 pb-2 text-4xl font-extrabold",
currentRouteHandler(path) && "text-dark-500",
)}
variants={animation.links}
>
{name}_
</motion.a>
</Link>
))}
</div>
{/*
Contact container
*/}
<div className="text-light-500 flex flex-col gap-5">
<ArrowCircleLink
description="5 steps to connect"
path="/connect/form"
onClick={cycleMenuCallback}
variants={animation.links}
/>
<div className="flex flex-col gap-2">
<motion.a
className="text-xl font-bold xl:text-2xl"
href={contact.phone.href}
variants={animation.links}
>
{contact.phone.text}
</motion.a>
<motion.a
className="text-xl font-bold xl:text-2xl"
href={contact.email.href}
variants={animation.links}
>
{contact.email.text}
</motion.a>
</div>
<motion.div
className="text-md text-dark-500 flex flex-row gap-8 font-bold"
variants={animation.links}
>
{socials.map(({ name, url }, index) => (
<a key={index} href={url} target="_blank" rel="noreferrer">
{name}_
</a>
))}
</motion.div>
</div>
</motion.nav>
);
}