From 45b883477dae977cda488616db5736fe369fadab Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 20 Jul 2022 11:42:49 -0500 Subject: [PATCH] generic copy link button --- web/components/copy-link-button.tsx | 87 +++++++++++++++-------------- web/components/share-market.tsx | 16 +++--- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/web/components/copy-link-button.tsx b/web/components/copy-link-button.tsx index ab6dd66f..4ce4140d 100644 --- a/web/components/copy-link-button.tsx +++ b/web/components/copy-link-button.tsx @@ -3,58 +3,63 @@ import { LinkIcon } from '@heroicons/react/outline' import { Menu, Transition } from '@headlessui/react' import clsx from 'clsx' -import { Contract } from 'common/contract' import { copyToClipboard } from 'web/lib/util/copy' -import { contractPath } from 'web/lib/firebase/contracts' -import { ENV_CONFIG } from 'common/envs/constants' import { ToastClipboard } from 'web/components/toast-clipboard' import { track } from 'web/lib/service/analytics' - -function copyContractUrl(contract: Contract) { - copyToClipboard(`https://${ENV_CONFIG.domain}${contractPath(contract)}`) -} +import { Row } from './layout/row' export function CopyLinkButton(props: { - contract: Contract + url: string + displayUrl?: string + tracking?: string buttonClassName?: string toastClassName?: string }) { - const { contract, buttonClassName, toastClassName } = props + const { url, displayUrl, tracking, buttonClassName, toastClassName } = props return ( - { - copyContractUrl(contract) - track('copy share link') - }} - > - - + + - { + copyToClipboard(url) + track(tracking ?? 'copy share link') + }} > - - - - - - - + + + + + + + + + + + + ) } diff --git a/web/components/share-market.tsx b/web/components/share-market.tsx index a5da585f..be943a34 100644 --- a/web/components/share-market.tsx +++ b/web/components/share-market.tsx @@ -1,5 +1,8 @@ import clsx from 'clsx' -import { Contract, contractUrl } from 'web/lib/firebase/contracts' + +import { ENV_CONFIG } from 'common/envs/constants' + +import { Contract, contractPath, contractUrl } from 'web/lib/firebase/contracts' import { CopyLinkButton } from './copy-link-button' import { Col } from './layout/col' import { Row } from './layout/row' @@ -7,18 +10,15 @@ import { Row } from './layout/row' export function ShareMarket(props: { contract: Contract; className?: string }) { const { contract, className } = props + const url = `https://${ENV_CONFIG.domain}${contractPath(contract)}` + return (
Share your market
-