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

Add token icons #55

Merged
merged 9 commits into from
Feb 25, 2019
Merged

Add token icons #55

merged 9 commits into from
Feb 25, 2019

Conversation

unjapones
Copy link
Contributor

@unjapones unjapones commented Feb 21, 2019

Connects #11.

  • Refactor a little bit known tokens information and initialization (adds file to /src/common, /src/services and /src/util).
  • Add TokenIcon component to render an SVG, given a token symbol.

I might add some notes in the code for clarification.

Add services/known_tokens.
Update store/actions accordingly.
Update common/constants accordingly.
Add common token svg files (taken from 0x instant).
@unjapones
Copy link
Contributor Author

If you manually test this and check it in the browser, no icon will be visible while on "My Wallet" because the SVGs' main color seems to be white.

This needs styling, or some way to colorize the SVG elements (0x Instant seems to use a primary field/attribute for each token's metadata):

background_purple

@unjapones
Copy link
Contributor Author

Another thing, we could have some kind of fallback icon as seen in the designs (screenshot below): a component that renders the first 3 letters of the token's symbol with a coloured-circle background as in the mocks.

fallback

For now, TokenIcon renders the SVG, but it you think I should add this we can create a ticket or add it right into this PR.

@fvictorio
Copy link
Contributor

I like the idea of a fallback icon, and it shouldn't be too hard to do. @unjapones can you open an issue for that?

@Agupane
Copy link
Contributor

Agupane commented Feb 22, 2019

I agree with @fvictorio, fallback icons are a good Idea and should be considered in a new issue


const getTokenIconNameBySymbol = (symbol: string): string => {
const symbolfirstChar = symbol.charAt(0).toUpperCase();
const restOfSymbol = symbol.substring(1, symbol.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can drop the second argument here, the API is similar to that of Array.prototype.slice.


export const TokenIcon = (props: Props) => {
const { token } = props;
const TokenIconComponentName = getTokenIconNameBySymbol(token.symbol) as keyof typeof TokenIcons;
Copy link
Contributor

Choose a reason for hiding this comment

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

keyof typeof TokenIcons

mind = blown

} from '../util/token_meta_data';
import { Token } from '../util/types';

export class KnownTokens {
Copy link
Contributor

@fvictorio fvictorio Feb 22, 2019

Choose a reason for hiding this comment

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

Some thoughts on this.

First, can we move this to the util directory, based on what we talk about having pure/testable things there?

Second, it would be nice to make KNOWN_TOKENS_META_DATA a constructor parameter, so that this can be tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup agree with both items. Will work on that now.


export class KnownTokens {
private readonly _tokens: Token[] = [];
private readonly _wethToken: Token | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing something here, but I think there's no need to make this nullable. And the app shouldn't work without the weth token anyway.

Conflicts:
src/common/constants.ts
src/store/actions.ts
@unjapones unjapones merged commit d616c4d into 0xProject:development Feb 25, 2019
@unjapones unjapones deleted the add-token-icons branch March 1, 2019 16:03
birimbau pushed a commit to birimbau/VeriDex that referenced this pull request Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants