From c88efadf1e322d6f96963162ec5eefae4e2efbd3 Mon Sep 17 00:00:00 2001 From: ryanml Date: Tue, 25 Oct 2022 08:03:45 -0700 Subject: [PATCH] =?UTF-8?q?Remove=20ETH=20badge=20from=20NetworkAccountBal?= =?UTF-8?q?anceHeader=20when=20on=20non-ETH=20net=E2=80=A6=20(#16102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove ETH badge from NetworkAccountBalanceHeader when on non-ETH networks * Network specific icons, or fallback, in the network-account-balance-header * Update snapshots * Code cleanup Co-authored-by: Dan Miller --- .../confirm-page-container.component.js | 1 + .../network-account-balance-header/index.scss | 19 ++++++++- .../network-account-balance-header.js | 21 ++++++---- .../icon-with-fallback.component.js | 42 ++++++++++++------- .../dropdown-search-list.test.js.snap | 14 ++++--- .../main-quote-summary.test.js.snap | 24 +++++++---- .../searchable-item-list.test.js.snap | 14 ++++--- .../item-list.component.test.js.snap | 14 ++++--- .../__snapshots__/view-quote.test.js.snap | 28 ++++++++----- ui/pages/token-allowance/token-allowance.js | 1 + 10 files changed, 121 insertions(+), 57 deletions(-) diff --git a/ui/components/app/confirm-page-container/confirm-page-container.component.js b/ui/components/app/confirm-page-container/confirm-page-container.component.js index edb124001..a972aee17 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container.component.js @@ -217,6 +217,7 @@ export default class ConfirmPageContainer extends Component { tokenName={nativeCurrency} accountAddress={fromAddress} networkName={networkName} + chainId={currentTransaction.chainId} /> ) : ( span { + display: flex; + justify-content: center; + line-height: 18px; + } + } + + &__ident-icon-ethereum--gray { + border: 1px solid var(--color-border-default); } } } diff --git a/ui/components/app/network-account-balance-header/network-account-balance-header.js b/ui/components/app/network-account-balance-header/network-account-balance-header.js index 217111c16..fbf5291b1 100644 --- a/ui/components/app/network-account-balance-header/network-account-balance-header.js +++ b/ui/components/app/network-account-balance-header/network-account-balance-header.js @@ -1,5 +1,6 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; +import IconWithFallback from '../../ui/icon-with-fallback'; import Identicon from '../../ui/identicon'; import { DISPLAY, @@ -14,15 +15,21 @@ import { import Box from '../../ui/box/box'; import { I18nContext } from '../../../contexts/i18n'; import Typography from '../../ui/typography'; +import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP } from '../../../../shared/constants/network'; export default function NetworkAccountBalanceHeader({ networkName, accountName, accountBalance, - tokenName, + tokenName, // Derived from nativeCurrency accountAddress, + chainId, }) { const t = useContext(I18nContext); + const networkIcon = CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[chainId]; + const networkIconWrapperClass = networkIcon + ? 'network-account-balance-header__network-account__ident-icon-ethereum' + : 'network-account-balance-header__network-account__ident-icon-ethereum--gray'; return ( - { const [iconError, setIconError] = useState(false); @@ -17,21 +18,28 @@ const IconWithFallback = ({ setIconError(true); }; - return !iconError && icon ? ( - {name - ) : ( - - {name && name.length ? name.charAt(0).toUpperCase() : ''} - + return ( +
+ {!iconError && icon ? ( + {name + ) : ( + + {name?.charAt(0).toUpperCase() || ''} + + )} +
); }; @@ -52,6 +60,10 @@ IconWithFallback.propTypes = { * className to apply to the image tag */ className: PropTypes.string, + /** + * className to apply to the div that wraps the icon + */ + wrapperClassName: PropTypes.string, /** * Additional className to apply to the fallback span tag */ diff --git a/ui/pages/swaps/dropdown-search-list/__snapshots__/dropdown-search-list.test.js.snap b/ui/pages/swaps/dropdown-search-list/__snapshots__/dropdown-search-list.test.js.snap index d863077c5..ee9809186 100644 --- a/ui/pages/swaps/dropdown-search-list/__snapshots__/dropdown-search-list.test.js.snap +++ b/ui/pages/swaps/dropdown-search-list/__snapshots__/dropdown-search-list.test.js.snap @@ -13,11 +13,15 @@ exports[`DropdownSearchList renders the component with initial props 1`] = ` diff --git a/ui/pages/swaps/searchable-item-list/__snapshots__/searchable-item-list.test.js.snap b/ui/pages/swaps/searchable-item-list/__snapshots__/searchable-item-list.test.js.snap index ef3d79349..acf652948 100644 --- a/ui/pages/swaps/searchable-item-list/__snapshots__/searchable-item-list.test.js.snap +++ b/ui/pages/swaps/searchable-item-list/__snapshots__/searchable-item-list.test.js.snap @@ -42,11 +42,15 @@ exports[`SearchableItemList renders the component with initial props 2`] = ` data-testid="searchable-item-list__item" tabindex="0" > - primaryLabel +
+ primaryLabel +
diff --git a/ui/pages/swaps/searchable-item-list/item-list/__snapshots__/item-list.component.test.js.snap b/ui/pages/swaps/searchable-item-list/item-list/__snapshots__/item-list.component.test.js.snap index 017941d8d..89d3c0343 100644 --- a/ui/pages/swaps/searchable-item-list/item-list/__snapshots__/item-list.component.test.js.snap +++ b/ui/pages/swaps/searchable-item-list/item-list/__snapshots__/item-list.component.test.js.snap @@ -6,11 +6,15 @@ exports[`ItemList renders the component with initial props 1`] = ` data-testid="searchable-item-list__item" tabindex="0" > - primaryLabel +
+ primaryLabel +
diff --git a/ui/pages/swaps/view-quote/__snapshots__/view-quote.test.js.snap b/ui/pages/swaps/view-quote/__snapshots__/view-quote.test.js.snap index b317d3cbf..de5c4da43 100644 --- a/ui/pages/swaps/view-quote/__snapshots__/view-quote.test.js.snap +++ b/ui/pages/swaps/view-quote/__snapshots__/view-quote.test.js.snap @@ -11,11 +11,15 @@ exports[`ViewQuote renders the component with EIP-1559 enabled 1`] = ` > 10 - DAI +
+ DAI +
10 - DAI +
+ DAI +