* Inner component that uses R3F hooks (must be inside Canvas context)
({ shareSource, copied, setCopied, className }: ShareButtonInnerProps)
| 78 | * Inner component that uses R3F hooks (must be inside Canvas context) |
| 79 | */ |
| 80 | function ShareButtonInner({ shareSource, copied, setCopied, className }: ShareButtonInnerProps) { |
| 81 | const { controls } = useThree(); |
| 82 | const display = getShareButtonDisplayState('share', copied); |
| 83 | |
| 84 | const handleShare = useCallback(async () => { |
| 85 | const viewState = getControlsViewState(controls); |
| 86 | const url = generateShareableUrl(shareSource, viewState); |
| 87 | await copyWithFeedback(url, setCopied); |
| 88 | }, [controls, shareSource, setCopied]); |
| 89 | |
| 90 | return ( |
| 91 | <button |
| 92 | type="button" |
| 93 | onClick={handleShare} |
| 94 | className={`${getShareButtonClass(copied)} ${className}`} |
| 95 | title={display.title} |
| 96 | > |
| 97 | <ShareButtonIcon iconKind={display.iconKind} /> |
| 98 | <span>{display.label}</span> |
| 99 | </button> |
| 100 | ); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Standalone ShareButton that doesn't require R3F context. |
nothing calls this directly
no test coverage detected