diff --git a/components/TokenActions/index.tsx b/components/TokenActions/index.tsx index fdaf09a0..c38c3784 100644 --- a/components/TokenActions/index.tsx +++ b/components/TokenActions/index.tsx @@ -1,89 +1,81 @@ -import React, { Fragment } from 'react'; +import React, { useState } from 'react'; import { ethers } from 'ethers'; import { MoreOutlined, PlusOutlined } from '@ant-design/icons'; -import { Popover, Transition } from '@headlessui/react'; import { KnownNetwork, NETWORKS } from '@tracer-protocol/pools-js'; import { Logo, LogoTicker } from '~/components/General'; import { BlockExplorerAddressType } from '~/types/blockExplorers'; import { openBlockExplorer } from '~/utils/blockExplorers'; import { watchAsset } from '~/utils/rpcMethods'; -// const Actions -export default (({ provider, token, arbiscanTarget, otherActions }) => ( - <> - - {({ open }) => ( - <> - {/* Button */} - - - +import { Popover } from 'react-tiny-popover'; - {/* Menu */} - - -
-
watchAsset(provider, token)} - > - - Add token to wallet -
- {arbiscanTarget ? ( -
- openBlockExplorer( - arbiscanTarget.type, - arbiscanTarget.target, - provider?.network?.chainId?.toString() as KnownNetwork, - ) - } - > - - View on Arbiscan -
- ) : null} - {otherActions - ? otherActions.map((action) => ( -
- openBlockExplorer( - action.type, - action.target, - provider?.network?.chainId?.toString() as KnownNetwork, - ) - } - > - - {action.text} -
- )) - : null} +export default (({ provider, token, arbiscanTarget, otherActions }) => { + const [isOpen, setIsOpen] = useState(false); + + return ( + setIsOpen(false)} + content={ +
setIsOpen(!isOpen)}> +
+
watchAsset(provider, token)} + > + + Add token to wallet +
+ {arbiscanTarget ? ( +
+ openBlockExplorer( + arbiscanTarget.type, + arbiscanTarget.target, + provider?.network?.chainId?.toString() as KnownNetwork, + ) + } + > + + View on Arbiscan
- - - - )} + ) : null} + {otherActions + ? otherActions.map((action) => ( +
+ openBlockExplorer( + action.type, + action.target, + provider?.network?.chainId?.toString() as KnownNetwork, + ) + } + > + + {action.text} +
+ )) + : null} +
+
+ } + > +
setIsOpen(!isOpen)}> + +
- -)) as React.FC<{ + ); +}) as React.FC<{ provider: ethers.providers.JsonRpcProvider | null; token: { address: string; diff --git a/package.json b/package.json index 83cfc579..48070311 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "react-dom": "17", "react-jazzicon": "^0.1.3", "react-resize-detector": "^6.7.4", + "react-tiny-popover": "^7.0.1", "react-toastify": "^8.2.0", "stream": "^0.0.2", "styled-components": "^5.2.1", diff --git a/yarn.lock b/yarn.lock index e14cc98b..70812fe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10019,6 +10019,11 @@ react-resize-detector@^6.7.4: lodash "^4.17.21" resize-observer-polyfill "^1.5.1" +react-tiny-popover@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/react-tiny-popover/-/react-tiny-popover-7.0.1.tgz#efb396cae335f00a0767ad98b9579d28744aec9e" + integrity sha512-uV+nTZXkCtfPFQtoKwbfX8waaU7+b8LEOoyOUjtmRxqnH3KLX1FkPm7RU+RC8eXxtOe4rC1cuhOIbQFcc71vQQ== + react-toastify@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-8.2.0.tgz#ef7d56bdfdc6272ca6b228368ab564721c3a3244"