mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 11:03:50 +00:00
Animate header
This commit is contained in:
@@ -3,23 +3,46 @@
|
|||||||
import ThemeToggle from "@/components/theme-toggle"
|
import ThemeToggle from "@/components/theme-toggle"
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
|
|
||||||
const Header = () => {
|
let tabs = [
|
||||||
|
{ id: "/", label: "Home" },
|
||||||
|
{ id: "projects", label: "Projects" },
|
||||||
|
{ id: "resume", label: "Resume" },
|
||||||
|
{ id: "blog", label: "Blog" },
|
||||||
|
{ id: "shop", label: "Shop" },
|
||||||
|
];
|
||||||
|
|
||||||
|
function Header() {
|
||||||
|
let [activeTab, setActiveTab] = useState(tabs[0].id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center space-x-7">
|
<div className="flex space-x-1">
|
||||||
<Link href="/">Home</Link>
|
{tabs.map((tab) => (
|
||||||
<Link href="/projects">Projects</Link>
|
<Link key={tab.id} href={`/${tab.id}`} passHref>
|
||||||
<Link href="/resume">Resume</Link>
|
<motion.a
|
||||||
<Link href="/blog">Blog</Link>
|
onClick={() => setActiveTab(tab.id)}
|
||||||
<Link href="/shop">Shop</Link>
|
className={`${
|
||||||
<div className="flex items-center">
|
activeTab === tab.id ? "" : "hover:text-white/60"
|
||||||
<ThemeToggle />
|
} relative rounded-full px-3 py-1.5 text-sm font-medium text-white outline-sky-400 transition focus-visible:outline-2`}
|
||||||
</div>
|
style={{
|
||||||
|
WebkitTapHighlightColor: "transparent",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{activeTab === tab.id && (
|
||||||
|
<motion.span
|
||||||
|
layoutId="bubble"
|
||||||
|
className="absolute inset-0 z-10 bg-white mix-blend-difference"
|
||||||
|
style={{ borderRadius: 9999 }}
|
||||||
|
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{tab.label}
|
||||||
|
</motion.a>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Header;
|
export default Header;
|
||||||
|
|||||||
Reference in New Issue
Block a user