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/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js
George Marshall 739075662c
Migrating Icon to typescript and deprecating JS component (#18431)
* Migrating Icon to typescript and deprecating JS component

* gw suggestions (#18434)

---------

Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-04-04 09:48:04 -07:00

50 lines
1.3 KiB
JavaScript

import PropTypes from 'prop-types';
import React, { useRef } from 'react';
import { Menu } from '../../../ui/menu';
import { ICON_NAMES } from '../../../component-library/icon/deprecated';
import { ButtonIcon } from '../../../component-library';
import { useI18nContext } from '../../../../hooks/useI18nContext';
const ConnectedAccountsListOptions = ({
children,
onShowOptions,
onHideOptions,
show,
}) => {
const ref = useRef(false);
const t = useI18nContext();
return (
<div ref={ref}>
<ButtonIcon
iconName={ICON_NAMES.MORE_VERTICAL}
className="connected-accounts-options__button"
onClick={onShowOptions}
ariaLabel={t('options')}
/>
{show ? (
<Menu
anchorElement={ref.current}
onHide={onHideOptions}
popperOptions={{
modifiers: [
{ name: 'preventOverflow', options: { altBoundary: true } },
],
}}
>
{children}
</Menu>
) : null}
</div>
);
};
ConnectedAccountsListOptions.propTypes = {
children: PropTypes.node.isRequired,
onHideOptions: PropTypes.func.isRequired,
onShowOptions: PropTypes.func.isRequired,
show: PropTypes.bool.isRequired,
};
export default ConnectedAccountsListOptions;