add copy address balance btn

pull/86/head
jenya 3 years ago
parent 2016b6296f
commit 0acfe1b8a6
  1. 41
      src/components/ui/OneValueDropdown.tsx

@ -7,6 +7,14 @@ import dayjs from "dayjs";
import {formatNumber} from "./utils"; import {formatNumber} from "./utils";
import {Dropdown} from "../dropdown/Dropdown"; import {Dropdown} from "../dropdown/Dropdown";
import {useThemeMode} from "src/hooks/themeSwitcherHook"; import {useThemeMode} from "src/hooks/themeSwitcherHook";
import {CopyBtn} from "./CopyBtn"
import {toaster} from "../../App"
import {StatusGood} from "grommet-icons";
import styled from "styled-components"
const Icon = styled(StatusGood)`
margin-right: 5px;
`;
interface ONEValueProps { interface ONEValueProps {
value: (string | number)[]; value: (string | number)[];
@ -47,6 +55,15 @@ export const ONEValueDropdown = (props: ONEValueProps) => {
return {value: hashValue, one: v, usd: USDValue || 0, index}; return {value: hashValue, one: v, usd: USDValue || 0, index};
}); });
const hideCopyBtn = false
let valueCopy = ''
try {
valueCopy = normilizedValue[0].one.toString()
} catch (e) {
}
return ( return (
<Dropdown <Dropdown
items={normilizedValue} items={normilizedValue}
@ -56,6 +73,26 @@ export const ONEValueDropdown = (props: ONEValueProps) => {
itemStyles={{justifyContent: "center"}} itemStyles={{justifyContent: "center"}}
renderValue={() => ( renderValue={() => (
<Box direction={"row"} align={"center"} style={{paddingTop: "2px"}}> <Box direction={"row"} align={"center"} style={{paddingTop: "2px"}}>
{hideCopyBtn ? null : (
<CopyBtn
value={valueCopy}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
toaster.show({
message: () => (
<Box direction={"row"} align={"center"} pad={"small"}>
{<Icon size={"small"} color={"headerText"}/>}
<Text size={"small"}>Copied to clipboard</Text>
</Box>
)
});
}}
/>
)}
<div style={{marginRight: '5px'}}></div>
<Text size={"small"}> <Text size={"small"}>
<b> <b>
{normilizedValue.reduce((prev, cur) => { {normilizedValue.reduce((prev, cur) => {
@ -75,7 +112,7 @@ export const ONEValueDropdown = (props: ONEValueProps) => {
.toLocaleString("en-US", { .toLocaleString("en-US", {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 2, maximumFractionDigits: 2,
currency: "USD", currency: "USD"
})} })}
) )
</Text> </Text>
@ -95,7 +132,7 @@ export const ONEValueDropdown = (props: ONEValueProps) => {
{item.usd.toLocaleString("en-US", { {item.usd.toLocaleString("en-US", {
minimumFractionDigits: 2, minimumFractionDigits: 2,
maximumFractionDigits: 2, maximumFractionDigits: 2,
currency: "USD", currency: "USD"
})} })}
) )
</Text> </Text>

Loading…
Cancel
Save