Skip to content

Commit 9f4d270

Browse files
committed
refactor: global receive/send fixups
- remove fiat rates from global receive - add search by account index - adjust list item spacing - update help url in global receive - remove hover state of icon in select (network filter) and fix text color based on design
1 parent 0d013fb commit 9f4d270

File tree

8 files changed

+64
-39
lines changed

8 files changed

+64
-39
lines changed

packages/product-components/src/components/SelectAssetModal/SearchAsset.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ const SelectWrapper = styled.div`
1717
&:focus-within {
1818
border-color: transparent;
1919
}
20+
21+
&:hover .react-select__indicators {
22+
color: unset;
23+
}
24+
}
25+
26+
.react-select__single-value {
27+
color: ${({ theme }) => theme.textSubdued};
28+
}
29+
30+
.react-select__dropdown-indicator > svg {
31+
fill: ${({ theme }) => theme.iconSubdued};
32+
stroke: ${({ theme }) => theme.iconSubdued};
33+
}
34+
35+
&:hover .react-select__dropdown-indicator > svg {
36+
fill: ${({ theme }) => theme.iconSubdued};
37+
stroke: ${({ theme }) => theme.iconSubdued};
2038
}
2139
/* stylelint-enable selector-class-pattern */
2240
`;
Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { useMemo } from 'react';
2+
3+
import { getNetworkFeatures } from '@suite-common/wallet-config';
14
import { Account } from '@suite-common/wallet-types';
2-
import { Row, Text } from '@trezor/components';
5+
import { Column, Row, Text } from '@trezor/components';
36
import { CoinLogo } from '@trezor/product-components';
47
import { spacings } from '@trezor/theme';
58

69
import { AccountLabel } from 'src/components/suite/AccountLabel';
10+
import { Translation } from 'src/components/suite/Translation';
711

812
import { ItemClickableContainer } from '../ItemClickableContainer';
9-
import { AccountAmount } from './AccountAmount';
1013

1114
export type AssetRowReceiveToAccountProps = {
1215
account: Account;
@@ -19,21 +22,31 @@ export function AssetRowReceiveToAccount({
1922
account,
2023
onClick,
2124
}: AssetRowReceiveToAccountProps) {
25+
const supportsTokens = useMemo(
26+
() => getNetworkFeatures(account.symbol).includes('tokens'),
27+
[account.symbol],
28+
);
29+
2230
return (
2331
<ItemClickableContainer onClick={() => onClick(account)}>
2432
<Row data-testid={dataTestId} gap={spacings.sm} alignItems="center">
2533
<CoinLogo symbol={account.symbol} size={40} type="token" />
2634

27-
<Text variant="default" typographyStyle="body">
28-
<AccountLabel
29-
account={account}
30-
accountTypeBadgeSize="medium"
31-
showAccountTypeBadge={true}
32-
/>
33-
</Text>
35+
<Column alignItems="flex-start" justifyContent="flex-start">
36+
<Text variant="default" typographyStyle="body">
37+
<AccountLabel
38+
account={account}
39+
accountTypeBadgeSize="medium"
40+
showAccountTypeBadge={true}
41+
/>
42+
</Text>
43+
{supportsTokens && (
44+
<Text typographyStyle="hint" as="div" variant="tertiary">
45+
<Translation id="TR_INCLUDING_TOKENS" />
46+
</Text>
47+
)}
48+
</Column>
3449
</Row>
35-
36-
<AccountAmount account={account} />
3750
</ItemClickableContainer>
3851
);
3952
}

packages/suite/src/components/suite/asset-picker/components/AssetRow/ItemClickableContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ const ClickableContainer = styled.button`
88
background: unset;
99
box-shadow: unset;
1010
11-
width: 100%;
11+
width: calc(100% - ${spacings.xxs * 2}px);
1212
1313
cursor: pointer;
14-
padding: ${spacingsPx.sm} 0;
14+
padding: ${spacingsPx.xs} 0;
15+
margin: ${spacingsPx.xxs} ${spacingsPx.xxs};
1516
border-radius: 4px;
1617
transition: background-color 150ms ease-in-out;
1718

packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/GlobalSendReceive/GlobalReceiveModal/GlobalReceiveModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTheme } from 'styled-components';
55
import { Divider, Link, Row } from '@trezor/components';
66
import { EventType, analytics } from '@trezor/suite-analytics';
77
import { spacings } from '@trezor/theme';
8-
import { HELP_CENTER_VERIFY_TREZOR_SUITE_ADDRESSES_URL } from '@trezor/urls';
8+
import { HOW_TO_CHOOSE_RIGHT_NETWORK_URL } from '@trezor/urls';
99

1010
import {
1111
AssetRowReceiveToAccount,
@@ -65,7 +65,7 @@ export const GlobalReceiveModal = ({ onCancel, onSubmit }: GlobalReceiveModalPro
6565
color={theme.textSubdued}
6666
variant="underline"
6767
target="_blank"
68-
href={HELP_CENTER_VERIFY_TREZOR_SUITE_ADDRESSES_URL}
68+
href={HOW_TO_CHOOSE_RIGHT_NETWORK_URL}
6969
>
7070
{chunks}
7171
</Link>
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
import { useMemo } from 'react';
22
import { useThrottle } from 'react-use';
33

4-
import { selectAllAccountsToList, selectCurrentFiatRates } from '@suite-common/wallet-core';
4+
import { selectAllAccountsToList } from '@suite-common/wallet-core';
55
import { sortByCoin } from '@suite-common/wallet-utils';
6-
import { useCurrentRef } from '@trezor/react-utils';
76

87
import { ASSET_ROW_ACCOUNT_HEIGHT } from 'src/components/suite/asset-picker/components';
98
import { useSelector } from 'src/hooks/suite';
109

1110
export function useAccountsOptions() {
1211
const accounts = useSelector(selectAllAccountsToList);
13-
const fiatRates = useSelector(selectCurrentFiatRates);
14-
const fiatRatesRef = useCurrentRef(fiatRates);
1512
const throttledAccounts = useThrottle(accounts, 500);
1613

17-
return useMemo(() => {
18-
const fiatRates = fiatRatesRef.current;
19-
20-
if (!fiatRates) {
21-
return [];
22-
}
23-
24-
return sortByCoin(throttledAccounts).map(account => ({
25-
account,
26-
height: ASSET_ROW_ACCOUNT_HEIGHT,
27-
}));
28-
}, [throttledAccounts, fiatRatesRef]);
14+
return useMemo(
15+
() =>
16+
sortByCoin(throttledAccounts).map(account => ({
17+
account,
18+
height: ASSET_ROW_ACCOUNT_HEIGHT,
19+
})),
20+
[throttledAccounts],
21+
);
2922
}
3023

3124
export type AccountOption = ReturnType<typeof useAccountsOptions>[number];

packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/GlobalSendReceive/GlobalReceiveModal/hooks/useFilterAccounts.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ export function useFilterAccounts(accounts: AccountOption[]) {
1212

1313
return useMemo(
1414
() =>
15-
accounts
16-
.filter(account =>
17-
networkSymbol ? account.account.symbol === networkSymbol : true,
18-
)
19-
.filter(account => (search ? accountSearchFn(account.account, search) : true)),
15+
accounts.filter(account =>
16+
search ? accountSearchFn(account.account, search, networkSymbol) : true,
17+
),
2018
[accounts, networkSymbol, search],
2119
);
2220
}

packages/suite/src/support/messages.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,16 +3213,15 @@ export default defineMessages({
32133213
id: 'TR_RANDOM_SEED_WORDS_DISCLAIMER',
32143214
},
32153215
TR_RECEIVE: {
3216-
defaultMessage: 'Receive',
3216+
defaultMessage: 'Select an account to receive funds',
32173217
id: 'TR_RECEIVE',
32183218
},
32193219
TR_RECEIVE_SELECT_ACCOUNT: {
32203220
defaultMessage: 'Select an account to receive funds',
32213221
id: 'TR_RECEIVE_SELECT_ACCOUNT',
32223222
},
32233223
TR_RECEIVE_DESCRIPTION: {
3224-
defaultMessage:
3225-
'Tokens exist on multiple networks, so be sure to select the correct one. <a>Learn more</a>',
3224+
defaultMessage: 'How to <a>choose the right network</a> to receive your tokens',
32263225
id: 'TR_RECEIVE_DESCRIPTION',
32273226
},
32283227
TR_RECEIVE_SEARCH: {

suite-common/wallet-utils/src/accountUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,9 @@ export const accountSearchFn = (
931931
const searchString = rawSearchString?.trim().toLowerCase();
932932
if (!searchString) return true; // no search string
933933

934+
// Search by account number
935+
if (`#${account.index + 1}`.startsWith(searchString)) return true;
936+
934937
const network = networks[account.symbol];
935938

936939
// helper func for searching in account's addresses

0 commit comments

Comments
 (0)