"use client"; import { BASE_URL } from "@/constants"; import type { Icon, IconWithName } from "@/types/icons"; import { format, isToday, isYesterday } from "date-fns"; import { motion, useInView } from "framer-motion"; import { ArrowRight, Clock, ExternalLink } from "lucide-react"; import Image from "next/image"; import Link from "next/link"; import { useRef } from "react"; function formatIconDate(timestamp: string): string { const date = new Date(timestamp); if (isToday(date)) { return "Today"; } if (isYesterday(date)) { return "Yesterday"; } return format(date, "MMM d, yyyy"); } export function RecentlyAddedIcons({ icons }: { icons: IconWithName[] }) { return (
{/* Background glow */} ); } // Extracted component for better animation handling function RecentIconCard({ name, data, }: { name: string; data: Icon; }) { const ref = useRef(null); const isInView = useInView(ref, { once: false, amount: 0.2, margin: "100px 0px", }); const variants = { hidden: { opacity: 0, y: 20, scale: 0.95 }, visible: { opacity: 1, y: 0, scale: 1, transition: { duration: 0.4, ease: [0.25, 0.1, 0.25, 1.0] }, }, exit: { opacity: 0, y: -10, scale: 0.98, transition: { duration: 0.3, ease: [0.25, 0.1, 0.25, 1.0] }, }, }; return (
{`${name}
{name.replace(/-/g, " ")}
{formatIconDate(data.update.timestamp)}
); }