1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

UX: Update three-dot icon for settings (#17558)

This commit is contained in:
David Walsh 2023-02-15 08:39:46 -06:00 committed by GitHub
parent a4f33ec0ad
commit fca2a3f97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 73 deletions

View File

@ -2188,6 +2188,9 @@
"nftDisclaimer": { "nftDisclaimer": {
"message": "Disclaimer: MetaMask pulls the media file from the source url. This url sometimes is changed by the marketplace the NFT was minted on." "message": "Disclaimer: MetaMask pulls the media file from the source url. This url sometimes is changed by the marketplace the NFT was minted on."
}, },
"nftOptions": {
"message": "NFT Options"
},
"nftTokenIdPlaceholder": { "nftTokenIdPlaceholder": {
"message": "Enter the token id" "message": "Enter the token id"
}, },
@ -2601,6 +2604,9 @@
"optionalWithParanthesis": { "optionalWithParanthesis": {
"message": "(Optional)" "message": "(Optional)"
}, },
"options": {
"message": "Options"
},
"or": { "or": {
"message": "or" "message": "or"
}, },

View File

@ -35,7 +35,7 @@ describe('Token Details', function () {
await driver.fill('#custom-symbol', tokenSymbol); await driver.fill('#custom-symbol', tokenSymbol);
await driver.clickElement({ text: 'Add custom token', tag: 'button' }); await driver.clickElement({ text: 'Add custom token', tag: 'button' });
await driver.clickElement({ text: 'Import tokens', tag: 'button' }); await driver.clickElement({ text: 'Import tokens', tag: 'button' });
await driver.clickElement('[title="Asset options"]'); await driver.clickElement('[aria-label="Asset options"]');
await driver.clickElement({ text: 'Token details', tag: 'span' }); await driver.clickElement({ text: 'Token details', tag: 'span' });
const tokenAddressFound = { const tokenAddressFound = {

View File

@ -1,6 +1,8 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { useState } from 'react'; import React, { useRef } from 'react';
import { Menu } from '../../../ui/menu'; import { Menu } from '../../../ui/menu';
import { ButtonIcon, ICON_NAMES } from '../../../component-library';
import { useI18nContext } from '../../../../hooks/useI18nContext';
const ConnectedAccountsListOptions = ({ const ConnectedAccountsListOptions = ({
children, children,
@ -8,18 +10,20 @@ const ConnectedAccountsListOptions = ({
onHideOptions, onHideOptions,
show, show,
}) => { }) => {
const [optionsButtonElement, setOptionsButtonElement] = useState(null); const ref = useRef(false);
const t = useI18nContext();
return ( return (
<> <div ref={ref}>
<button <ButtonIcon
className="fas fa-ellipsis-v connected-accounts-options__button" iconName={ICON_NAMES.MORE_VERTICAL}
className="connected-accounts-options__button"
onClick={onShowOptions} onClick={onShowOptions}
ref={setOptionsButtonElement} ariaLabel={t('options')}
/> />
{show ? ( {show ? (
<Menu <Menu
anchorElement={optionsButtonElement} anchorElement={ref.current}
onHide={onHideOptions} onHide={onHideOptions}
popperOptions={{ popperOptions={{
modifiers: [ modifiers: [
@ -30,7 +34,7 @@ const ConnectedAccountsListOptions = ({
{children} {children}
</Menu> </Menu>
) : null} ) : null}
</> </div>
); );
}; };

View File

@ -1,4 +1,4 @@
import React, { useState, useContext } from 'react'; import React, { useState, useContext, useRef } from 'react';
import browser from 'webextension-polyfill'; import browser from 'webextension-polyfill';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
@ -11,16 +11,16 @@ import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { getOriginOfCurrentTab } from '../../../selectors'; import { getOriginOfCurrentTab } from '../../../selectors';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
import { ButtonIcon, ICON_NAMES } from '../../component-library';
import AccountOptionsMenu from './account-options-menu'; import AccountOptionsMenu from './account-options-menu';
export default function MenuBar() { export default function MenuBar() {
const t = useI18nContext(); const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext); const trackEvent = useContext(MetaMetricsContext);
const history = useHistory(); const history = useHistory();
const [accountOptionsButtonElement, setAccountOptionsButtonElement] =
useState(null);
const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false); const [accountOptionsMenuOpen, setAccountOptionsMenuOpen] = useState(false);
const origin = useSelector(getOriginOfCurrentTab); const origin = useSelector(getOriginOfCurrentTab);
const ref = useRef(false);
const showStatus = const showStatus =
getEnvironmentType() === ENVIRONMENT_TYPE_POPUP && getEnvironmentType() === ENVIRONMENT_TYPE_POPUP &&
@ -34,14 +34,13 @@ export default function MenuBar() {
onClick={() => history.push(CONNECTED_ACCOUNTS_ROUTE)} onClick={() => history.push(CONNECTED_ACCOUNTS_ROUTE)}
/> />
) : null} ) : null}
<SelectedAccount /> <SelectedAccount />
<span style={{ display: 'inherit' }} ref={ref}>
<button <ButtonIcon
className="fas fa-ellipsis-v menu-bar__account-options" iconName={ICON_NAMES.MORE_VERTICAL}
className="menu-bar__account-options"
data-testid="account-options-menu-button" data-testid="account-options-menu-button"
ref={setAccountOptionsButtonElement} ariaLabel={t('accountOptions')}
title={t('accountOptions')}
onClick={() => { onClick={() => {
trackEvent({ trackEvent({
event: EVENT_NAMES.NAV_ACCOUNT_MENU_OPENED, event: EVENT_NAMES.NAV_ACCOUNT_MENU_OPENED,
@ -53,13 +52,13 @@ export default function MenuBar() {
setAccountOptionsMenuOpen(true); setAccountOptionsMenuOpen(true);
}} }}
/> />
</span>
{accountOptionsMenuOpen && ( {accountOptionsMenuOpen ? (
<AccountOptionsMenu <AccountOptionsMenu
anchorElement={accountOptionsButtonElement} anchorElement={ref.current}
onClose={() => setAccountOptionsMenuOpen(false)} onClose={() => setAccountOptionsMenuOpen(false)}
/> />
)} ) : null}
</div> </div>
); );
} }

View File

@ -22,10 +22,18 @@ exports[`Collectible Details should match minimal props and state snapshot 1`] =
MUNK #1 MUNK #1
</span> </span>
</button> </button>
<div>
<button <button
class="fas fa-ellipsis-v collectible-options__button" aria-label="NFT Options"
class="box mm-button-icon mm-button-icon--size-lg collectible-options__button box--display-inline-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-text-default box--background-color-transparent box--rounded-lg"
data-testid="collectible-options__button" data-testid="collectible-options__button"
>
<div
class="box mm-icon mm-icon--size-lg box--flex-direction-row box--color-inherit"
style="mask-image: url('./images/icons/more-vertical.svg');"
/> />
</button>
</div>
</div> </div>
<div <div
class="box collectible-details box--flex-direction-row" class="box collectible-details box--flex-direction-row"

View File

@ -1,12 +1,5 @@
.collectible-options { .collectible-options {
&__button { &__button {
font-size: $font-size-paragraph;
color: var(--color-text-default);
background-color: inherit;
padding: 2px 0 2px 8px; padding: 2px 0 2px 8px;
} }
&__icon {
font-weight: 900;
}
} }

View File

@ -1,28 +1,31 @@
import React, { useContext, useState } from 'react'; import React, { useContext, useRef, useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { I18nContext } from '../../../contexts/i18n'; import { I18nContext } from '../../../contexts/i18n';
import { Menu, MenuItem } from '../../ui/menu'; import { Menu, MenuItem } from '../../ui/menu';
import { ICON_NAMES } from '../../component-library'; import { ButtonIcon, ICON_NAMES } from '../../component-library';
import { Color } from '../../../helpers/constants/design-system';
const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => { const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => {
const t = useContext(I18nContext); const t = useContext(I18nContext);
const [collectibleOptionsButtonElement, setCollectibleOptionsButtonElement] =
useState(null);
const [collectibleOptionsOpen, setCollectibleOptionsOpen] = useState(false); const [collectibleOptionsOpen, setCollectibleOptionsOpen] = useState(false);
const ref = useRef(false);
return ( return (
<> <div ref={ref}>
<button <ButtonIcon
className="fas fa-ellipsis-v collectible-options__button" iconName={ICON_NAMES.MORE_VERTICAL}
className="collectible-options__button"
data-testid="collectible-options__button" data-testid="collectible-options__button"
onClick={() => setCollectibleOptionsOpen(true)} onClick={() => setCollectibleOptionsOpen(true)}
ref={setCollectibleOptionsButtonElement} color={Color.textDefault}
ariaLabel={t('nftOptions')}
/> />
{collectibleOptionsOpen ? ( {collectibleOptionsOpen ? (
<Menu <Menu
anchorElement={collectibleOptionsButtonElement}
data-testid="close-collectible-options-menu" data-testid="close-collectible-options-menu"
anchorElement={ref.current}
onHide={() => setCollectibleOptionsOpen(false)} onHide={() => setCollectibleOptionsOpen(false)}
> >
{onViewOnOpensea ? ( {onViewOnOpensea ? (
@ -49,7 +52,7 @@ const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => {
</MenuItem> </MenuItem>
</Menu> </Menu>
) : null} ) : null}
</> </div>
); );
}; };

View File

@ -34,13 +34,6 @@
.asset-options { .asset-options {
&__button { &__button {
font-size: $font-size-paragraph;
color: var(--color-text-default);
background-color: inherit;
padding: 2px 0 2px 8px; padding: 2px 0 2px 8px;
} }
&__icon {
font-weight: 900;
}
} }

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from 'react'; import React, { useContext, useRef, useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@ -7,7 +7,8 @@ import { I18nContext } from '../../../contexts/i18n';
import { Menu, MenuItem } from '../../../components/ui/menu'; import { Menu, MenuItem } from '../../../components/ui/menu';
import { getBlockExplorerLinkText } from '../../../selectors'; import { getBlockExplorerLinkText } from '../../../selectors';
import { NETWORKS_ROUTE } from '../../../helpers/constants/routes'; import { NETWORKS_ROUTE } from '../../../helpers/constants/routes';
import { ICON_NAMES } from '../../../components/component-library'; import { ButtonIcon, ICON_NAMES } from '../../../components/component-library';
import { Color } from '../../../helpers/constants/design-system';
const AssetOptions = ({ const AssetOptions = ({
onRemove, onRemove,
@ -18,11 +19,10 @@ const AssetOptions = ({
isNativeAsset, isNativeAsset,
}) => { }) => {
const t = useContext(I18nContext); const t = useContext(I18nContext);
const [assetOptionsButtonElement, setAssetOptionsButtonElement] =
useState(null);
const [assetOptionsOpen, setAssetOptionsOpen] = useState(false); const [assetOptionsOpen, setAssetOptionsOpen] = useState(false);
const history = useHistory(); const history = useHistory();
const blockExplorerLinkText = useSelector(getBlockExplorerLinkText); const blockExplorerLinkText = useSelector(getBlockExplorerLinkText);
const ref = useRef(false);
const routeToAddBlockExplorerUrl = () => { const routeToAddBlockExplorerUrl = () => {
history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`); history.push(`${NETWORKS_ROUTE}#blockExplorerUrl`);
@ -34,17 +34,18 @@ const AssetOptions = ({
}; };
return ( return (
<> <div ref={ref}>
<button <ButtonIcon
className="fas fa-ellipsis-v asset-options__button" className="asset-options__button"
data-testid="asset-options__button" data-testid="asset-options__button"
onClick={() => setAssetOptionsOpen(true)} onClick={() => setAssetOptionsOpen(true)}
ref={setAssetOptionsButtonElement} ariaLabel={t('assetOptions')}
title={t('assetOptions')} iconName={ICON_NAMES.MORE_VERTICAL}
color={Color.textDefault}
/> />
{assetOptionsOpen ? ( {assetOptionsOpen ? (
<Menu <Menu
anchorElement={assetOptionsButtonElement} anchorElement={ref.current}
onHide={() => setAssetOptionsOpen(false)} onHide={() => setAssetOptionsOpen(false)}
> >
<MenuItem <MenuItem
@ -99,7 +100,7 @@ const AssetOptions = ({
)} )}
</Menu> </Menu>
) : null} ) : null}
</> </div>
); );
}; };