Skip to content

Commit

Permalink
Merge branch 'develop' into e2e-mv3-incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
seaona committed Oct 25, 2022
2 parents e11e768 + c88efad commit d93b7d8
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export default class ConfirmPageContainer extends Component {
tokenName={nativeCurrency}
accountAddress={fromAddress}
networkName={networkName}
chainId={currentTransaction.chainId}
/>
) : (
<ConfirmPageContainerHeader
Expand Down
19 changes: 17 additions & 2 deletions ui/components/app/network-account-balance-header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@
border-bottom: 1px solid var(--color-border-muted);

&__network-account {
&__ident-icon-ethereum {
&__ident-icon-ethereum,
&__ident-icon-ethereum--gray {
height: 18px;
width: 18px;
border-radius: 50%;
border: 1px solid var(--color-background-default);
background: var(--color-background-default);
margin-inline-start: -10px;
margin-top: -20px;
border: none !important;

> span {
display: flex;
justify-content: center;
line-height: 18px;
}
}

&__ident-icon-ethereum--gray {
border: 1px solid var(--color-border-default);
}
}
}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 (
<Box
Expand All @@ -45,12 +52,11 @@ export default function NetworkAccountBalanceHeader({
alignItems={ALIGN_ITEMS.CENTER}
>
<Identicon address={accountAddress} diameter={32} />
<Identicon
address={accountAddress}
diameter={16}
imageBorder
image="./images/eth_badge.svg"
className="network-account-balance-header__network-account__ident-icon-ethereum"
<IconWithFallback
name={networkName}
size={16}
icon={networkIcon}
wrapperClassName={networkIconWrapperClass}
/>
</Box>
<Box
Expand Down Expand Up @@ -109,4 +115,5 @@ NetworkAccountBalanceHeader.propTypes = {
accountBalance: PropTypes.string,
tokenName: PropTypes.string,
accountAddress: PropTypes.string,
chainId: PropTypes.string,
};
42 changes: 27 additions & 15 deletions ui/components/ui/icon-with-fallback/icon-with-fallback.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const IconWithFallback = ({
size,
className,
fallbackClassName,
wrapperClassName,
...props
}) => {
const [iconError, setIconError] = useState(false);
Expand All @@ -17,21 +18,28 @@ const IconWithFallback = ({
setIconError(true);
};

return !iconError && icon ? (
<img
onError={handleOnError}
src={icon}
style={style}
className={className}
alt={name || 'icon'}
{...props}
/>
) : (
<span
className={classnames('icon-with-fallback__fallback', fallbackClassName)}
>
{name && name.length ? name.charAt(0).toUpperCase() : ''}
</span>
return (
<div className={classnames(wrapperClassName)}>
{!iconError && icon ? (
<img
onError={handleOnError}
src={icon}
style={style}
className={className}
alt={name || 'icon'}
{...props}
/>
) : (
<span
className={classnames(
'icon-with-fallback__fallback',
fallbackClassName,
)}
>
{name?.charAt(0).toUpperCase() || ''}
</span>
)}
</div>
);
};

Expand All @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ exports[`DropdownSearchList renders the component with initial props 1`] = `
<div
class="dropdown-search-list__selector-closed"
>
<img
alt="symbol"
class="url-icon dropdown-search-list__selector-closed-icon"
src="iconUrl"
/>
<div
class=""
>
<img
alt="symbol"
class="url-icon dropdown-search-list__selector-closed-icon"
src="iconUrl"
/>
</div>
<div
class="dropdown-search-list__labels"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ exports[`MainQuoteSummary renders the component with initial props 1`] = `
>
2
</span>
<span
class="icon-with-fallback__fallback url-icon__fallback main-quote-summary__icon-fallback"
<div
class=""
>
E
</span>
<span
class="icon-with-fallback__fallback url-icon__fallback main-quote-summary__icon-fallback"
>
E
</span>
</div>
<span
class="main-quote-summary__source-row-symbol"
title="ETH"
Expand All @@ -29,11 +33,15 @@ exports[`MainQuoteSummary renders the component with initial props 2`] = `
<div
class="main-quote-summary__destination-row"
>
<span
class="icon-with-fallback__fallback url-icon__fallback main-quote-summary__icon-fallback"
<div
class=""
>
B
</span>
<span
class="icon-with-fallback__fallback url-icon__fallback main-quote-summary__icon-fallback"
>
B
</span>
</div>
<span
class="main-quote-summary__destination-row-symbol"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ exports[`SearchableItemList renders the component with initial props 2`] = `
data-testid="searchable-item-list__item"
tabindex="0"
>
<img
alt="primaryLabel"
class="url-icon"
src="iconUrl"
/>
<div
class=""
>
<img
alt="primaryLabel"
class="url-icon"
src="iconUrl"
/>
</div>
<div
class="searchable-item-list__labels"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ exports[`ItemList renders the component with initial props 1`] = `
data-testid="searchable-item-list__item"
tabindex="0"
>
<img
alt="primaryLabel"
class="url-icon"
src="iconUrl"
/>
<div
class=""
>
<img
alt="primaryLabel"
class="url-icon"
src="iconUrl"
/>
</div>
<div
class="searchable-item-list__labels"
>
Expand Down
28 changes: 18 additions & 10 deletions ui/pages/swaps/view-quote/__snapshots__/view-quote.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ exports[`ViewQuote renders the component with EIP-1559 enabled 1`] = `
>
10
</span>
<img
alt="DAI"
class="url-icon main-quote-summary__icon"
src="https://foo.bar/logo.png"
/>
<div
class=""
>
<img
alt="DAI"
class="url-icon main-quote-summary__icon"
src="https://foo.bar/logo.png"
/>
</div>
<span
class="main-quote-summary__source-row-symbol"
title="DAI"
Expand Down Expand Up @@ -85,11 +89,15 @@ exports[`ViewQuote renders the component with initial props 1`] = `
>
10
</span>
<img
alt="DAI"
class="url-icon main-quote-summary__icon"
src="https://foo.bar/logo.png"
/>
<div
class=""
>
<img
alt="DAI"
class="url-icon main-quote-summary__icon"
src="https://foo.bar/logo.png"
/>
</div>
<span
class="main-quote-summary__source-row-symbol"
title="DAI"
Expand Down
1 change: 1 addition & 0 deletions ui/pages/token-allowance/token-allowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default function TokenAllowance({
accountBalance={currentTokenBalance}
tokenName={tokenSymbol}
accountAddress={userAddress}
chainId={fullTxData.chainId}
/>
<Box
display={DISPLAY.FLEX}
Expand Down

0 comments on commit d93b7d8

Please sign in to comment.