1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 22:24:27 +01:00
metamask-extension/ui/components/app/detected-token/detected-token-address/detected-token-address.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-05-09 19:47:06 +02:00
import React from 'react';
import PropTypes from 'prop-types';
2022-05-09 19:47:06 +02:00
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
import Box from '../../../ui/box';
import Button from '../../../ui/button';
import Tooltip from '../../../ui/tooltip';
import {
DISPLAY,
TextColor,
TextVariant,
} from '../../../../helpers/constants/design-system';
import { shortenAddress } from '../../../../helpers/utils/util';
import { Text } from '../../../component-library';
2022-05-09 19:47:06 +02:00
const DetectedTokenAddress = ({ tokenAddress }) => {
const t = useI18nContext();
const [copied, handleCopy] = useCopyToClipboard();
return (
<Box display={DISPLAY.INLINE_FLEX} className="detected-token-address">
<Text variant={TextVariant.bodySm} as="h6" color={TextColor.textDefault}>
{`${t('tokenAddress')}:`}
</Text>
<Text
variant={TextVariant.bodySm}
as="h6"
color={TextColor.primaryDefault}
marginLeft={2}
marginRight={2}
>
2022-05-09 19:47:06 +02:00
{shortenAddress(tokenAddress)}
</Text>
<Tooltip
position="bottom"
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
>
<Button
type="link"
className="detected-token-address__copy-link"
onClick={() => {
2022-05-09 19:47:06 +02:00
handleCopy(tokenAddress);
}}
>
<i className="fa fa-copy" />
</Button>
</Tooltip>
</Box>
);
};
DetectedTokenAddress.propTypes = {
2022-05-09 19:47:06 +02:00
tokenAddress: PropTypes.string,
};
export default DetectedTokenAddress;