| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | "use client" | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | import { Marquee } from "@/components/magicui/marquee" | 
					
						
							|  |  |  | import { BASE_URL } from "@/constants" | 
					
						
							|  |  |  | import { cn } from "@/lib/utils" | 
					
						
							|  |  |  | import type { Icon, IconWithName } from "@/types/icons" | 
					
						
							|  |  |  | import { format, isToday, isYesterday } from "date-fns" | 
					
						
							|  |  |  | 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 15:12:28 +02:00
										 |  |  | 	const date = new Date(timestamp) | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 	if (isToday(date)) { | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | 		return "Today" | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (isYesterday(date)) { | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | 		return "Yesterday" | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +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
 | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | 	const firstRow = icons.slice(0, Math.ceil(icons.length / 2)) | 
					
						
							|  |  |  | 	const secondRow = icons.slice(Math.ceil(icons.length / 2)) | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 	return ( | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 		<div className="relative isolate overflow-hidden my-8"> | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 			{/* Background glow */} | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +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 02:43:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-17 11:38:32 +02:00
										 |  |  | 			<div className="mx-auto px-6 lg:px-8"> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 				<div className="mx-auto max-w-2xl text-center my-4"> | 
					
						
							|  |  |  | 					<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  motion-safe:motion-preset-fade-lg motion-duration-2000"> | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 						Recently Added Icons | 
					
						
							|  |  |  | 					</h2> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:38:32 +02:00
										 |  |  | 				</div> | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 				<div className="relative flex w-full flex-col items-center justify-center overflow-hidden"> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | 					<Marquee pauseOnHover className="[--duration:60s] [--gap:1em] motion-safe:motion-preset-slide-left-sm motion-duration-1000"> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 						{firstRow.map(({ name, data }) => ( | 
					
						
							|  |  |  | 							<RecentIconCard key={name} name={name} data={data} /> | 
					
						
							|  |  |  | 						))} | 
					
						
							|  |  |  | 					</Marquee> | 
					
						
							|  |  |  | 					<Marquee | 
					
						
							|  |  |  | 						reverse | 
					
						
							|  |  |  | 						pauseOnHover | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 						className="[--duration:60s] [--gap:1rem] motion-safe:motion-preset-slide-right-sm motion-duration-1000" | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 					> | 
					
						
							|  |  |  | 						{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 11:38:32 +02:00
										 |  |  | 				<div className="mt-12 text-center"> | 
					
						
							| 
									
										
										
										
											2025-04-17 05:14:37 +02:00
										 |  |  | 					<Link | 
					
						
							|  |  |  | 						href="/icons" | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 						className="font-medium inline-flex items-center py-2 px-4 rounded-full border  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> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:38:32 +02:00
										 |  |  | 				</div> | 
					
						
							| 
									
										
										
										
											2025-04-17 05:14:37 +02:00
										 |  |  | 			</div> | 
					
						
							|  |  |  | 		</div> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +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 15:12:28 +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( | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 				"flex flex-col items-center p-3 sm:p-4 rounded-xl border border-border", | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 				"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:38:32 +02:00
										 |  |  | 			<div className="absolute inset-0 bg-gradient-to-br from-rose-500/5 to-transparent opacity-0 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 | 
					
						
							| 
									
										
										
										
											2025-04-17 11:38:32 +02:00
										 |  |  | 					className="object-contain p-1 hover:scale-110 transition-transform duration-300" | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 				/> | 
					
						
							|  |  |  | 			</div> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 			<span className="text-xs sm:text-sm text-center truncate w-full capitalize  dark:hover:text-rose-400 transition-colors duration-200 font-medium"> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 				{name.replace(/-/g, " ")} | 
					
						
							|  |  |  | 			</span> | 
					
						
							|  |  |  | 			<div className="flex items-center justify-center mt-2 w-full"> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 				<span className="text-[10px] sm:text-xs text-muted-foreground flex items-center whitespace-nowrap hover:/70 transition-colors duration-200"> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 					<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:38:32 +02:00
										 |  |  | 			<div className="absolute top-2 right-2 opacity-0 hover:opacity-100 transition-opacity duration-200"> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:11:17 +02:00
										 |  |  | 				<ExternalLink className="w-3 h-3 " /> | 
					
						
							| 
									
										
										
										
											2025-04-17 11:05:22 +02:00
										 |  |  | 			</div> | 
					
						
							|  |  |  | 		</Link> | 
					
						
							| 
									
										
										
										
											2025-04-17 15:12:28 +02:00
										 |  |  | 	) | 
					
						
							| 
									
										
										
										
											2025-04-17 02:43:14 +02:00
										 |  |  | } |