import React, { lazy, Suspense, useCallback, useState } from 'react'
import useWebShare from '../../hooks/useWebShare'
const ArtworkShareModal = lazy(() => import('./ArtworkShareModal'))
/* ── Share icon (lucide-style) ───────────────────────────────────────────── */
function ShareIcon() {
return (
)
}
/**
* ArtworkShareButton – renders the Share pill and manages modal / native share.
*
* Props:
* artwork – artwork object
* shareUrl – canonical URL to share
* size – 'default' | 'small' (for mobile bar)
*/
export default function ArtworkShareButton({ artwork, shareUrl, size = 'default', isLoggedIn = false }) {
const [modalOpen, setModalOpen] = useState(false)
const openModal = useCallback(
() => setModalOpen(true),
[],
)
const closeModal = useCallback(
() => setModalOpen(false),
[],
)
const { share } = useWebShare({ onFallback: openModal })
const handleClick = () => {
share({
title: artwork?.title || 'Artwork',
text: artwork?.description?.substring(0, 120) || '',
url: shareUrl || artwork?.canonical_url || window.location.href,
})
}
const isSmall = size === 'small'
return (
<>
{/* Lazy-loaded modal – only rendered when opened */}
{modalOpen && (
)}
>
)
}