import { type ReactNode } from 'react'; import { QRCodeSVG } from 'qrcode.react'; const AV_COLORS = ['#d50000', '#20b2aa', '#e11d48', '#0d9488', '#f59e0b', '#0ea5e9', '#dc2626', '#7c3aed', '#16a34a', '#ea580c', '#0891b2', '#db2777']; export function initials(name: string): string { return name .split(' ') .map((w) => w[0]) .slice(0, 2) .join('') .toUpperCase(); } export function avColor(seed: string): string { let h = 0; for (const c of seed) h = (h * 31 + c.charCodeAt(0)) >>> 0; return AV_COLORS[h % AV_COLORS.length]; } export function Avatar({ name, id, size = 40, fs = 14 }: { name: string; id: string; size?: number; fs?: number }) { return ( {initials(name)} ); } export function Spinner() { return ; } export function Empty({ icon, text }: { icon: string; text: string }) { return (
{icon}
{text}
); } /** Centered modal dialog (desktop-first). */ export function Modal({ open, onClose, title, children, footer, }: { open: boolean; onClose: () => void; title: string; children: ReactNode; footer?: ReactNode; }) { if (!open) return null; return (
e.target === e.currentTarget && onClose()}>

{title}

{children}
{footer &&
{footer}
}
); } /** Render a string (e.g. a QR token) as a scannable QR code. */ export function QrImage({ value, size = 180 }: { value: string; size?: number }) { return (
); } /** Small colored badge for a registration / sponsor type. */ export function TypeBadge({ type }: { type: string }) { // "service_session" -> "Service Session" (capitalize each word). const label = type.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()); return {label}; } /** A small on/off toggle switch. */ export function Toggle({ checked, onChange, label, }: { checked: boolean; onChange: (v: boolean) => void; label?: string; }) { return ( ); }