"use client"; import { useCallback, useState } from "react"; import { ArrowUpRight, Check, ClipboardCopy, Codepen, Download, ExternalLink, } from "lucide-react"; import { cn } from "@/lib/utils"; import { DEEP_LINK_TARGETS, type DeepLinkTarget, openDeepLink, } from "@/lib/svg-utils"; interface DeepLinkActionsProps { svg: string; title: string; layout?: "stack" | "grid"; className?: string; } function TargetIcon({ id }: { id: string }) { if (id === "codepen") return ; if (id === "jsfiddle") return ; if (id === "filagram") { return ( ); } if (id === "figma") { return ( ); } if (id === "sketch") { return ( <> ); } if (id === "illustrator") return ; return ; } function ActionRow({ target, toast, onClick, }: { target: DeepLinkTarget; toast: string | null; onClick: (t: DeepLinkTarget) => void; }) { return ( ); } export function DeepLinkActions({ svg, title, layout = "stack", className, }: DeepLinkActionsProps) { const [toasts, setToasts] = useState>({}); const handleClick = useCallback( async (target: DeepLinkTarget) => { const result = await openDeepLink(target, svg, title); if (result.ok) { const msg = result.message ?? "Opened in new tab."; setToasts((prev) => ({ ...prev, [target.id]: msg })); setTimeout(() => { setToasts((prev) => { const next = { ...prev }; delete next[target.id]; return next; }); }, 2400); } else { setToasts((prev) => ({ ...prev, [target.id]: result.message ?? "Could not open.", })); setTimeout(() => { setToasts((prev) => { const next = { ...prev }; delete next[target.id]; return next; }); }, 3000); } }, [svg, title], ); return (
{DEEP_LINK_TARGETS.map((t) => ( ))}
); }