import { useState } from "react"; import { useShare } from "../hooks/useShare"; interface ShareSheetProps { open: boolean; onClose: () => void; text: string; embedUrl?: string; title?: string; user?: { username: string; displayName?: string; pfpUrl?: string; }; } export function ShareSheet({ open, onClose, text, embedUrl, title = "Share to Warpcast", user, }: ShareSheetProps) { const { share } = useShare(); const [isSharing, setIsSharing] = useState(false); if (!open) return null; const handleShare = async () => { setIsSharing(true); try { const result = await share({ text, embedUrl }); if (result.success) { onClose(); } } finally { setIsSharing(false); } }; const handleBackdropClick = (e: React.MouseEvent) => { if (e.target === e.currentTarget) { onClose(); } }; // Truncate preview text if too long const previewText = text.length > 280 ? text.slice(0, 277) + "..." : text; return (
{/* Header */}

{title}

{/* Preview card */}
{user && (
{user.pfpUrl ? ( ) : (
)}

{user.displayName || user.username}

@{user.username}

)}

{previewText}

{embedUrl &&

{embedUrl}

}
{/* Actions */}
); }