import { FACEBOOK, TELEGRAM, TWITTER, VK, createSocialShare } from '@solid-primitives/share' import { clsx } from 'clsx' import { Show, createSignal } from 'solid-js' import { useLocalize } from '../../../context/localize' import { useSnackbar } from '../../../context/snackbar' import { Icon } from '../Icon' import { Popover } from '../Popover' import styles from './ShareLinks.module.scss' type Props = { title: string description: string shareUrl: string imageUrl?: string class?: string variant: 'inModal' | 'inPopup' onShareClick?: () => void } export const ShareLinks = (props: Props) => { const { t } = useLocalize() const [isLinkCopied, setIsLinkCopied] = createSignal(false) const { showSnackbar } = useSnackbar() const [share] = createSocialShare(() => ({ title: props.title, url: props.shareUrl, description: props.description, })) const handleShare = (network) => { share(network) if (props.variant === 'inModal') { props.onShareClick() } } const copyLink = async () => { await navigator.clipboard.writeText(props.shareUrl) if (props.variant === 'inModal') { setIsLinkCopied(true) setTimeout(() => { setIsLinkCopied(false) props.onShareClick() }, 3000) } else { showSnackbar({ body: t('Link copied') }) } } return (
) }