1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/app/detected-token/detected-token-address/detected-token-address.js
Dhruv d375dc550d
Part of #18714: Replacing deprecated constants (#19843)
* replacing constants

* updating ButtonLink component

* Updates to responsive typography

* lint fixes

* snapshot updates

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-08-01 14:37:16 -07:00

49 lines
1.3 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard';
import Tooltip from '../../../ui/tooltip';
import {
Display,
TextColor,
} from '../../../../helpers/constants/design-system';
import { shortenAddress } from '../../../../helpers/utils/util';
import { Text, Box, ButtonLink, IconName } from '../../../component-library';
const DetectedTokenAddress = ({ tokenAddress }) => {
const t = useI18nContext();
const [copied, handleCopy] = useCopyToClipboard();
return (
<Box display={Display.InlineFlex} className="detected-token-address">
<Text color={TextColor.textDefault}>{`${t('tokenAddress')}:`}</Text>
<Tooltip
position="bottom"
title={copied ? t('copiedExclamation') : t('copyToClipboard')}
>
<ButtonLink
className="detected-token-address__copy-link"
onClick={() => {
handleCopy(tokenAddress);
}}
endIconName={IconName.Copy}
marginLeft={2}
marginRight={2}
>
{shortenAddress(tokenAddress)}
</ButtonLink>
</Tooltip>
</Box>
);
};
DetectedTokenAddress.propTypes = {
tokenAddress: PropTypes.string,
};
export default DetectedTokenAddress;