feat: add animated text flip and pointer highlight components with home agent section

This commit is contained in:
2025-10-23 04:24:01 +02:00
parent 82e730346e
commit f2cb22ef66
5 changed files with 248 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
"use client";
import React, { useState, useEffect } from "react";
import { motion, AnimatePresence } from "motion/react";
import { cn } from "@/lib/utils";
export const LayoutTextFlip = ({
text = "Build Amazing",
words = ["Landing Pages", "Component Blocks", "Page Sections", "3D Shaders"],
duration = 3000,
}: {
text: string;
words: string[];
duration?: number;
}) => {
const [currentIndex, setCurrentIndex] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % words.length);
}, duration);
return () => clearInterval(interval);
}, []);
return (
<>
<motion.span
layoutId="subtext"
className="text-2xl font-bold tracking-tight drop-shadow-lg md:text-4xl"
>
{text}
</motion.span>
<motion.span
layout
className="relative w-fit overflow-hidden px-8 py-2 font-neuton font-medium italic tracking-tight"
>
<AnimatePresence mode="popLayout">
<motion.span
key={currentIndex}
initial={{ y: -40, filter: "blur(10px)" }}
animate={{
y: 0,
filter: "blur(0px)",
}}
exit={{ y: 50, filter: "blur(10px)", opacity: 0 }}
transition={{
duration: 0.5,
}}
className={cn("inline-block whitespace-nowrap")}
>
{words[currentIndex]}
</motion.span>
</AnimatePresence>
</motion.span>
</>
);
};