Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Polish multichain token list styles #26300

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5648f9c
Bump Avatar Network marginRight to 16px
gambinish Aug 1, 2024
d64de36
Tweak top & bottom padding on AssetList item
gambinish Aug 1, 2024
7dd7a1d
Bump border width on AvatarBase and set to default background
gambinish Aug 1, 2024
50affff
Convert stakeableTitle to in-line rather than Flexbox to avoid incosi…
gambinish Aug 1, 2024
ec3ed11
Bump font weight on Stake button to match token title
gambinish Aug 1, 2024
4f53c6b
Update snapshots
gambinish Aug 1, 2024
9e420ff
Tweak padding on Import Token modal
gambinish Aug 2, 2024
4ebdb9c
Tweak padding on Account Overview tabs
gambinish Aug 2, 2024
7bd5456
Use outline instead of border for AvatarNetwork, remove border from A…
gambinish Aug 2, 2024
3aff29b
Update snapshots
gambinish Aug 2, 2024
919ea3a
Lint
gambinish Aug 2, 2024
49453a1
Lint
gambinish Aug 2, 2024
be1befe
Lint scss file
gambinish Aug 2, 2024
f8c9881
Remove all borders from NetworkAvatar icons, in network tab, network …
gambinish Aug 2, 2024
ce838ef
Lint css
gambinish Aug 2, 2024
1ff64c5
Move padding to jsx, rather than scss
gambinish Aug 2, 2024
a957253
Merge branch 'develop' into chore/mmassets-328_polish-multichain-toke…
gambinish Aug 22, 2024
0e4494a
Replace border to AvatarNetwork component-library, remove custom outl…
gambinish Aug 22, 2024
dc6c39e
Merge branch 'develop' into chore/mmassets-328_polish-multichain-toke…
gambinish Aug 22, 2024
7eba1d1
Merge branch 'chore/mmassets-328_polish-multichain-token-list-styles'…
gambinish Aug 22, 2024
160cdcc
Update snapshots
gambinish Aug 22, 2024
f3a46d0
Add content-box to mm-avatar-network styles
gambinish Aug 22, 2024
cbabd33
Revert borderColor to existing implementation of alternative
gambinish Aug 22, 2024
be4ed7d
chore: adding storybook for token-list moving avatar network updates …
georgewrmarshall Aug 23, 2024
0d3d34e
chore: moving border to outside of network badge in mutlichain token …
georgewrmarshall Aug 23, 2024
dae0ccf
chore: updating snapshots
georgewrmarshall Aug 23, 2024
fd3c3b7
Merge branch 'develop' into chore/mmassets-328_polish-multichain-toke…
gambinish Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports[`Token Cell should match snapshot 1`] = `
data-testid="multichain-token-list-item"
>
<a
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-4 mm-box--display-flex mm-box--flex-direction-row"
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-2 mm-box--padding-left-4 mm-box--display-flex mm-box--flex-direction-row"
data-testid="multichain-token-list-button"
href="#"
>
<div
class="mm-box mm-badge-wrapper multichain-token-list-item__badge mm-box--margin-right-3 mm-box--display-inline-block"
class="mm-box mm-badge-wrapper multichain-token-list-item__badge mm-box--margin-right-4 mm-box--display-inline-block"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-md mm-avatar-token mm-text--body-sm mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full"
Expand All @@ -27,7 +27,7 @@ exports[`Token Cell should match snapshot 1`] = `
class="mm-box mm-badge-wrapper__badge-container mm-badge-wrapper__badge-container--circular-top-right"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--rounded-full mm-box--border-color-border-muted box--border-style-solid box--border-width-1"
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
?
</div>
Expand Down
10 changes: 2 additions & 8 deletions ui/components/app/import-token/token-list/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
}

&__tokens-container {
display: flex;
flex-direction: column;
gambinish marked this conversation as resolved.
Show resolved Hide resolved
overflow: auto;
max-height: 214.5px;

Expand All @@ -21,14 +19,10 @@
}

&__token_component {
display: flex;
flex-flow: row nowrap;
padding: 16px;
align-items: center;
gambinish marked this conversation as resolved.
Show resolved Hide resolved
cursor: pointer;

&--selected {
background-color: var(--color-primary-muted);
gambinish marked this conversation as resolved.
Show resolved Hide resolved
&__network-badge {
box-sizing: content-box; // Prevents border effecting size of badge image
gambinish marked this conversation as resolved.
Show resolved Hide resolved
}

&--disabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
TextColor,
TextVariant,
FontWeight,
FlexDirection,
FlexWrap,
BackgroundColor,
} from '../../../../helpers/constants/design-system';
import TokenListPlaceholder from './token-list-placeholder';

Expand Down Expand Up @@ -56,7 +59,11 @@ export default class TokenList extends Component {
<TokenListPlaceholder />
</Box>
) : (
<Box className="token-list__tokens-container">
<Box
className="token-list__tokens-container"
display={Display.Flex}
flexDirection={FlexDirection.Column}
gambinish marked this conversation as resolved.
Show resolved Hide resolved
>
{Array(12)
.fill(undefined)
.map((_, i) => {
Expand All @@ -72,9 +79,19 @@ export default class TokenList extends Component {
<Box
key={address}
display={Display.Flex}
alignItems={AlignItems.center}
flexDirection={FlexDirection.Row}
flexWrap={FlexWrap.NoWrap}
paddingLeft={4}
paddingRight={4}
paddingTop={2}
paddingBottom={2}
gambinish marked this conversation as resolved.
Show resolved Hide resolved
backgroundColor={
selectedTokens[address]
? BackgroundColor.primaryMuted
: BackgroundColor.transparent
}
className={classnames('token-list__token_component', {
'token-list__token_component--selected':
selectedTokens[address],
'token-list__token_component--disabled':
tokenAlreadyAdded,
})}
Expand All @@ -100,6 +117,7 @@ export default class TokenList extends Component {
name={currentNetwork?.nickname}
src={currentNetwork?.rpcPrefs?.imageUrl}
backgroundColor={testNetworkBackgroundColor}
className="token-list__token_component__network-badge"
gambinish marked this conversation as resolved.
Show resolved Hide resolved
/>
}
marginRight={4}
gambinish marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import TokenList from './token-list.component';

export default {
title: 'Components/App/TokenList',
component: TokenList,
argTypes: {
tokens: {
control: 'array',
},
results: {
control: 'array',
},
selectedTokens: {
control: 'object',
},
onToggleToken: {
action: 'onToggleToken',
},
currentNetwork: {
control: 'object',
},
testNetworkBackgroundColor: {
control: 'object',
},
},
} as Meta<typeof TokenList>;

const Template = (args: any) => <TokenList {...args} />;

export const Default = Template.bind({});
Default.args = {
currentNetwork: {
name: 'Ethereum',
chainId: 1,
nickname: 'Ethereum',
rpcPrefs: {
imageUrl: './images/eth_logo.svg',
},
},
selectedTokens: {
'0x9f9d0248bc87bee3ef76f9bb46aaaa01d80cc339': true,
},
results: [
{
symbol: 'ETH',
name: 'Ethereum',
address: '0x9f9d0248bc87bee3ef76f9bb46aaaa01d80cc339',
iconUrl: './images/eth_logo.svg',
},
{
symbol: 'DAI',
name: 'Dai Stablecoin',
address: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
iconUrl: 'https://static.cx.metamask.io/api/v1/tokenIcons/1/0x6b175474e89094c44da98b954eedeac495271d0f.png',
},
{
symbol: 'XYZ',
name: 'XYZ Token',
address: '0x1234567890abcdef',
iconUrl: 'https://example.com/xyz.png',
},
],
};

export const ShowTokenListPlaceholder = Template.bind({});
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const AccountOverviewTabs = ({
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);

const tabPadding = 4;
const tabProps = useMemo(
() => ({
activeClassName: 'account-overview__tab--active',
Expand Down Expand Up @@ -128,7 +127,7 @@ export const AccountOverviewTabs = ({
///: END:ONLY_INCLUDE_IF

return (
<Box style={{ flexGrow: '1' }} paddingTop={tabPadding}>
<Box style={{ flexGrow: '1' }}>
<Tabs
defaultActiveTabKey={defaultHomeActiveTabName}
onTabClick={handleTabClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ exports[`TokenListItem should render correctly 1`] = `
data-testid="multichain-token-list-item"
>
<a
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-4 mm-box--display-flex mm-box--flex-direction-row"
class="mm-box multichain-token-list-item__container-cell multichain-token-list-item__container-cell--clickable mm-box--padding-top-2 mm-box--padding-right-4 mm-box--padding-bottom-2 mm-box--padding-left-4 mm-box--display-flex mm-box--flex-direction-row"
data-testid="multichain-token-list-button"
href="#"
>
<div
class="mm-box mm-badge-wrapper multichain-token-list-item__badge mm-box--margin-right-3 mm-box--display-inline-block"
class="mm-box mm-badge-wrapper multichain-token-list-item__badge mm-box--margin-right-4 mm-box--display-inline-block"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-md mm-avatar-token mm-text--body-sm mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-border-default box--border-style-solid box--border-width-1"
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-md mm-avatar-token mm-text--body-sm mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full"
>
?
</div>
<div
class="mm-box mm-badge-wrapper__badge-container mm-badge-wrapper__badge-container--circular-top-right"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-border-muted box--border-style-solid box--border-width-1"
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<img
alt="network logo"
Expand Down
34 changes: 15 additions & 19 deletions ui/components/multichain/token-list-item/token-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
AlignItems,
BackgroundColor,
BlockSize,
BorderColor,
Display,
FlexDirection,
FontWeight,
Expand Down Expand Up @@ -46,7 +45,6 @@ import {
getMultichainCurrentChainId,
getMultichainCurrentNetwork,
getMultichainIsEvm,
getMultichainNativeCurrencyImage,
} from '../../../selectors/multichain';
import Tooltip from '../../ui/tooltip';
import { useI18nContext } from '../../../hooks/useI18nContext';
Expand Down Expand Up @@ -82,7 +80,6 @@ export const TokenListItem = ({
}) => {
const t = useI18nContext();
const isEvm = useSelector(getMultichainIsEvm);
const primaryTokenImage = useSelector(getMultichainNativeCurrencyImage);
const trackEvent = useContext(MetaMetricsContext);
const chainId = useSelector(getMultichainCurrentChainId);
const metaMetricsId = useSelector(getMetaMetricsId);
Expand Down Expand Up @@ -128,11 +125,10 @@ export const TokenListItem = ({
as="button"
backgroundColor={BackgroundColor.transparent}
data-testid={`staking-entrypoint-${chainId}`}
display={Display.InlineFlex}
flexDirection={FlexDirection.Row}
alignItems={AlignItems.center}
gap={1}
paddingInline={0}
paddingInlineStart={1}
paddingInlineEnd={1}
tabIndex="0"
onClick={(e) => {
e.preventDefault();
Expand All @@ -159,7 +155,13 @@ export const TokenListItem = ({
}}
>
<Text as="span">•</Text>
<Text as="span" color={TextColor.primaryDefault}>
<Text
as="span"
color={TextColor.primaryDefault}
paddingInlineStart={1}
paddingInlineEnd={1}
fontWeight={FontWeight.Medium}
>
{t('stake')}
</Text>
<Icon
Expand Down Expand Up @@ -189,7 +191,10 @@ export const TokenListItem = ({
})}
display={Display.Flex}
flexDirection={FlexDirection.Row}
padding={4}
paddingTop={2}
paddingBottom={2}
paddingLeft={4}
paddingRight={4}
data-testid="multichain-token-list-button"
{...(onClick && {
as: 'a',
Expand Down Expand Up @@ -222,21 +227,12 @@ export const TokenListItem = ({
name={currentNetwork?.nickname}
src={currentNetwork?.rpcPrefs?.imageUrl}
backgroundColor={testNetworkBackgroundColor}
borderColor={
primaryTokenImage
? BorderColor.borderMuted
: BorderColor.borderDefault
}
/>
}
marginRight={3}
marginRight={4}
className="multichain-token-list-item__badge"
>
<AvatarToken
name={tokenSymbol}
src={tokenImage}
borderColor={tokenImage ? undefined : BorderColor.borderDefault}
/>
<AvatarToken name={tokenSymbol} src={tokenImage} />
</BadgeWrapper>
<Box
className="multichain-token-list-item__container-cell--text-container"
Expand Down
Loading