import { BadgeCheck, ExternalLink } from 'lucide-react'; import { cn } from '@/lib/utils'; import { SKATESPOTS_SITE, type ProfileBadge } from '@/lib/badges'; import { sanitizeUrl } from '@/lib/sanitizeUrl'; /** The app logo is already served with the site. */ const SKATESPOTS_LOGO = '/images/logo-icon.png'; const isApp = (b: ProfileBadge) => b.label === 'SkateSpots' && b.url === SKATESPOTS_SITE; /** * ProfileBadges — the row of badges on a profile (own or someone else's). * Clicking a badge with a link opens it in a new tab. */ export function ProfileBadges({ badges, size = 'md', className, }: { badges: ProfileBadge[]; size?: 'sm' | 'md'; className?: string; }) { if (badges.length === 0) return null; return (
{badges.map((b, i) => { const app = isApp(b); const safeUrl = b.url ? sanitizeUrl(b.url) : null; const cls = cn( 'inline-flex items-center gap-1.5 rounded-full border font-bold transition-colors', size === 'sm' ? 'px-2 py-0.5 text-[11px]' : 'px-3 py-1.5 text-sm', app ? 'border-[#ccff00]/40 bg-[#ccff00]/10 text-[#ccff00] hover:bg-[#ccff00]/20' : 'border-pink-500/25 bg-pink-500/10 text-gray-100 hover:bg-pink-500/20', ); const inner = ( <> {app ? ( ) : ( )} {b.label} {safeUrl && !app && } ); return safeUrl ? ( {inner} ) : ( {inner} ); })}
); }