UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
fix: update header code
Dillion Verma8fe728be97e8
diff --git a/registry/blocks/example/header-1.tsx b/registry/blocks/example/header-1.tsxindex 88d3e55a..cc9a11d0 100644--- a/registry/blocks/example/header-1.tsx+++ b/registry/blocks/example/header-1.tsx@@ -2,7 +2,6 @@import { cn } from "@/lib/utils";import { AnimatePresence, motion } from "framer-motion";-import { ChevronDown } from "lucide-react";import { useTheme } from "next-themes";import { useEffect, useRef, useState } from "react";@@ -10,7 +9,8 @@ const SCROLL_BOUNDARY = 120;export default function StickyHeader() {const [scrollY, setScrollY] = useState(0);- const headerParentRef = useRef<HTMLDivElement>(null);+ const fixedNavRef = useRef<HTMLElement>(null);+const { theme } = useTheme();const getBreakpoint = (width: number) => {@@ -48,113 +48,104 @@ export default function StickyHeader() {useEffect(() => {const handleScroll = () => {- if (headerParentRef.current) {- setScrollY(headerParentRef.current.scrollTop);- }+ setScrollY(window.scrollY);};- const parentElement = headerParentRef.current;- parentElement?.addEventListener("scroll", handleScroll);+ window.addEventListener("scroll", handleScroll);return () => {- parentElement?.removeEventListener("scroll", handleScroll);+ window.removeEventListener("scroll", handleScroll);};- }, [headerParentRef.current]);+ }, []);return (- <div ref={headerParentRef} className="max-h-[450px] overflow-y-scroll">- <div className="h-[100vh]">- <header className="mx-auto flex max-w-5xl items-center justify-between bg-transparent px-10 py-7 dark:bg-transparent">- <div className="hidden flex-row items-center justify-center gap-2 lg:flex">- <a href="#" className="flex h-8 w-8">- <img src="/icon.png" className="h-full w-full" />- </a>- <a href="#">Magic UI</a>- </div>- {/* <h1 className="hidden lg:flex">Logo</h1> */}- <div className="absolute inset-x-0 top-6 z-50 flex items-center justify-center">- <motion.div- initial={{ x: 0 }}- animate={{- boxShadow: active- ? theme === "dark"- ? "0 0 0 1px rgba(255,255,255,.08), 0 1px 2px -1px rgba(255,255,255,.08), 0 2px 4px rgba(255,255,255,.04)"- : "0 0 0 1px rgba(17,24,28,.08), 0 1px 2px -1px rgba(17,24,28,.08), 0 2px 4px rgba(17,24,28,.04)"- : "none",- }}- transition={{- ease: "linear",- duration: 0.05,- delay: 0.05,- }}- className={cn(- "supports-backdrop-blur:bg-white/90 mx-4 flex w-full items-center justify-center overflow-hidden rounded-full bg-white bg-white/40 px-3 py-2.5 backdrop-blur-md transition-all dark:bg-black/20 lg:w-auto lg:p-1.5 lg:py-2",- )}- >- <ul className="flex h-full w-full flex-row justify-between gap-6 lg:flex-row lg:justify-start lg:gap-1">- <li className="flex items-center justify-center px-2 py-0.5">- <a href="#" className="flex h-8 w-8 lg:hidden">- <img src="/icon.png" className="h-full w-full" />- </a>- <a href="#" className="hidden lg:flex">- Home- </a>- </li>- <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">- <a href="#">Features</a>- </li>- <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">- <a href="#">Pricing</a>- </li>- <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">- <a href="#">Contact</a>- </li>+ <header+ ref={fixedNavRef}+ className="mx-auto flex w-full max-w-5xl items-center justify-between bg-transparent px-10 py-7 dark:bg-transparent"+ >+ <div className="hidden flex-row items-center justify-center gap-2 lg:flex">+ <a href="#" className="flex h-8 w-8">+ <img src="/icon.png" className="h-full w-full" />+ </a>+ <a href="#">Magic UI</a>+ </div>+ {/* <h1 className="hidden lg:flex">Logo</h1> */}+ <div className="fixed inset-x-0 top-6 z-50 flex items-center justify-center">+ <motion.div+ initial={{ x: 0 }}+ animate={{+ boxShadow: active+ ? theme === "dark"+ ? "0 0 0 1px rgba(255,255,255,.08), 0 1px 2px -1px rgba(255,255,255,.08), 0 2px 4px rgba(255,255,255,.04)"+ : "0 0 0 1px rgba(17,24,28,.08), 0 1px 2px -1px rgba(17,24,28,.08), 0 2px 4px rgba(17,24,28,.04)"+ : "none",+ }}+ transition={{+ ease: "linear",+ duration: 0.05,+ delay: 0.05,+ }}+ className={cn(+ "supports-backdrop-blur:bg-white/90 mx-4 flex w-full items-center justify-center overflow-hidden rounded-full bg-white bg-white/40 px-3 py-2.5 backdrop-blur-md transition-all dark:bg-black/20 lg:w-auto lg:p-1.5 lg:py-2",+ )}+ >+ <ul className="flex h-full w-full flex-row justify-between gap-6 lg:flex-row lg:justify-start lg:gap-1">+ <li className="flex items-center justify-center px-2 py-0.5">+ <a href="#" className="flex h-8 w-8 lg:hidden">+ <img src="/icon.png" className="h-full w-full" />+ </a>+ <a href="#" className="hidden lg:flex">+ Home+ </a>+ </li>+ <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">+ <a href="#">Features</a>+ </li>+ <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">+ <a href="#">Pricing</a>+ </li>+ <li className="hidden items-center justify-center px-2 py-0.5 lg:flex">+ <a href="#">Contact</a>+ </li>+ <AnimatePresence>+ <motion.div+ initial={{ width: 0 }}+ animate={{+ width: active ? "auto" : 0,+ }}+ transition={{+ ease: "easeOut",+ duration: 0.25,+ delay: 0.05,+ }}+ ><AnimatePresence>- <motion.div- initial={{ width: 0 }}- animate={{- width: active ? "auto" : 0,- }}- transition={{- ease: "easeOut",- duration: 0.25,- delay: 0.05,- }}- >- <AnimatePresence>- {active && (- <motion.a- initial={{ x: "125%" }}- animate={{ x: "0" }}- exit={{- x: "125%",- transition: { ease: "easeOut", duration: 2.2 },- }}- transition={{ ease: "easeOut", duration: 0.5 }}- className="relative inline-flex w-fit shrink-0 items-center justify-center gap-x-1.5 overflow-hidden whitespace-nowrap rounded-full bg-neutral-900 px-3 py-1.5 text-white outline-none dark:bg-white dark:text-black"- >- Get Started- </motion.a>- )}- </AnimatePresence>- </motion.div>+ {active && (+ <motion.a+ initial={{ x: "125%" }}+ animate={{ x: "0" }}+ exit={{+ x: "125%",+ transition: { ease: "easeOut", duration: 2.2 },+ }}+ transition={{ ease: "easeOut", duration: 0.5 }}+ className="relative inline-flex w-fit shrink-0 items-center justify-center gap-x-1.5 overflow-hidden whitespace-nowrap rounded-full bg-neutral-900 px-3 py-1.5 text-white outline-none dark:bg-white dark:text-black"+ >+ Get Started+ </motion.a>+ )}</AnimatePresence>- </ul>- </motion.div>- </div>-- {/* <div className="flex items-center gap-x-5"> */}- <a className="relative hidden w-fit items-center justify-center gap-x-1.5 overflow-hidden rounded-full bg-neutral-900 px-3 py-1.5 text-white outline-none dark:bg-white dark:text-black lg:inline-flex">- Get Started- </a>- {/* </div> */}- </header>-- <h2 className="mt-12 flex flex-col items-center justify-center text-center">- Scroll down- <ChevronDown className="animate-bounce" />- </h2>+ </motion.div>+ </AnimatePresence>+ </ul>+ </motion.div></div>- </div>++ {/* <div className="flex items-center gap-x-5"> */}+ <a className="relative hidden w-fit items-center justify-center gap-x-1.5 overflow-hidden rounded-full bg-neutral-900 px-3 py-1.5 text-white outline-none dark:bg-white dark:text-black lg:inline-flex">+ Get Started+ </a>+ {/* </div> */}+ </header>);}