mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Support redirect to a correct view from search * show domains on address page * migrate to new API version to display address domains * another api update * new design for chain widget on home page + tests * chain widget styles for mobile devices * ecosystems page * update types * add ecosystems to navigation * address portfolio: pt.1 * portfolio tokens list * filter portfolio by chain * skip redirect when navigating to search result by clicking on "show all results" link * net worth block design * add filter input to chain select and fix tokens table * calculate address portfolio * adjust card logic * support custom token types in multichain explorer * handle case when new worth is 0 * add text filter to tokens list * fixes * demo envs * portfolio tests * ecosystems test * change signature for getTokenTypes function * fix adding token to the wallet from the list * lazy load all address domains * show contract creator and implementations info * fix tests * add poor reputation tokens toggle * tweaks * dim celo native tokens * disable env validator * fix tests * remove tokens with 0 usd value from top tokens * fixes * preserve selected chain when switching tabs on address page * add hints to stats widgets on home page * update envs for demo * fix portfolio cards and home page * update styles for contract creator and implementations * fix select issues * add chains from cluster to network menu * hide csv export link on empty logs page * update screenshots * rollback select fix * update cut length calculation for portfolio cards * fix chain select * update screenshots * fix tests * more fixes * add sorting to ecosystems table * fix test * fixes * fix loading state in ecosystems page * review fixes * fix tests
82 lines
2.2 KiB
TypeScript
82 lines
2.2 KiB
TypeScript
import { upperFirst } from 'es-toolkit';
|
|
import React from 'react';
|
|
|
|
import type { MultichainProviderConfigParsed } from 'types/client/multichainProviderConfig';
|
|
|
|
import { route } from 'nextjs-routes';
|
|
|
|
import { Image } from 'toolkit/chakra/image';
|
|
import { Link } from 'toolkit/chakra/link';
|
|
import { Tooltip } from 'toolkit/chakra/tooltip';
|
|
import TextSeparator from 'ui/shared/TextSeparator';
|
|
|
|
import styles from './AddressMultichainButton.module.css';
|
|
|
|
const TEMPLATE_ADDRESS = '{address}';
|
|
|
|
type Props = {
|
|
item: MultichainProviderConfigParsed;
|
|
addressHash: string;
|
|
onClick?: () => void;
|
|
isFirst?: boolean;
|
|
isLast?: boolean;
|
|
};
|
|
|
|
const AddressMultichainButton = ({ item, addressHash, onClick, isFirst, isLast }: Props) => {
|
|
|
|
const isOnlyOne = isFirst && isLast;
|
|
|
|
const buttonIcon = (
|
|
<Image
|
|
src={ item.logoUrl }
|
|
alt={ item.name }
|
|
boxSize={ 5 }
|
|
mr={ isOnlyOne ? { base: 1, lg: 2 } : 0 }
|
|
borderRadius="4px"
|
|
overflow="hidden"
|
|
/>
|
|
);
|
|
|
|
const name = upperFirst(item.name.replaceAll('_', ' '));
|
|
|
|
const buttonContent = isOnlyOne ? (
|
|
<>
|
|
{ buttonIcon }
|
|
{ name }
|
|
</>
|
|
) : (
|
|
<Tooltip content={ name }>{ buttonIcon }</Tooltip>
|
|
);
|
|
|
|
try {
|
|
const portfolioUrlString = item.urlTemplate.replace(TEMPLATE_ADDRESS, addressHash);
|
|
const portfolioUrl = new URL(portfolioUrlString);
|
|
portfolioUrl.searchParams.append('utm_source', 'blockscout');
|
|
portfolioUrl.searchParams.append('utm_medium', 'address');
|
|
const dappId = item.dappId;
|
|
const isExternal = typeof dappId !== 'string';
|
|
|
|
return (
|
|
<>
|
|
<Link
|
|
className={ item.promo ? styles.promo : undefined }
|
|
external={ isExternal }
|
|
href={ isExternal ? portfolioUrl.toString() : route({ pathname: '/apps/[id]', query: { id: dappId, url: portfolioUrl.toString() } }) }
|
|
variant={ isOnlyOne ? 'underlaid' : undefined }
|
|
textStyle="sm"
|
|
fontWeight="medium"
|
|
onClick={ onClick }
|
|
noIcon={ !isOnlyOne }
|
|
>
|
|
{ buttonContent }
|
|
</Link>
|
|
{ item.promo && isFirst && !isLast && <TextSeparator mx={ 0 }/> }
|
|
</>
|
|
);
|
|
} catch (error) {}
|
|
|
|
return null;
|
|
};
|
|
|
|
export default AddressMultichainButton;
|