1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

UX Multichain: Replace badge icon with current network image (#19964)

* updated network with current network

* Update snapshot

* fixed stories

---------

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
This commit is contained in:
Nidhi Kumari 2023-07-12 22:57:39 +05:30 committed by GitHub
parent c86cbf5df2
commit beffc0611f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 25 deletions

View File

@ -26,7 +26,7 @@ exports[`Token Cell should match snapshot 1`] = `
class="box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase box--display-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-text-default box--background-color-background-alternative box--rounded-full box--border-color-border-muted box--border-style-solid box--border-width-1" class="box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase box--display-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-text-default box--background-color-background-alternative box--rounded-full box--border-color-border-muted box--border-style-solid box--border-width-1"
> >
<img <img
alt="TEST logo" alt="Ethereum Mainnet logo"
class="mm-avatar-network__network-image" class="mm-avatar-network__network-image"
src="./images/eth_logo.png" src="./images/eth_logo.png"
/> />

View File

@ -26,7 +26,7 @@ exports[`TokenListItem should render correctly 1`] = `
class="box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase box--display-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-text-default box--background-color-background-alternative box--rounded-full box--border-color-border-muted box--border-style-solid box--border-width-1" class="box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase box--display-flex box--flex-direction-row box--justify-content-center box--align-items-center box--color-text-default box--background-color-background-alternative box--rounded-full box--border-color-border-muted box--border-style-solid box--border-width-1"
> >
<img <img
alt="undefined logo" alt="Ethereum Mainnet logo"
class="mm-avatar-network__network-image" class="mm-avatar-network__network-image"
src="./images/eth_logo.png" src="./images/eth_logo.png"
/> />

View File

@ -21,7 +21,11 @@ import {
Text, Text,
Box, Box,
} from '../../component-library'; } from '../../component-library';
import { getCurrentChainId, getNativeCurrencyImage } from '../../../selectors'; import {
getCurrentChainId,
getCurrentNetwork,
getNativeCurrencyImage,
} from '../../../selectors';
import Tooltip from '../../ui/tooltip'; import Tooltip from '../../ui/tooltip';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../contexts/metametrics'; import { MetaMetricsContext } from '../../../contexts/metametrics';
@ -29,7 +33,6 @@ import {
MetaMetricsEventCategory, MetaMetricsEventCategory,
MetaMetricsEventName, MetaMetricsEventName,
} from '../../../../shared/constants/metametrics'; } from '../../../../shared/constants/metametrics';
import { LINEA_GOERLI_TOKEN_IMAGE_URL } from '../../../../shared/constants/network';
export const TokenListItem = ({ export const TokenListItem = ({
className, className,
@ -44,11 +47,9 @@ export const TokenListItem = ({
const primaryTokenImage = useSelector(getNativeCurrencyImage); const primaryTokenImage = useSelector(getNativeCurrencyImage);
const trackEvent = useContext(MetaMetricsContext); const trackEvent = useContext(MetaMetricsContext);
const chainId = useSelector(getCurrentChainId); const chainId = useSelector(getCurrentChainId);
const badgeWrapperImage =
title === 'LineaETH' ? LINEA_GOERLI_TOKEN_IMAGE_URL : primaryTokenImage;
const badgeTokenImage =
title === 'LineaETH' ? LINEA_GOERLI_TOKEN_IMAGE_URL : tokenImage;
// Used for badge icon
const currentNetwork = useSelector(getCurrentNetwork);
return ( return (
<Box <Box
className={classnames('multichain-token-list-item', className)} className={classnames('multichain-token-list-item', className)}
@ -83,10 +84,10 @@ export const TokenListItem = ({
badge={ badge={
<AvatarNetwork <AvatarNetwork
size={Size.XS} size={Size.XS}
name={tokenSymbol} name={currentNetwork?.nickname}
src={badgeWrapperImage} src={currentNetwork?.rpcPrefs?.imageUrl}
borderColor={ borderColor={
badgeWrapperImage primaryTokenImage
? BorderColor.borderMuted ? BorderColor.borderMuted
: BorderColor.borderDefault : BorderColor.borderDefault
} }
@ -96,12 +97,10 @@ export const TokenListItem = ({
> >
<AvatarToken <AvatarToken
name={tokenSymbol} name={tokenSymbol}
src={badgeTokenImage} src={tokenImage}
showHalo showHalo
borderColor={ borderColor={
badgeTokenImage tokenImage ? BorderColor.transparent : BorderColor.borderDefault
? BorderColor.transparent
: BorderColor.borderDefault
} }
/> />
</BadgeWrapper> </BadgeWrapper>

View File

@ -38,7 +38,12 @@ export default {
const customNetworkData = { const customNetworkData = {
...testData, ...testData,
metamask: { ...testData.metamask, nativeCurrency: '' }, metamask: {
...testData.metamask,
providerConfig: {
chainId: '0x1',
},
},
}; };
const customNetworkStore = configureStore(customNetworkData); const customNetworkStore = configureStore(customNetworkData);
@ -47,6 +52,13 @@ const Template = (args) => {
}; };
export const DefaultStory = Template.bind({}); export const DefaultStory = Template.bind({});
DefaultStory.decorators = [
(Story) => (
<Provider store={customNetworkStore}>
<Story />
</Provider>
),
];
export const ChaosStory = (args) => ( export const ChaosStory = (args) => (
<div <div
@ -55,7 +67,13 @@ export const ChaosStory = (args) => (
<TokenListItem {...args} /> <TokenListItem {...args} />
</div> </div>
); );
ChaosStory.storyName = 'ChaosStory'; ChaosStory.decorators = [
(Story) => (
<Provider store={customNetworkStore}>
<Story />
</Provider>
),
];
ChaosStory.args = { ChaosStory.args = {
title: 'Really long, long name', title: 'Really long, long name',
@ -65,14 +83,6 @@ ChaosStory.args = {
export const NoImagesStory = Template.bind({}); export const NoImagesStory = Template.bind({});
NoImagesStory.decorators = [
(Story) => (
<Provider store={customNetworkStore}>
<Story />
</Provider>
),
];
NoImagesStory.args = { NoImagesStory.args = {
tokenImage: '', tokenImage: '',
}; };