mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
065c499753
* update ButtonIcon to TS lint updates fix lint issues add ref fix as prop test updates * box and icon updates for support * Update ui/components/component-library/text-field/README.mdx Co-authored-by: George Marshall <george.marshall@consensys.net> * fix disabled * update types for as * update readme * fix storybook * george changes to button icon * revert headerbase * box prop back to HTMLElementTagNameMap --------- Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
import React, { useContext, useRef, useState } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
import { Menu, MenuItem } from '../../ui/menu';
|
|
import { ButtonIcon } from '../../component-library/button-icon/deprecated';
|
|
import { ICON_NAMES } from '../../component-library/icon/deprecated';
|
|
import { Color } from '../../../helpers/constants/design-system';
|
|
|
|
const NftOptions = ({ onRemove, onViewOnOpensea }) => {
|
|
const t = useContext(I18nContext);
|
|
const [nftOptionsOpen, setNftOptionsOpen] = useState(false);
|
|
const ref = useRef(false);
|
|
|
|
return (
|
|
<div ref={ref}>
|
|
<ButtonIcon
|
|
iconName={ICON_NAMES.MORE_VERTICAL}
|
|
className="nft-options__button"
|
|
data-testid="nft-options__button"
|
|
onClick={() => setNftOptionsOpen(true)}
|
|
color={Color.textDefault}
|
|
ariaLabel={t('nftOptions')}
|
|
/>
|
|
|
|
{nftOptionsOpen ? (
|
|
<Menu
|
|
data-testid="close-nft-options-menu"
|
|
anchorElement={ref.current}
|
|
onHide={() => setNftOptionsOpen(false)}
|
|
>
|
|
{onViewOnOpensea ? (
|
|
<MenuItem
|
|
iconName={ICON_NAMES.EXPORT}
|
|
data-testid="nft-options__view-on-opensea"
|
|
onClick={() => {
|
|
setNftOptionsOpen(false);
|
|
onViewOnOpensea();
|
|
}}
|
|
>
|
|
{t('viewOnOpensea')}
|
|
</MenuItem>
|
|
) : null}
|
|
<MenuItem
|
|
iconName={ICON_NAMES.TRASH}
|
|
data-testid="nft-item-remove"
|
|
onClick={() => {
|
|
setNftOptionsOpen(false);
|
|
onRemove();
|
|
}}
|
|
>
|
|
{t('removeNFT')}
|
|
</MenuItem>
|
|
</Menu>
|
|
) : null}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
NftOptions.propTypes = {
|
|
onRemove: PropTypes.func.isRequired,
|
|
onViewOnOpensea: PropTypes.func,
|
|
};
|
|
|
|
export default NftOptions;
|