import { Icon } from '../_shared/Icon' import { createSocialShare, TWITTER, VK, FACEBOOK, TELEGRAM } from '@solid-primitives/share' import styles from '../_shared/Popup/Popup.module.scss' import type { PopupProps } from '../_shared/Popup' import { Popup } from '../_shared/Popup' import { useLocalize } from '../../context/localize' import { createEffect, createSignal } from 'solid-js' type SharePopupProps = { title: string shareUrl?: string imageUrl: string description: string isVisible?: (value: boolean) => void } & Omit export const getShareUrl = (params: { pathname?: string } = {}) => { if (typeof location === 'undefined') return '' const pathname = params.pathname ?? location.pathname return location.origin + pathname } export const SharePopup = (props: SharePopupProps) => { const { t } = useLocalize() const [isVisible, setIsVisible] = createSignal(false) createEffect(() => { if (props.isVisible) { props.isVisible(isVisible()) } }) const [share] = createSocialShare(() => ({ title: props.title, url: props.shareUrl, description: props.description })) const copyLink = async () => { await navigator.clipboard.writeText(props.shareUrl) } return ( setIsVisible(value)}> ) }