2025-04-17 10:46:00 +02:00
|
|
|
"use client";
|
2025-04-17 02:43:14 +02:00
|
|
|
|
2025-04-17 11:05:22 +02:00
|
|
|
import { Marquee } from "@/components/magicui/marquee";
|
2025-04-17 10:46:00 +02:00
|
|
|
import { BASE_URL } from "@/constants";
|
2025-04-17 11:05:22 +02:00
|
|
|
import { cn } from "@/lib/utils";
|
2025-04-17 10:46:00 +02:00
|
|
|
import type { Icon, IconWithName } from "@/types/icons";
|
|
|
|
import { format, isToday, isYesterday } from "date-fns";
|
2025-04-17 11:05:22 +02:00
|
|
|
import { motion } from "framer-motion";
|
2025-04-17 10:46:00 +02:00
|
|
|
import { ArrowRight, Clock, ExternalLink } from "lucide-react";
|
|
|
|
import Image from "next/image";
|
|
|
|
import Link from "next/link";
|
2025-04-17 02:43:14 +02:00
|
|
|
|
|
|
|
function formatIconDate(timestamp: string): string {
|
2025-04-17 10:46:00 +02:00
|
|
|
const date = new Date(timestamp);
|
2025-04-17 02:43:14 +02:00
|
|
|
if (isToday(date)) {
|
2025-04-17 10:46:00 +02:00
|
|
|
return "Today";
|
2025-04-17 02:43:14 +02:00
|
|
|
}
|
|
|
|
if (isYesterday(date)) {
|
2025-04-17 10:46:00 +02:00
|
|
|
return "Yesterday";
|
2025-04-17 02:43:14 +02:00
|
|
|
}
|
2025-04-17 10:46:00 +02:00
|
|
|
return format(date, "MMM d, yyyy");
|
2025-04-17 02:43:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function RecentlyAddedIcons({ icons }: { icons: IconWithName[] }) {
|
2025-04-17 11:05:22 +02:00
|
|
|
// Split icons into two rows for the marquee
|
|
|
|
const firstRow = icons.slice(0, Math.ceil(icons.length / 2));
|
|
|
|
const secondRow = icons.slice(Math.ceil(icons.length / 2));
|
|
|
|
|
2025-04-17 02:43:14 +02:00
|
|
|
return (
|
|
|
|
<div className="relative isolate overflow-hidden py-16 md:py-24">
|
|
|
|
{/* Background glow */}
|
2025-04-17 10:46:00 +02:00
|
|
|
<div
|
|
|
|
className="absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80"
|
|
|
|
aria-hidden="true"
|
2025-04-17 11:05:22 +02:00
|
|
|
></div>
|
2025-04-17 02:43:14 +02:00
|
|
|
|
|
|
|
<div className="mx-auto max-w-7xl px-6 lg:px-8">
|
|
|
|
<motion.div
|
|
|
|
className="mx-auto max-w-2xl text-center mb-12"
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
|
|
viewport={{ once: true }}
|
|
|
|
transition={{ duration: 0.8 }}
|
|
|
|
>
|
|
|
|
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl bg-clip-text text-transparent bg-gradient-to-r from-rose-600 to-rose-500">
|
|
|
|
Recently Added Icons
|
|
|
|
</h2>
|
2025-04-17 10:46:00 +02:00
|
|
|
<p className="mt-3 text-lg text-muted-foreground">
|
|
|
|
Check out the latest additions to our collection.
|
|
|
|
</p>
|
2025-04-17 02:43:14 +02:00
|
|
|
</motion.div>
|
|
|
|
|
2025-04-17 11:05:22 +02:00
|
|
|
<div className="relative flex w-full flex-col items-center justify-center overflow-hidden">
|
|
|
|
<Marquee pauseOnHover className="[--duration:30s] [--gap:2rem]">
|
|
|
|
{firstRow.map(({ name, data }) => (
|
|
|
|
<RecentIconCard key={name} name={name} data={data} />
|
|
|
|
))}
|
|
|
|
</Marquee>
|
|
|
|
<Marquee
|
|
|
|
reverse
|
|
|
|
pauseOnHover
|
|
|
|
className="[--duration:30s] [--gap:2rem] mt-6"
|
|
|
|
>
|
|
|
|
{secondRow.map(({ name, data }) => (
|
|
|
|
<RecentIconCard key={name} name={name} data={data} />
|
|
|
|
))}
|
|
|
|
</Marquee>
|
|
|
|
<div className="pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r from-background" />
|
|
|
|
<div className="pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l from-background" />
|
2025-04-17 05:14:37 +02:00
|
|
|
</div>
|
|
|
|
|
2025-04-17 07:21:19 +02:00
|
|
|
<motion.div
|
2025-04-17 05:14:37 +02:00
|
|
|
className="mt-12 text-center"
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
whileInView={{ opacity: 1 }}
|
2025-04-17 07:21:19 +02:00
|
|
|
viewport={{ once: true }}
|
2025-04-17 05:14:37 +02:00
|
|
|
transition={{ duration: 0.8, delay: 0.4 }}
|
|
|
|
>
|
|
|
|
<Link
|
|
|
|
href="/icons"
|
2025-04-17 05:29:49 +02:00
|
|
|
className="text-rose-500 dark:text-rose-400 hover:text-rose-600 dark:hover:text-rose-300 font-medium inline-flex items-center py-2 px-4 rounded-full border border-rose-200 dark:border-rose-800/30 hover:bg-rose-50 dark:hover:bg-rose-900/20 transition-all duration-200 group hover-lift soft-shadow"
|
2025-04-17 05:14:37 +02:00
|
|
|
>
|
2025-04-17 07:21:19 +02:00
|
|
|
View complete collection
|
2025-04-17 05:29:49 +02:00
|
|
|
<ArrowRight className="w-4 h-4 ml-1.5 transition-transform duration-200 group-hover:translate-x-1" />
|
2025-04-17 05:14:37 +02:00
|
|
|
</Link>
|
|
|
|
</motion.div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-04-17 10:46:00 +02:00
|
|
|
);
|
2025-04-17 05:14:37 +02:00
|
|
|
}
|
|
|
|
|
2025-04-17 11:05:22 +02:00
|
|
|
// Marquee-compatible icon card
|
2025-04-17 07:21:19 +02:00
|
|
|
function RecentIconCard({
|
|
|
|
name,
|
|
|
|
data,
|
|
|
|
}: {
|
2025-04-17 10:46:00 +02:00
|
|
|
name: string;
|
|
|
|
data: Icon;
|
2025-04-17 05:14:37 +02:00
|
|
|
}) {
|
|
|
|
return (
|
2025-04-17 11:05:22 +02:00
|
|
|
<Link
|
|
|
|
prefetch={false}
|
|
|
|
href={`/icons/${name}`}
|
|
|
|
className={cn(
|
|
|
|
"group flex flex-col items-center p-3 sm:p-4 rounded-xl border border-border bg-background/95 dark:bg-background/80",
|
|
|
|
"hover:border-rose-500 hover:bg-rose-500/10 dark:hover:bg-rose-900/30 dark:hover:border-rose-500",
|
|
|
|
"transition-all duration-300 hover:shadow-lg hover:shadow-rose-500/5 relative overflow-hidden hover-lift",
|
|
|
|
"w-36 mx-2",
|
|
|
|
)}
|
2025-04-17 05:29:49 +02:00
|
|
|
>
|
2025-04-17 11:05:22 +02:00
|
|
|
<div className="absolute inset-0 bg-gradient-to-br from-rose-500/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300" />
|
2025-04-17 02:43:14 +02:00
|
|
|
|
2025-04-17 11:05:22 +02:00
|
|
|
<div className="relative h-12 w-12 sm:h-16 sm:w-16 mb-2">
|
|
|
|
<Image
|
|
|
|
src={`${BASE_URL}/${data.base}/${name}.${data.base}`}
|
|
|
|
alt={`${name} icon`}
|
|
|
|
fill
|
|
|
|
className="object-contain p-1 group-hover:scale-110 transition-transform duration-300"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<span className="text-xs sm:text-sm text-center truncate w-full capitalize group-hover:text-rose-600 dark:group-hover:text-rose-400 transition-colors duration-200 font-medium">
|
|
|
|
{name.replace(/-/g, " ")}
|
|
|
|
</span>
|
|
|
|
<div className="flex items-center justify-center mt-2 w-full">
|
|
|
|
<span className="text-[10px] sm:text-xs text-muted-foreground flex items-center whitespace-nowrap group-hover:text-rose-500/70 transition-colors duration-200">
|
|
|
|
<Clock className="w-3 h-3 mr-1.5 shrink-0" />
|
|
|
|
{formatIconDate(data.update.timestamp)}
|
2025-04-17 05:29:49 +02:00
|
|
|
</span>
|
2025-04-17 11:05:22 +02:00
|
|
|
</div>
|
2025-04-17 02:43:14 +02:00
|
|
|
|
2025-04-17 11:05:22 +02:00
|
|
|
<div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
|
|
|
<ExternalLink className="w-3 h-3 text-rose-500" />
|
|
|
|
</div>
|
|
|
|
</Link>
|
2025-04-17 10:46:00 +02:00
|
|
|
);
|
2025-04-17 02:43:14 +02:00
|
|
|
}
|