From 5d14d79e6e7eab47f530b97ff8b67979841013c7 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Mon, 15 Aug 2022 00:03:05 -0500 Subject: [PATCH] share dialog: remove native sharer; use toast for embed --- web/components/contract/share-modal.tsx | 17 ++++-------- web/components/share-embed-button.tsx | 36 ++++++++----------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/web/components/contract/share-modal.tsx b/web/components/contract/share-modal.tsx index c462e78b..e1805364 100644 --- a/web/components/contract/share-modal.tsx +++ b/web/components/contract/share-modal.tsx @@ -51,17 +51,10 @@ export function ShareModal(props: { color="gradient" className={'mb-2 flex max-w-xs self-center'} onClick={() => { - if (window.navigator.share) { - window.navigator.share({ - url: shareUrl, - title: contract.question, - }) - } else { - copyToClipboard(shareUrl) - toast.success('Link copied!', { - icon: linkIcon, - }) - } + copyToClipboard(shareUrl) + toast.success('Link copied!', { + icon: linkIcon, + }) track('copy share link') }} > @@ -73,7 +66,7 @@ export function ShareModal(props: { className="self-start" tweetText={getTweetText(contract, shareUrl)} /> - + diff --git a/web/components/share-embed-button.tsx b/web/components/share-embed-button.tsx index 8678299b..cfbe78f0 100644 --- a/web/components/share-embed-button.tsx +++ b/web/components/share-embed-button.tsx @@ -1,12 +1,12 @@ -import React, { Fragment } from 'react' +import React from 'react' import { CodeIcon } from '@heroicons/react/outline' -import { Menu, Transition } from '@headlessui/react' +import { Menu } from '@headlessui/react' +import toast from 'react-hot-toast' import { Contract } from 'common/contract' import { contractPath } from 'web/lib/firebase/contracts' import { DOMAIN } from 'common/envs/constants' import { copyToClipboard } from 'web/lib/util/copy' -import { ToastClipboard } from 'web/components/toast-clipboard' import { track } from 'web/lib/service/analytics' export function embedCode(contract: Contract) { @@ -16,11 +16,10 @@ export function embedCode(contract: Contract) { return `` } -export function ShareEmbedButton(props: { - contract: Contract - toastClassName?: string -}) { - const { contract, toastClassName } = props +export function ShareEmbedButton(props: { contract: Contract }) { + const { contract } = props + + const codeIcon =