2025-04-17 15:12:28 +02:00
|
|
|
"use client"
|
|
|
|
|
2025-04-24 20:38:09 +02:00
|
|
|
import { IconsGrid } from "@/components/icon-grid"
|
2025-04-17 15:12:28 +02:00
|
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
|
|
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
|
|
|
|
import { BASE_URL, REPO_PATH } from "@/constants"
|
2025-04-24 20:38:09 +02:00
|
|
|
import type { AuthorData, Icon, IconFile } from "@/types/icons"
|
2025-04-17 15:12:28 +02:00
|
|
|
import confetti from "canvas-confetti"
|
|
|
|
import { motion } from "framer-motion"
|
2025-04-26 00:20:06 +02:00
|
|
|
import { ArrowRight, Check, Copy, Download, FileType, Github, Moon, PaletteIcon, Sun, AlertTriangle } from "lucide-react"
|
2025-04-17 15:12:28 +02:00
|
|
|
import Image from "next/image"
|
|
|
|
import Link from "next/link"
|
|
|
|
import { useCallback, useState } from "react"
|
|
|
|
import { toast } from "sonner"
|
|
|
|
import { Carbon } from "./carbon"
|
|
|
|
import { MagicCard } from "./magicui/magic-card"
|
2025-04-17 17:27:06 +02:00
|
|
|
import { Badge } from "./ui/badge"
|
2025-04-16 16:18:20 +02:00
|
|
|
|
|
|
|
export type IconDetailsProps = {
|
2025-04-17 15:12:28 +02:00
|
|
|
icon: string
|
|
|
|
iconData: Icon
|
|
|
|
authorData: AuthorData
|
2025-04-24 20:38:09 +02:00
|
|
|
allIcons: IconFile
|
2025-04-17 15:12:28 +02:00
|
|
|
}
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-24 20:38:09 +02:00
|
|
|
export function IconDetails({ icon, iconData, authorData, allIcons }: IconDetailsProps) {
|
2025-04-26 00:20:06 +02:00
|
|
|
// Add state for the main preview icon
|
|
|
|
const [isPreviewLoading, setIsPreviewLoading] = useState(true)
|
|
|
|
const [hasPreviewError, setHasPreviewError] = useState(false)
|
|
|
|
|
2025-04-17 15:12:28 +02:00
|
|
|
const authorName = authorData.name || authorData.login || ""
|
|
|
|
const iconColorVariants = iconData.colors
|
|
|
|
const formattedDate = new Date(iconData.update.timestamp).toLocaleDateString("en-GB", {
|
|
|
|
day: "numeric",
|
|
|
|
month: "long",
|
|
|
|
year: "numeric",
|
|
|
|
})
|
2025-04-16 16:18:20 +02:00
|
|
|
const getAvailableFormats = () => {
|
|
|
|
switch (iconData.base) {
|
|
|
|
case "svg":
|
2025-04-17 15:12:28 +02:00
|
|
|
return ["svg", "png", "webp"]
|
2025-04-16 16:18:20 +02:00
|
|
|
case "png":
|
2025-04-17 15:12:28 +02:00
|
|
|
return ["png", "webp"]
|
2025-04-16 16:18:20 +02:00
|
|
|
default:
|
2025-04-17 15:12:28 +02:00
|
|
|
return [iconData.base]
|
2025-04-16 16:18:20 +02:00
|
|
|
}
|
2025-04-17 15:12:28 +02:00
|
|
|
}
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-17 15:12:28 +02:00
|
|
|
const availableFormats = getAvailableFormats()
|
|
|
|
const [copiedVariants, setCopiedVariants] = useState<Record<string, boolean>>({})
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-17 07:21:19 +02:00
|
|
|
// Launch confetti from the pointer position
|
|
|
|
const launchConfetti = useCallback((originX?: number, originY?: number) => {
|
|
|
|
const defaults = {
|
2025-04-17 10:28:22 +02:00
|
|
|
startVelocity: 15,
|
|
|
|
spread: 180,
|
2025-04-17 07:21:19 +02:00
|
|
|
ticks: 50,
|
2025-04-18 18:17:39 +02:00
|
|
|
zIndex: 20,
|
2025-04-17 07:21:19 +02:00
|
|
|
disableForReducedMotion: true,
|
2025-04-17 15:12:28 +02:00
|
|
|
colors: ["#ff0a54", "#ff477e", "#ff7096", "#ff85a1", "#fbb1bd", "#f9bec7"],
|
|
|
|
}
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
// If we have origin coordinates, use them
|
|
|
|
if (originX !== undefined && originY !== undefined) {
|
|
|
|
confetti({
|
|
|
|
...defaults,
|
2025-04-17 10:28:22 +02:00
|
|
|
particleCount: 50,
|
|
|
|
origin: {
|
|
|
|
x: originX / window.innerWidth,
|
|
|
|
y: originY / window.innerHeight,
|
|
|
|
},
|
2025-04-17 15:12:28 +02:00
|
|
|
})
|
2025-04-17 07:21:19 +02:00
|
|
|
} else {
|
|
|
|
// Default to center of screen
|
|
|
|
confetti({
|
|
|
|
...defaults,
|
2025-04-17 10:28:22 +02:00
|
|
|
particleCount: 50,
|
2025-04-17 07:21:19 +02:00
|
|
|
origin: { x: 0.5, y: 0.5 },
|
2025-04-17 15:12:28 +02:00
|
|
|
})
|
2025-04-17 03:02:30 +02:00
|
|
|
}
|
2025-04-17 15:12:28 +02:00
|
|
|
}, [])
|
|
|
|
|
|
|
|
const handleCopy = (url: string, variantKey: string, event?: React.MouseEvent) => {
|
|
|
|
navigator.clipboard.writeText(url)
|
2025-04-16 16:18:20 +02:00
|
|
|
setCopiedVariants((prev) => ({
|
|
|
|
...prev,
|
|
|
|
[variantKey]: true,
|
2025-04-17 15:12:28 +02:00
|
|
|
}))
|
2025-04-16 16:18:20 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
setCopiedVariants((prev) => ({
|
|
|
|
...prev,
|
|
|
|
[variantKey]: false,
|
2025-04-17 15:12:28 +02:00
|
|
|
}))
|
|
|
|
}, 2000)
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-17 07:21:19 +02:00
|
|
|
// Launch confetti from click position or center of screen
|
|
|
|
if (event) {
|
2025-04-17 15:12:28 +02:00
|
|
|
launchConfetti(event.clientX, event.clientY)
|
2025-04-17 07:21:19 +02:00
|
|
|
} else {
|
2025-04-17 15:12:28 +02:00
|
|
|
launchConfetti()
|
2025-04-17 07:21:19 +02:00
|
|
|
}
|
|
|
|
|
2025-04-16 16:18:20 +02:00
|
|
|
toast.success("URL copied", {
|
2025-04-17 15:12:28 +02:00
|
|
|
description: "The icon URL has been copied to your clipboard. Ready to use!",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const handleDownload = async (event: React.MouseEvent, url: string, filename: string) => {
|
|
|
|
event.preventDefault()
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
// Launch confetti from download button position
|
2025-04-17 15:12:28 +02:00
|
|
|
launchConfetti(event.clientX, event.clientY)
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
// Show loading toast
|
2025-04-17 15:12:28 +02:00
|
|
|
toast.loading("Preparing download...")
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
// Fetch the file first as a blob
|
2025-04-17 15:12:28 +02:00
|
|
|
const response = await fetch(url)
|
|
|
|
const blob = await response.blob()
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
// Create a blob URL and use it for download
|
2025-04-17 15:12:28 +02:00
|
|
|
const blobUrl = URL.createObjectURL(blob)
|
|
|
|
const link = document.createElement("a")
|
|
|
|
link.href = blobUrl
|
|
|
|
link.download = filename
|
|
|
|
document.body.appendChild(link)
|
|
|
|
link.click()
|
2025-04-17 07:21:19 +02:00
|
|
|
|
|
|
|
// Clean up
|
2025-04-17 15:12:28 +02:00
|
|
|
document.body.removeChild(link)
|
|
|
|
setTimeout(() => URL.revokeObjectURL(blobUrl), 100)
|
2025-04-17 07:21:19 +02:00
|
|
|
|
2025-04-17 15:12:28 +02:00
|
|
|
toast.dismiss()
|
2025-04-17 07:21:19 +02:00
|
|
|
toast.success("Download started", {
|
2025-04-17 15:12:28 +02:00
|
|
|
description: "Your icon file is being downloaded and will be saved to your device.",
|
|
|
|
})
|
2025-04-17 07:21:19 +02:00
|
|
|
} catch (error) {
|
2025-04-17 15:12:28 +02:00
|
|
|
console.error("Download error:", error)
|
|
|
|
toast.dismiss()
|
2025-04-17 07:21:19 +02:00
|
|
|
toast.error("Download failed", {
|
2025-04-17 15:12:28 +02:00
|
|
|
description: "There was an error downloading the file. Please try again.",
|
|
|
|
})
|
2025-04-17 07:21:19 +02:00
|
|
|
}
|
2025-04-17 15:12:28 +02:00
|
|
|
}
|
|
|
|
|
2025-04-26 00:20:06 +02:00
|
|
|
// Handlers for main preview icon
|
|
|
|
const handlePreviewLoadingComplete = () => {
|
|
|
|
setIsPreviewLoading(false)
|
|
|
|
setHasPreviewError(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
const handlePreviewError = () => {
|
|
|
|
setIsPreviewLoading(false)
|
|
|
|
setHasPreviewError(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
// URLs for main preview icon
|
|
|
|
const previewWebpSrc = `${BASE_URL}/webp/${icon}.webp`
|
|
|
|
const previewOriginalSrc = `${BASE_URL}/${iconData.base}/${icon}.${iconData.base}`
|
|
|
|
const previewOriginalFormat = iconData.base
|
|
|
|
|
2025-04-17 15:12:28 +02:00
|
|
|
const renderVariant = (format: string, iconName: string, theme?: "light" | "dark") => {
|
2025-04-26 00:20:06 +02:00
|
|
|
const [isLoading, setIsLoading] = useState(true)
|
|
|
|
const [hasError, setHasError] = useState(false)
|
|
|
|
|
2025-04-17 15:12:28 +02:00
|
|
|
const variantName = theme && iconColorVariants?.[theme] ? iconColorVariants[theme] : iconName
|
2025-04-26 00:20:06 +02:00
|
|
|
const originalFormat = iconData.base
|
|
|
|
const originalImageUrl = `${BASE_URL}/${originalFormat}/${variantName}.${originalFormat}`
|
|
|
|
const webpImageUrl = `${BASE_URL}/webp/${variantName}.webp`
|
|
|
|
const githubUrl = `${REPO_PATH}/tree/main/${originalFormat}/${iconName}.${originalFormat}`
|
2025-04-17 15:12:28 +02:00
|
|
|
const variantKey = `${format}-${theme || "default"}`
|
|
|
|
const isCopied = copiedVariants[variantKey] || false
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-26 00:20:06 +02:00
|
|
|
const handleLoadingComplete = () => {
|
|
|
|
setIsLoading(false)
|
|
|
|
setHasError(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
const handleError = () => {
|
|
|
|
setIsLoading(false)
|
|
|
|
setHasError(true)
|
|
|
|
}
|
|
|
|
|
2025-04-16 16:18:20 +02:00
|
|
|
return (
|
2025-04-17 10:28:22 +02:00
|
|
|
<TooltipProvider key={variantKey} delayDuration={500}>
|
2025-04-22 20:51:58 +02:00
|
|
|
<MagicCard className="p-0 rounded-md">
|
2025-04-17 15:11:17 +02:00
|
|
|
<div className="flex flex-col items-center p-4 transition-all">
|
2025-04-17 10:28:22 +02:00
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger asChild>
|
2025-04-16 16:18:20 +02:00
|
|
|
<motion.div
|
2025-04-26 00:20:06 +02:00
|
|
|
className="relative w-28 h-28 mb-3 cursor-pointer rounded-xl overflow-hidden group flex items-center justify-center"
|
|
|
|
whileHover={{ scale: hasError ? 1 : 1.05 }}
|
|
|
|
whileTap={{ scale: hasError ? 1 : 0.95 }}
|
|
|
|
onClick={(e) => !hasError && handleCopy(format === 'webp' ? webpImageUrl : originalImageUrl, variantKey, e)}
|
|
|
|
aria-label={hasError ? "Image failed to load" : `Copy ${format.toUpperCase()} URL for ${iconName}${theme ? ` (${theme} theme)` : ""}`}
|
2025-04-16 16:18:20 +02:00
|
|
|
>
|
2025-04-26 00:20:06 +02:00
|
|
|
{isLoading && !hasError && (
|
|
|
|
<div className="absolute inset-0 bg-gray-200 dark:bg-gray-700 animate-pulse rounded-xl z-10" />
|
|
|
|
)}
|
|
|
|
{hasError ? (
|
|
|
|
<AlertTriangle className="h-12 w-12 text-red-500 z-10 cursor-help" />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<div className="absolute inset-0 border-2 border-transparent group-hover:border-primary/20 rounded-xl z-10 transition-colors pointer-events-none" />
|
|
|
|
<motion.div
|
|
|
|
className="absolute inset-0 bg-primary/10 flex items-center justify-center z-20 rounded-xl pointer-events-none"
|
|
|
|
initial={{ opacity: 0 }}
|
|
|
|
animate={{ opacity: isCopied ? 1 : 0 }}
|
|
|
|
transition={{ duration: 0.2 }}
|
|
|
|
>
|
|
|
|
<motion.div
|
|
|
|
initial={{ scale: 0.5, opacity: 0 }}
|
|
|
|
animate={{ scale: isCopied ? 1 : 0.5, opacity: isCopied ? 1 : 0 }}
|
|
|
|
transition={{ type: "spring", stiffness: 300, damping: 20 }}
|
|
|
|
>
|
|
|
|
<Check className="w-8 h-8 text-primary" />
|
|
|
|
</motion.div>
|
|
|
|
</motion.div>
|
2025-04-16 16:18:20 +02:00
|
|
|
|
2025-04-26 00:20:06 +02:00
|
|
|
<picture>
|
|
|
|
<source srcSet={webpImageUrl} type="image/webp" />
|
|
|
|
<source srcSet={originalImageUrl} type={`image/${originalFormat === 'svg' ? 'svg+xml' : originalFormat}`} />
|
|
|
|
<Image
|
|
|
|
src={originalImageUrl}
|
|
|
|
alt={`${iconName} in ${format} format${theme ? ` (${theme} theme)` : ""}`}
|
|
|
|
fill
|
|
|
|
className={`object-contain p-4 transition-opacity duration-500 ${isLoading || hasError ? 'opacity-0' : 'opacity-100'}`}
|
|
|
|
onLoadingComplete={handleLoadingComplete}
|
|
|
|
onError={handleError}
|
|
|
|
/>
|
|
|
|
</picture>
|
|
|
|
</>
|
|
|
|
)}
|
2025-04-17 10:28:22 +02:00
|
|
|
</motion.div>
|
2025-04-16 16:18:20 +02:00
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent>
|
2025-04-26 00:20:06 +02:00
|
|
|
<p>
|
|
|
|
{hasError
|
|
|
|
? "Image failed to load, likely due to size limits. Please raise an issue on GitHub."
|
|
|
|
: isCopied
|
|
|
|
? "URL Copied!"
|
|
|
|
: "Click to copy direct URL to clipboard"}
|
|
|
|
</p>
|
2025-04-16 16:18:20 +02:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
|
2025-04-26 00:20:06 +02:00
|
|
|
<p className="text-sm font-medium capitalize">
|
|
|
|
{format.toUpperCase()} {theme && `(${theme})`}
|
|
|
|
</p>
|
2025-04-17 10:28:22 +02:00
|
|
|
|
|
|
|
<div className="flex gap-2 mt-3 w-full justify-center">
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger asChild>
|
|
|
|
<Button
|
|
|
|
variant="outline"
|
|
|
|
size="icon"
|
|
|
|
className="h-8 w-8 rounded-lg cursor-pointer"
|
2025-04-26 00:20:06 +02:00
|
|
|
onClick={(e) => !hasError && handleDownload(e, format === 'webp' ? webpImageUrl : originalImageUrl, `${variantName}.${format}`)}
|
2025-04-25 17:55:17 +02:00
|
|
|
aria-label={`Download ${iconName} in ${format} format${theme ? ` (${theme} theme)` : ""}`}
|
2025-04-26 00:20:06 +02:00
|
|
|
disabled={hasError}
|
2025-04-17 10:28:22 +02:00
|
|
|
>
|
|
|
|
<Download className="w-4 h-4" />
|
|
|
|
</Button>
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent>
|
2025-04-26 00:20:06 +02:00
|
|
|
<p>{hasError ? "Download unavailable" : "Download icon file"}</p>
|
2025-04-17 10:28:22 +02:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger asChild>
|
|
|
|
<Button
|
|
|
|
variant="outline"
|
|
|
|
size="icon"
|
|
|
|
className="h-8 w-8 rounded-lg cursor-pointer"
|
2025-04-26 00:20:06 +02:00
|
|
|
onClick={(e) => !hasError && handleCopy(format === 'webp' ? webpImageUrl : originalImageUrl, `btn-${variantKey}`, e)}
|
2025-04-25 17:55:17 +02:00
|
|
|
aria-label={`Copy URL for ${iconName} in ${format} format${theme ? ` (${theme} theme)` : ""}`}
|
2025-04-26 00:20:06 +02:00
|
|
|
disabled={hasError}
|
2025-04-17 10:28:22 +02:00
|
|
|
>
|
2025-04-17 15:12:28 +02:00
|
|
|
{copiedVariants[`btn-${variantKey}`] ? <Check className="w-4 h-4 text-green-500" /> : <Copy className="w-4 h-4" />}
|
2025-04-17 10:28:22 +02:00
|
|
|
</Button>
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent>
|
2025-04-26 00:20:06 +02:00
|
|
|
<p>{hasError ? "Copy unavailable" : isCopied ? "URL Copied!" : "Copy direct URL to clipboard"}</p>
|
2025-04-17 10:28:22 +02:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger asChild>
|
2025-04-25 23:13:43 +02:00
|
|
|
<Button variant="outline" size="icon" className="h-8 w-8 rounded-lg" asChild>
|
2025-04-25 17:55:17 +02:00
|
|
|
<Link
|
|
|
|
href={githubUrl}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2025-04-26 00:20:06 +02:00
|
|
|
aria-label={`View ${iconName} ${originalFormat} file on GitHub`}
|
2025-04-25 17:55:17 +02:00
|
|
|
>
|
2025-04-17 10:28:22 +02:00
|
|
|
<Github className="w-4 h-4" />
|
|
|
|
</Link>
|
|
|
|
</Button>
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent>
|
|
|
|
<p>View on GitHub</p>
|
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
2025-04-17 10:28:22 +02:00
|
|
|
</MagicCard>
|
2025-04-16 16:18:20 +02:00
|
|
|
</TooltipProvider>
|
2025-04-17 15:12:28 +02:00
|
|
|
)
|
|
|
|
}
|
2025-04-16 16:18:20 +02:00
|
|
|
|
|
|
|
return (
|
2025-04-24 20:38:09 +02:00
|
|
|
<main className="container mx-auto pt-12 pb-14 px-4 sm:px-6 lg:px-8">
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
|
|
|
{/* Left Column: Icon Info and Author */}
|
|
|
|
<div className="lg:col-span-1">
|
2025-04-18 18:17:39 +02:00
|
|
|
<Card className="h-full bg-background/50 border shadow-lg">
|
2025-04-16 16:18:20 +02:00
|
|
|
<CardHeader className="pb-4">
|
|
|
|
<div className="flex flex-col items-center">
|
2025-04-26 00:20:06 +02:00
|
|
|
{/* Apply loading/error handling to the main preview icon */}
|
|
|
|
<div className="relative w-32 h-32 rounded-xl overflow-hidden border flex items-center justify-center p-3 mb-4">
|
|
|
|
{isPreviewLoading && !hasPreviewError && (
|
|
|
|
<div className="absolute inset-0 bg-gray-200 dark:bg-gray-700 animate-pulse rounded-xl" />
|
|
|
|
)}
|
|
|
|
{hasPreviewError ? (
|
|
|
|
<TooltipProvider delayDuration={300}>
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger aria-label="Preview image loading error">
|
|
|
|
<AlertTriangle className="h-16 w-16 text-red-500 cursor-help" />
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent side="bottom">
|
|
|
|
<p>Preview failed to load, likely due to size limits. Please raise an issue.</p>
|
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
</TooltipProvider>
|
|
|
|
) : (
|
|
|
|
<picture>
|
|
|
|
<source srcSet={previewWebpSrc} type="image/webp" />
|
|
|
|
<source srcSet={previewOriginalSrc} type={`image/${previewOriginalFormat === 'svg' ? 'svg+xml' : previewOriginalFormat}`} />
|
|
|
|
<Image
|
|
|
|
src={previewOriginalSrc}
|
|
|
|
alt={`High quality ${icon.replace(/-/g, " ")} icon preview`}
|
|
|
|
fill // Use fill instead of width/height for parent relative sizing
|
|
|
|
className={`object-contain transition-opacity duration-500 ${isPreviewLoading || hasPreviewError ? 'opacity-0' : 'opacity-100'}`}
|
|
|
|
onLoadingComplete={handlePreviewLoadingComplete}
|
|
|
|
onError={handlePreviewError}
|
|
|
|
priority // Prioritize loading the main icon
|
|
|
|
/>
|
|
|
|
</picture>
|
|
|
|
)}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
2025-04-24 20:38:09 +02:00
|
|
|
<CardTitle className="text-2xl font-bold capitalize text-center mb-2">
|
|
|
|
<h1>{icon.replace(/-/g, " ")}</h1>
|
|
|
|
</CardTitle>
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="space-y-4">
|
|
|
|
<div>
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="space-y-2">
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<p className="text-sm">
|
2025-04-24 20:38:09 +02:00
|
|
|
<span className="font-medium">Updated on:</span> <time dateTime={iconData.update.timestamp}>{formattedDate}</time>
|
2025-04-16 16:18:20 +02:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<p className="text-sm font-medium">By:</p>
|
|
|
|
<Avatar className="h-5 w-5 border">
|
2025-04-24 20:38:09 +02:00
|
|
|
<AvatarImage src={authorData.avatar_url} alt={`${authorName}'s avatar`} />
|
2025-04-17 15:12:28 +02:00
|
|
|
<AvatarFallback>{authorName ? authorName.slice(0, 2).toUpperCase() : "??"}</AvatarFallback>
|
2025-04-16 16:18:20 +02:00
|
|
|
</Avatar>
|
2025-04-17 02:43:14 +02:00
|
|
|
{authorData.html_url ? (
|
|
|
|
<Link
|
|
|
|
href={authorData.html_url}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
className="text-primary hover:underline text-sm"
|
|
|
|
>
|
|
|
|
{authorName}
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
<span className="text-sm">{authorName}</span>
|
|
|
|
)}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{iconData.categories && iconData.categories.length > 0 && (
|
2025-04-17 17:27:06 +02:00
|
|
|
<div>
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Categories</h3>
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="flex flex-wrap gap-2">
|
|
|
|
{iconData.categories.map((category) => (
|
2025-04-17 17:27:06 +02:00
|
|
|
<Link key={category} href={`/icons?category=${encodeURIComponent(category)}`} className="cursor-pointer">
|
2025-04-17 18:03:26 +02:00
|
|
|
<Badge
|
|
|
|
variant="outline"
|
|
|
|
className="inline-flex items-center border border-primary/20 hover:border-primary px-2.5 py-0.5 text-sm"
|
|
|
|
>
|
2025-04-17 17:27:06 +02:00
|
|
|
{category
|
|
|
|
.split("-")
|
|
|
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
|
|
.join(" ")}
|
|
|
|
</Badge>
|
2025-04-17 07:21:19 +02:00
|
|
|
</Link>
|
2025-04-16 16:18:20 +02:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{iconData.aliases && iconData.aliases.length > 0 && (
|
2025-04-17 17:27:06 +02:00
|
|
|
<div>
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Aliases</h3>
|
2025-04-17 07:21:19 +02:00
|
|
|
<div className="flex flex-wrap gap-2">
|
2025-04-16 16:18:20 +02:00
|
|
|
{iconData.aliases.map((alias) => (
|
2025-04-17 17:27:06 +02:00
|
|
|
<Badge
|
|
|
|
variant="outline"
|
2025-04-17 07:21:19 +02:00
|
|
|
key={alias}
|
2025-04-17 17:27:06 +02:00
|
|
|
className="inline-flex items-center px-2.5 py-1 text-xs"
|
2025-04-17 07:21:19 +02:00
|
|
|
title={`This icon can also be found by searching for "${alias}"`}
|
|
|
|
>
|
2025-04-16 16:18:20 +02:00
|
|
|
{alias}
|
2025-04-17 17:27:06 +02:00
|
|
|
</Badge>
|
2025-04-16 16:18:20 +02:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
2025-04-17 17:27:06 +02:00
|
|
|
|
|
|
|
<div>
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">About this icon</h3>
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="text-xs text-muted-foreground space-y-2">
|
|
|
|
<p>
|
2025-04-25 23:13:43 +02:00
|
|
|
Available in{" "}
|
|
|
|
{availableFormats.length > 1
|
2025-04-25 17:55:17 +02:00
|
|
|
? `${availableFormats.length} formats (${availableFormats.map((f) => f.toUpperCase()).join(", ")}) `
|
|
|
|
: `${availableFormats[0].toUpperCase()} format `}
|
2025-04-17 17:27:06 +02:00
|
|
|
with a base format of {iconData.base.toUpperCase()}.
|
|
|
|
{iconData.colors && " Includes both light and dark theme variants for better integration with different UI designs."}
|
|
|
|
</p>
|
|
|
|
<p>
|
2025-04-25 23:13:43 +02:00
|
|
|
Perfect for adding to dashboards, app directories, documentation, or anywhere you need the {icon.replace(/-/g, " ")}{" "}
|
|
|
|
logo.
|
2025-04-17 17:27:06 +02:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Middle Column: Icon variants */}
|
|
|
|
<div className="lg:col-span-2">
|
2025-04-18 18:17:39 +02:00
|
|
|
<Card className="h-full bg-background/50 shadow-lg">
|
2025-04-16 16:18:20 +02:00
|
|
|
<CardHeader>
|
2025-04-24 20:38:09 +02:00
|
|
|
<CardTitle>
|
|
|
|
<h2>Icon variants</h2>
|
|
|
|
</CardTitle>
|
2025-04-17 15:12:28 +02:00
|
|
|
<CardDescription>Click on any icon to copy its URL to your clipboard</CardDescription>
|
2025-04-16 16:18:20 +02:00
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
{!iconData.colors ? (
|
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
|
2025-04-17 15:12:28 +02:00
|
|
|
{availableFormats.map((format) => renderVariant(format, icon))}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="space-y-10">
|
|
|
|
<div>
|
2025-04-17 10:28:22 +02:00
|
|
|
<h3 className="text-lg font-semibold flex items-center gap-2">
|
2025-04-17 02:43:14 +02:00
|
|
|
<Sun className="w-4 h-4 text-amber-500" />
|
2025-04-16 16:18:20 +02:00
|
|
|
Light theme
|
|
|
|
</h3>
|
2025-04-17 10:28:22 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-3 rounded-lg ">
|
2025-04-17 15:12:28 +02:00
|
|
|
{availableFormats.map((format) => renderVariant(format, icon, "light"))}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
2025-04-17 10:28:22 +02:00
|
|
|
<h3 className="text-lg font-semibold flex items-center gap-2">
|
2025-04-17 02:43:14 +02:00
|
|
|
<Moon className="w-4 h-4 text-indigo-500" />
|
2025-04-16 16:18:20 +02:00
|
|
|
Dark theme
|
|
|
|
</h3>
|
2025-04-17 10:28:22 +02:00
|
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-3 rounded-lg ">
|
2025-04-17 15:12:28 +02:00
|
|
|
{availableFormats.map((format) => renderVariant(format, icon, "dark"))}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Right Column: Technical details */}
|
|
|
|
<div className="lg:col-span-1">
|
2025-04-18 18:17:39 +02:00
|
|
|
<Card className="h-full bg-background/50 border shadow-lg">
|
2025-04-16 16:18:20 +02:00
|
|
|
<CardHeader>
|
|
|
|
<CardTitle>Technical details</CardTitle>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<div className="space-y-6">
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="">
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Base format</h3>
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="flex items-center gap-2">
|
2025-04-17 02:43:14 +02:00
|
|
|
<FileType className="w-4 h-4 text-blue-500" />
|
2025-04-17 15:12:28 +02:00
|
|
|
<div className="px-3 py-1.5 border border-border rounded-lg text-sm font-medium">{iconData.base.toUpperCase()}</div>
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="">
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Available formats</h3>
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="flex flex-wrap gap-2">
|
|
|
|
{availableFormats.map((format) => (
|
2025-04-17 15:12:28 +02:00
|
|
|
<div key={format} className="px-3 py-1.5 border border-border rounded-lg text-xs font-medium">
|
2025-04-16 16:18:20 +02:00
|
|
|
{format.toUpperCase()}
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{iconData.colors && (
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="">
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Color variants</h3>
|
2025-04-16 16:18:20 +02:00
|
|
|
<div className="space-y-2">
|
2025-04-17 15:12:28 +02:00
|
|
|
{Object.entries(iconData.colors).map(([theme, variant]) => (
|
|
|
|
<div key={theme} className="flex items-center gap-2">
|
|
|
|
<PaletteIcon className="w-4 h-4 text-purple-500" />
|
|
|
|
<span className="capitalize font-medium text-sm">{theme}:</span>
|
|
|
|
<code className=" border border-border px-2 py-0.5 rounded-lg text-xs">{variant}</code>
|
|
|
|
</div>
|
|
|
|
))}
|
2025-04-16 16:18:20 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2025-04-17 17:27:06 +02:00
|
|
|
<div className="">
|
2025-04-25 17:55:17 +02:00
|
|
|
<h3 className="text-sm font-semibold text-muted-foreground mb-2">Source</h3>
|
2025-04-16 16:18:20 +02:00
|
|
|
<Button variant="outline" className="w-full" asChild>
|
2025-04-17 15:12:28 +02:00
|
|
|
<Link href={`${REPO_PATH}/blob/main/meta/${icon}.json`} target="_blank" rel="noopener noreferrer">
|
2025-04-16 16:18:20 +02:00
|
|
|
<Github className="w-4 h-4 mr-2" />
|
|
|
|
View on GitHub
|
|
|
|
</Link>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</CardContent>
|
|
|
|
<Carbon />
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-04-25 23:13:43 +02:00
|
|
|
{iconData.categories &&
|
|
|
|
iconData.categories.length > 0 &&
|
|
|
|
(() => {
|
|
|
|
const MAX_RELATED_ICONS = 16
|
|
|
|
const currentCategories = iconData.categories || []
|
|
|
|
|
|
|
|
const relatedIconsWithScore = Object.entries(allIcons)
|
|
|
|
.map(([name, data]) => {
|
|
|
|
if (name === icon) return null // Exclude the current icon
|
|
|
|
|
|
|
|
const otherCategories = data.categories || []
|
|
|
|
const commonCategories = currentCategories.filter((cat) => otherCategories.includes(cat))
|
|
|
|
const score = commonCategories.length
|
|
|
|
|
|
|
|
return score > 0 ? { name, data, score } : null
|
|
|
|
})
|
|
|
|
.filter((item): item is { name: string; data: Icon; score: number } => item !== null) // Type guard
|
|
|
|
.sort((a, b) => b.score - a.score) // Sort by score DESC
|
|
|
|
|
|
|
|
const topRelatedIcons = relatedIconsWithScore.slice(0, MAX_RELATED_ICONS)
|
|
|
|
|
|
|
|
const viewMoreUrl = `/icons?${currentCategories.map((cat) => `category=${encodeURIComponent(cat)}`).join("&")}`
|
|
|
|
|
|
|
|
if (topRelatedIcons.length === 0) return null
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section className="container mx-auto mt-12" aria-labelledby="related-icons-title">
|
|
|
|
<Card className="bg-background/50 border shadow-lg">
|
|
|
|
<CardHeader>
|
|
|
|
<CardTitle>
|
|
|
|
<h2 id="related-icons-title">Related Icons</h2>
|
|
|
|
</CardTitle>
|
|
|
|
<CardDescription>
|
|
|
|
Other icons from {currentCategories.map((cat) => cat.replace(/-/g, " ")).join(", ")} categories
|
|
|
|
</CardDescription>
|
|
|
|
</CardHeader>
|
|
|
|
<CardContent>
|
|
|
|
<IconsGrid filteredIcons={topRelatedIcons} matchedAliases={{}} />
|
|
|
|
{relatedIconsWithScore.length > MAX_RELATED_ICONS && (
|
|
|
|
<div className="mt-6 text-center">
|
|
|
|
<Button
|
|
|
|
asChild
|
|
|
|
variant="link"
|
|
|
|
className="text-muted-foreground hover:text-primary transition-colors duration-200 hover:no-underline"
|
|
|
|
>
|
|
|
|
<Link href={viewMoreUrl} className="no-underline">
|
|
|
|
View all related icons
|
|
|
|
<ArrowRight className="ml-2 h-4 w-4" />
|
|
|
|
</Link>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
})()}
|
2025-04-25 23:17:31 +02:00
|
|
|
</main>
|
2025-04-17 15:12:28 +02:00
|
|
|
)
|
2025-04-16 16:18:20 +02:00
|
|
|
}
|