1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/app/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js
Garrett Bear 065c499753
update ButtonIcon to TS (#18448)
* 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>
2023-04-12 08:55:24 -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/button-icon/deprecated';
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;