"use client"; import { useState } from "react"; import type { ContactMethod } from "@/data/content"; import { useStaggerReveal } from "@/hooks/useAnimations"; function ContactIcon({ type }: { type: string }) { const s = { width: 16, height: 16, strokeWidth: 1.5, stroke: "currentColor", fill: "none" as const, }; if (type === "tel") return ( ); if (type === "email") return ( ); return ( ); } function maskValue(label: string, icon: string): string { if (icon === "tel") { const digits = label.replace(/\D/g, ""); return `•••-•••-${digits.slice(-4)}`; } return "•".repeat(Math.min(label.length, 12)); } function getHref(label: string, icon: string): string { if (icon === "tel") return `tel:${label.replace(/\D/g, "")}`; if (icon === "email") return `mailto:${label}`; return "#"; } type Props = { methods: ContactMethod[]; visibleCount: number; visibleComponent: Set; isVisible: boolean; }; export default function ContactMethods({ methods, visibleComponent, visibleCount, isVisible }: Props) { const [revealed, setRevealed] = useState>(new Set()); const [hovered, setHovered] = useState(null); return (
{"contact"}
{methods.map((method, i) => { const isRevealed = !method.masked || revealed.has(i); const isHovered = hovered === i; return (
{ setHovered(i); if (method.masked) { setRevealed((prev) => new Set(prev).add(i)); } }} onMouseLeave={() => setHovered(null)} style={{ display: "inline-flex", alignItems: "center", gap: 10, padding: "8px 14px", fontFamily: "var(--mono)", fontSize: "var(--text-sm)", color: isHovered ? "var(--fg)" : "var(--fg-secondary)", background: isHovered ? "var(--surface-hover)" : "var(--surface)", border: `1px solid ${isHovered ? "var(--border-strong)" : "var(--border)"}`, borderRadius: "var(--radius-md)", transition: `all var(--duration-normal) var(--ease-in-out)`, cursor: isRevealed ? "pointer" : "default", alignSelf: "flex-start", opacity: visibleComponent.has(i + visibleCount) ? 1.0 : 0.0 }} onClick={() => { if (isRevealed) { window.location.href = getHref(method.label, method.icon); } }} > {isRevealed ? method.label : maskValue(method.label, method.icon)} {method.masked && !revealed.has(i) && ( hover to reveal )}
); })}
); }