diff --git a/frontend/src/components/ShareTip.jsx b/frontend/src/components/ShareTip.jsx new file mode 100644 index 00000000..96924acb --- /dev/null +++ b/frontend/src/components/ShareTip.jsx @@ -0,0 +1,110 @@ +import { useState } from 'react'; + +const PLATFORM_URL = 'https://tipstream.app'; + +function buildShareText(tip) { + const amt = tip.amount ? `${tip.amount} STX` : 'a tip'; + if (tip.type === 'sent') { + return `I just sent ${amt} on TipStream! Support creators on the Stacks blockchain.`; + } + return `I just received ${amt} on TipStream! Join the Stacks tipping community.`; +} + +function twitterUrl(text) { + const params = new URLSearchParams({ + text, + url: PLATFORM_URL, + hashtags: 'TipStream,Stacks,STX', + }); + return `https://twitter.com/intent/tweet?${params.toString()}`; +} + +function linkedinUrl(text) { + const params = new URLSearchParams({ + mini: 'true', + url: PLATFORM_URL, + title: 'TipStream', + summary: text, + }); + return `https://www.linkedin.com/shareArticle?${params.toString()}`; +} + +function facebookUrl() { + const params = new URLSearchParams({ + u: PLATFORM_URL, + }); + return `https://www.facebook.com/sharer/sharer.php?${params.toString()}`; +} + +export default function ShareTip({ tip }) { + const [copied, setCopied] = useState(false); + + if (!tip) return null; + + const text = buildShareText(tip); + + const handleCopyLink = async () => { + try { + await navigator.clipboard.writeText(`${text}\n${PLATFORM_URL}`); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch { + // Fallback for older browsers + } + }; + + const openShare = (url) => { + window.open(url, '_blank', 'noopener,noreferrer,width=600,height=400'); + }; + + return ( +
+ + + + +
+ ); +} diff --git a/frontend/src/components/TipHistory.jsx b/frontend/src/components/TipHistory.jsx index b54f8e22..f42b2a71 100644 --- a/frontend/src/components/TipHistory.jsx +++ b/frontend/src/components/TipHistory.jsx @@ -5,6 +5,7 @@ import { CONTRACT_ADDRESS, CONTRACT_NAME } from '../config/contracts'; import { formatSTX } from '../lib/utils'; import { useTipContext } from '../context/TipContext'; import CopyButton from './ui/copy-button'; +import ShareTip from './ShareTip'; const API_BASE = 'https://api.hiro.so'; @@ -217,6 +218,7 @@ export default function TipHistory({ userAddress }) {

{tip.direction === 'sent' ? '-' : '+'}{formatSTX(tip.amount, 2)} STX

+ ))}