Change default token icon

This commit is contained in:
Willian Mitsuda 2021-11-26 05:13:23 -03:00
parent 1431b449cc
commit 380ef96225
2 changed files with 12 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,32 +1,31 @@
import React, { Suspense, useContext } from "react";
import React, { useContext } from "react";
import { useImage } from "react-image";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
import { tokenLogoURL } from "../url";
import { RuntimeContext } from "../useRuntime";
import { ChecksummedAddress } from "../types";
type TokenLogoProps = {
address: string;
address: ChecksummedAddress;
name: string;
};
const TokenLogo: React.FC<TokenLogoProps> = (props) => (
<Suspense fallback={null}>
<InternalTokenLogo {...props} />
</Suspense>
);
const InternalTokenLogo: React.FC<TokenLogoProps> = ({ address, name }) => {
const TokenLogo: React.FC<TokenLogoProps> = ({ address, name }) => {
const { config } = useContext(RuntimeContext);
const srcList: string[] = [];
if (config) {
srcList.push(tokenLogoURL(config.assetsURLPrefix ?? "", address));
}
srcList.push("/eth-diamond-black.png");
const { src } = useImage({ srcList });
const { src, isLoading } = useImage({ srcList, useSuspense: false });
return (
<div className="flex items-center justify-center w-5 h-5">
<div className="flex items-center justify-center text-gray-400 w-5 h-5">
{src && (
<img className="max-w-full max-h-full" src={src} alt={`${name} logo`} />
)}
{!src && !isLoading && <FontAwesomeIcon icon={faCoins} size="1x" />}
</div>
);
};