Inkspring / website / src / ShareButton.tsx
| 1 | /* Share pill (2026-11-21: share buttons everywhere we talk about our |
| 2 | products). Phones open the native share sheet; desktops get a small menu |
| 3 | with Copy link, X, LinkedIn, Facebook and Email. The behavior lives in |
| 4 | /share.js (loaded once in the root layout), the same script every |
| 5 | site uses. */ |
| 6 | type Props = { |
| 7 | url?: string; |
| 8 | title?: string; |
| 9 | text?: string; |
| 10 | label?: string; |
| 11 | small?: boolean; |
| 12 | className?: string; |
| 13 | }; |
| 14 | |
| 15 | export function ShareIcon() { |
| 16 | return ( |
| 17 | <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"> |
| 18 | <path d="M12 3v12" /> |
| 19 | <path d="m7.5 7.5 4.5-4.5 4.5 4.5" /> |
| 20 | <path d="M5 12v6.5A2.5 2.5 0 0 0 7.5 21h9a2.5 2.5 0 0 0 2.5-2.5V12" /> |
| 21 | </svg> |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | export default function ShareButton({ url, title, text, label = 'Share', small = false, className = '' }: Props) { |
| 26 | return ( |
| 27 | <button |
| 28 | type="button" |
| 29 | className={`pm-share-btn${small ? ' is-small' : ''} ${className}`.trim()} |
| 30 | data-pm-share="" |
| 31 | data-share-url={url} |
| 32 | data-share-title={title} |
| 33 | data-share-text={text} |
| 34 | aria-haspopup="menu" |
| 35 | aria-label={title ? `Share ${title}` : 'Share'} |
| 36 | > |
| 37 | <ShareIcon /> |
| 38 | <span data-pm-share-label="">{label}</span> |
| 39 | </button> |
| 40 | ); |
| 41 | } |