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

Feat/coinmarket crypto select #14551

Merged
merged 3 commits into from
Oct 1, 2024
Merged

Conversation

adderpositive
Copy link
Contributor

@adderpositive adderpositive commented Sep 26, 2024

Description

  • Replace Select with Select modal of assets in Swap & Buy
  • Search should allow to input crypto name, symbol, contract address or network name
    • Placeholder copy: Search by name or paste address
  • Networks filter: this works as radio button, only one can be selected and it’s static list, not all available networks will be listed
    • Ethereum
    • Polygon
    • Solana
    • BNB Smart Chain

Design

Before

In Buy section
image
In Exchange section
image

After

Screenshot 2024-10-01 at 12-57-59 Trade
image
image
Screenshot 2024-10-01 at 12 59 19 PM
image
Screenshot 2024-10-01 at 12 59 05 PM

Related

Resolve #14550

@adderpositive adderpositive added feature Product related issue visible for end user components Related to global components +Invity Related to Invity project labels Sep 26, 2024
@adderpositive adderpositive self-assigned this Sep 26, 2024
@adderpositive adderpositive force-pushed the feat/coinmarket-crypto-select branch 3 times, most recently from bab3e17 to 17c25c9 Compare September 26, 2024 12:47
Copy link
Member

@tomasklim tomasklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I believe All networks should be selected by default all the time

Screenshot 2024-09-26 at 14 52 27

  1. It is really weird that it is All networks 8 but I see just 4 networks next to it.

  2. You miss (8) parenthesis

@adderpositive
Copy link
Contributor Author

@tomasklim 2. & 3. are fixed. 1. Let's add it in the future. 🚀

@jvaclavik
Copy link
Contributor

Looks like it's not working in storybook:

yarn workspace @trezor/product-components storybook
image

a: CoinmarketCryptoSelectItemProps,
b: CoinmarketCryptoSelectItemProps,
) => {
const order = ['bitcoin', 'ethereum', 'litecoin', 'solana', 'cardano'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to earlier sorting based on the backend's response. Now there is no sorting on the backend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would sort it using order from networksConfig.

cc @Hannsek maybe we should also sort it somehow?
Screenshot 2024-09-27 at 16 24 12

Copy link
Contributor

@jvaclavik jvaclavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Houmi 👏

Comment on lines 7 to 14
const ColumnWrapper = styled.div<{ $height: string }>`
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: ${({ $height }) => $height};
min-height: 180px;
`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw you could do this with Column. We can add min-height there if you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added in this commit e30ec34. We can also create separate PR if necessary.


const ParagraphWrapper = styled.div`
max-width: 280px;
margin: 0 auto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about combine these margins?

margin: ${spacingsPx.xxxs} auto 0 auto;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

min-height: 180px;
`;

const ParagraphWrapper = styled.div`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure but you might use Paragraph component instead of Text + ParagraphWrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement! Done

};

// temporary styles, should be replaced in the future
const CheckableTag = styled.button<CheckableTagProps>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please extract this component and related logic to different file? 🙏 we will later refactor it to the design system

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done

import { FormattedMessage } from 'react-intl';

interface CheckableTagProps {
$variant: 'primary' | 'tertiary';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use it this way please? 🙏

export const tagVariants = ['primary', 'tertiary'] as const;
export type TagVariant = Extract<UIVariant, (typeof tagVariants)[number]>;

we use similar approach everywhere we use variants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks

onSelectAssetModal: (selectedAsset: string) => void;
onFavoriteClick: (isFavorite: boolean) => void;
};
const LIST_HEIGHT = 'calc(80vh - 267px)'; // 267px is height header part of modal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do it without comment please? 👍

Suggestion:

const HEADER_HEIGHT = 267
const LIST_HEIGHT = 'calc(80vh - ${HEADER_HEIGHT}px)';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

onFavoriteClick: (isFavorite: boolean) => void;
};
const LIST_HEIGHT = 'calc(80vh - 267px)'; // 267px is height header part of modal
const height = 60;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what does this mean. Maybe it's item height?

In that case I suggest:

const ITEM_HEIGHT = 60

Copy link
Contributor Author

@adderpositive adderpositive Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye, nice catch. Updated

name={name}
symbol={symbol}
isFavorite={isFavorite}
badge={badge}
logo={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: thinking that it would be more clear this way:

logo={<AssetLogo ... />}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +208 to +209
label: string; // token shortcut
cryptoName: string | undefined; // full name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to do it with self-explanatory props 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comment above
#14551 (comment)

@@ -113,7 +131,7 @@ export const CoinmarketFormInputCryptoSelect = <
}}
data-testid="@coinmarket/form/select-crypto"
isClearable={false}
isSearchable
menuIsOpen={false}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe could you please rename it toisMenuOpen? 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement. I have renamed it, but it is trezor component as well. I'm not sure it is related to this PR. Anyway it is in a separate commit - 0c30002

@adderpositive
Copy link
Contributor Author

@jvaclavik thank you for constructive feedback. FYI:

  • I have prepared LIST_MIN_HEIGHT which is passed to VirtualizedList and AssetItemNotFound to make a point to define it.
  • Storybook should be fixed.


const getNetworks = () => {
const eth = getNetwork('eth');
const polygon = getNetwork('matic');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is #14093 which renames the matic to pol. Should we use pol here instead of matic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of getting here those 4 networks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To show tabs
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After rebase, I will change it. )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not make any sense. In the table there is like 50 networks. Next to "all networks" we say some random number and then for some reason we show four random networks next to it.

Screenshot 2024-09-27 at 16 10 50

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next to All network is not a random number. It is the number of all available networks. Soon it would be nice to add some select as you showed to us in DMs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that there is Base but we do not offer filter for it :(

Screenshot 2024-09-27 at 16 21 04

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally understood, what you meant. :D Maybe we should change All networks to something like All token networks? What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use order from networksConfig. We will sort it before freeze

Copy link
Member

@tomasklim tomasklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just product issues, I will check the code on Monday

@@ -44,13 +53,21 @@ type VirtualizedListProps<T> = {
items: Array<T & { height: number }>;
onScroll?: (e: Event) => void;
onScrollEnd: () => void;
height: number | string;
listHeight: number | string;
listMinHeight: number | string;
renderItem: (item: T, index: number) => React.ReactNode;
};

export const VirtualizedList = forwardRef<HTMLDivElement, VirtualizedListProps<any>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The shadow at the bottom is over scrollbar
  2. scrollbar should probably not be over items
Screen.Recording.2024-09-27.at.16.14.26.mov

cc @jvaclavik

packages/suite/src/support/messages.ts Show resolved Hide resolved
packages/suite/src/support/messages.ts Show resolved Hide resolved
packages/suite/src/support/messages.ts Outdated Show resolved Hide resolved

const getNetworks = () => {
const eth = getNetwork('eth');
const polygon = getNetwork('matic');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that there is Base but we do not offer filter for it :(

Screenshot 2024-09-27 at 16 21 04

a: CoinmarketCryptoSelectItemProps,
b: CoinmarketCryptoSelectItemProps,
) => {
const order = ['bitcoin', 'ethereum', 'litecoin', 'solana', 'cardano'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would sort it using order from networksConfig.

cc @Hannsek maybe we should also sort it somehow?
Screenshot 2024-09-27 at 16 24 12

@tomasklim
Copy link
Member

tomasklim commented Sep 27, 2024

@marek-andrsk
Why tokens are sorted like that? OMG is first, it was delisted from Binance 3 months ago, that does not sound like that it should be on #1 place
Screenshot 2024-09-27 at 16 32 01

packages/suite/src/support/messages.ts Show resolved Hide resolved

const getNetworks = () => {
const eth = getNetwork('eth');
const polygon = getNetwork('matic');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use order from networksConfig. We will sort it before freeze

@tomasklim
Copy link
Member

It is not possible to get offer for Base, Optimism, Arbitrum

Copy link
Member

@tomasklim tomasklim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎸

Copy link
Contributor

@LukasRada LukasRada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve the conflict and good job :)

@tomasklim tomasklim merged commit 4bc84bf into develop Oct 1, 2024
16 of 22 checks passed
@tomasklim tomasklim deleted the feat/coinmarket-crypto-select branch October 1, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
components Related to global components feature Product related issue visible for end user +Invity Related to Invity project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coinmarket - Implement New crypto-picker modal
5 participants