diff --git a/src/TokenTransferItem.tsx b/src/TokenTransferItem.tsx index 83c5e81..92ec6ee 100644 --- a/src/TokenTransferItem.tsx +++ b/src/TokenTransferItem.tsx @@ -2,6 +2,7 @@ import React from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCaretRight } from "@fortawesome/free-solid-svg-icons"; import AddressHighlighter from "./components/AddressHighlighter"; +import ValueHighlighter from "./components/ValueHighlighter"; import DecoratedAddressLink from "./components/DecoratedAddressLink"; import FormattedBalance from "./components/FormattedBalance"; import { @@ -52,10 +53,12 @@ const TokenTransferItem: React.FC = ({
For - + + + ; + +const ValueHighlighter: React.FC = ({ + value, + children, +}) => { + const [selection, setSelection] = useSelectionContext(); + const select = () => { + setSelection({ type: "value", content: value.toString() }); + }; + const deselect = () => { + setSelection(null); + }; + + return ( +
+ {children} +
+ ); +}; + +export default React.memo(ValueHighlighter); diff --git a/src/useSelection.ts b/src/useSelection.ts index a02f1fe..b34dc81 100644 --- a/src/useSelection.ts +++ b/src/useSelection.ts @@ -1,7 +1,7 @@ import React, { useState, useContext } from "react"; export type Selection = { - type: "address"; + type: "address" | "value"; content: string; };