import React from "react"; import clsx from "clsx"; import { MotionValue, animate, motion, useMotionValue, useTransform, } from "framer-motion"; import { LandingKeyIcon } from "./icons/landing-key"; import { LandingShareIcon } from "./icons/landing-share"; import { LandingTableIcon } from "./icons/landing-table"; import { LandingWorldIcon } from "./icons/landing-world"; import { LandingSubtractIcon } from "./icons/landing-subtract"; import { LandingClipboardIcon } from "./icons/landing-clipboard"; import { LandingFingerprintIcon } from "./icons/landing-fingerprint"; const highlights = [ { title: "Tables", icon: LandingTableIcon, }, { title: "Forms", icon: LandingClipboardIcon, }, { title: "Networking", icon: LandingShareIcon, }, { title: "State Management", icon: LandingSubtractIcon, }, { title: "Authentication", icon: LandingKeyIcon, }, { title: "Access Control", icon: LandingFingerprintIcon, }, { title: "i18n", icon: LandingWorldIcon, }, { title: "Tables", icon: LandingTableIcon, }, ]; const Item = ({ index, title, Icon, y, }: { index: number; title: string; Icon: typeof LandingKeyIcon; y: MotionValue; }) => { const opacity = useTransform(y, [index - 1, index, index + 1], [0, 1, 0]); return ( {title} ); }; export const LandingSlidingHighlights = () => { const y = useMotionValue(0); const translateY = useTransform( y, [0, highlights.length - 1], ["0%", `${-(highlights.length - 1) * 100}%`], ); React.useEffect(() => { const interval = setInterval(async () => { const next = y.get() + 1; const nextValue = next > highlights.length - 1 ? 0 : next; const isGoingToLast = nextValue === highlights.length - 1; await animate(y, nextValue, { duration: 0.3, type: "spring", bounce: 0.5, stiffness: 100, onComplete: () => { if (isGoingToLast) { y.stop(); y.set(0); } }, }); }, 4200); return () => { clearInterval(interval); }; }, [y]); return (
{highlights.map(({ title, icon: Icon }, index) => ( ))}
); };