|
2 | 2 |
|
3 | 3 | import React from "react";
|
4 | 4 | import Link from "next/link";
|
5 |
| -import clsx from "clsx"; |
6 | 5 | import { usePathname } from "next/navigation";
|
| 6 | +import { motion } from "framer-motion"; |
7 | 7 |
|
8 |
| -import { MotionDiv, MotionLi } from "@/lib/framer/client"; |
| 8 | +import { MotionDiv, MotionLi, MotionUl } from "@/lib/framer/client"; |
9 | 9 |
|
10 | 10 | import MobileMenu from "./MobileMenu.component";
|
11 | 11 |
|
12 |
| -export default function Header() { |
| 12 | +const Header = () => { |
13 | 13 | const pathname = usePathname();
|
14 | 14 |
|
15 | 15 | const links = [
|
16 |
| - { |
17 |
| - title: "Home", |
18 |
| - name: "Hjem", |
19 |
| - hash: "#hjem", |
20 |
| - href: "/", |
21 |
| - }, |
| 16 | + { title: "Home", name: "Hjem", hash: "#hjem", href: "/" }, |
22 | 17 | {
|
23 | 18 | title: "Prosjekter",
|
24 | 19 | name: "Prosjekter",
|
25 | 20 | hash: "#prosjekter",
|
26 | 21 | href: "/prosjekter",
|
27 | 22 | },
|
28 |
| - { |
29 |
| - title: "CV", |
30 |
| - name: "CV", |
31 |
| - hash: "#cv", |
32 |
| - href: "/cv", |
33 |
| - }, |
| 23 | + { title: "CV", name: "CV", hash: "#cv", href: "/cv" }, |
34 | 24 | {
|
35 | 25 | title: "Github",
|
36 | 26 | name: "Github",
|
37 | 27 | hash: "#github",
|
38 | 28 | href: "https://github.com/w3bdesign",
|
39 | 29 | },
|
40 |
| - { |
41 |
| - title: "Kontakt", |
42 |
| - name: "Kontakt", |
43 |
| - hash: "#kontakt", |
44 |
| - href: "/kontakt", |
45 |
| - }, |
| 30 | + { title: "Kontakt", name: "Kontakt", hash: "#kontakt", href: "/kontakt" }, |
46 | 31 | ];
|
47 | 32 |
|
48 | 33 | return (
|
49 | 34 | <header className="z-[999] relative">
|
50 | 35 | <MotionDiv
|
51 | 36 | className="bg-slate-800 bg-opacity-80 fixed top-0 left-1/2 h-[4.5rem] w-full shadow rounded-none shadow-lg shadow-black/[0.03] backdrop-blur-[0.5rem] sm:top-6 sm:h-[3.25rem] sm:w-[36rem] sm:rounded-full dark:bg-gray-900 dark:border-black/40 dark:bg-opacity-75"
|
52 |
| - initial={{ y: -50, x: "-50%", opacity: 0 }} |
53 |
| - animate={{ y: 0, x: "-50%", opacity: 1, transition: { duration: 0.6 } }} |
54 |
| - ></MotionDiv> |
55 |
| - |
| 37 | + initial={{ y: -100, x: "-50%", opacity: 0 }} |
| 38 | + animate={{ |
| 39 | + y: 0, |
| 40 | + x: "-50%", |
| 41 | + opacity: 1, |
| 42 | + transition: { |
| 43 | + y: { duration: 0.6, ease: "easeOut" }, |
| 44 | + opacity: { duration: 0.6, ease: "easeOut" }, |
| 45 | + }, |
| 46 | + }} |
| 47 | + /> |
56 | 48 | <nav className="flex fixed top-[0.65rem] left-1/2 h-12 -translate-x-1/2 py-2 sm:top-[1.7rem] sm:h-[initial] sm:py-0 w-full max-w-[370px] justify-end md:justify-between items-center">
|
57 |
| - <ul className="hidden md:flex md:w-[22rem] flex-wrap items-center justify-center gap-y-1 text-[0.9rem] font-medium text-slate-200 sm:w-[initial] sm:flex-nowrap sm:gap-5"> |
| 49 | + <MotionUl |
| 50 | + className="hidden md:flex md:w-[22rem] flex-wrap items-center justify-center gap-y-1 text-[0.9rem] font-medium text-slate-200 sm:w-[initial] sm:flex-nowrap sm:gap-5" |
| 51 | + variants={{ |
| 52 | + hidden: { opacity: 0 }, |
| 53 | + visible: { |
| 54 | + opacity: 1, |
| 55 | + transition: { |
| 56 | + staggerChildren: 0.1, |
| 57 | + delayChildren: 0.3, |
| 58 | + }, |
| 59 | + }, |
| 60 | + }} |
| 61 | + initial="hidden" |
| 62 | + animate="visible" |
| 63 | + > |
58 | 64 | {links.map((link) => (
|
59 | 65 | <MotionLi
|
60 | 66 | className="h-3/4 flex items-center justify-center relative"
|
61 | 67 | key={link.hash}
|
62 |
| - initial={{ y: -50, opacity: 0 }} |
63 |
| - animate={{ y: 0, opacity: 1, transition: { duration: 0.6 } }} |
| 68 | + variants={{ |
| 69 | + hidden: { y: -20, opacity: 0 }, |
| 70 | + visible: { y: 0, opacity: 1 }, |
| 71 | + }} |
| 72 | + transition={{ duration: 0.3 }} |
64 | 73 | >
|
65 |
| - <Link |
66 |
| - prefetch={true} |
67 |
| - className={`flex w-full items-center justify-center px-2 py-2 hover:text-white transition font-semibold text-lg ${ |
68 |
| - pathname === link.href ? "text-green-400" : "" |
69 |
| - }`} |
70 |
| - href={link.href} |
71 |
| - > |
72 |
| - <div |
73 |
| - className={clsx("glitch", { |
74 |
| - "underline underline-offset-4 decoration-2": |
75 |
| - pathname === link.href, |
76 |
| - })} |
77 |
| - data-text={link.name} |
| 74 | + <MotionDiv className="relative" whileHover="hover"> |
| 75 | + <Link |
| 76 | + prefetch={true} |
| 77 | + className={`flex w-full items-center justify-center px-2 py-2 hover:text-white transition font-semibold text-lg ${ |
| 78 | + pathname === link.href ? "text-green-400" : "" |
| 79 | + }`} |
| 80 | + href={link.href} |
78 | 81 | >
|
79 |
| - {link.name} |
80 |
| - </div> |
81 |
| - </Link> |
| 82 | + <div className="glitch relative" data-text={link.name}> |
| 83 | + {link.name} |
| 84 | + <motion.span |
| 85 | + className={`absolute bottom-0 left-0 h-0.5 bg-current ${ |
| 86 | + pathname === link.href ? "bg-green-400" : "bg-white" |
| 87 | + }`} |
| 88 | + initial={{ |
| 89 | + width: pathname === link.href ? "100%" : "0%", |
| 90 | + }} |
| 91 | + variants={{ |
| 92 | + hover: { width: "100%" }, |
| 93 | + }} |
| 94 | + transition={{ duration: 0.3 }} |
| 95 | + /> |
| 96 | + </div> |
| 97 | + </Link> |
| 98 | + </MotionDiv> |
82 | 99 | </MotionLi>
|
83 | 100 | ))}
|
84 |
| - </ul> |
| 101 | + </MotionUl> |
85 | 102 | <div id="hamburger-div" data-cy="hamburger-div" className="md:hidden">
|
86 | 103 | <MobileMenu links={links} />
|
87 | 104 | </div>
|
88 | 105 | </nav>
|
89 | 106 | </header>
|
90 | 107 | );
|
91 |
| -} |
| 108 | +}; |
| 109 | + |
| 110 | +export default Header; |
0 commit comments