2022-06-30 17:46:38 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import Typography from '../../ui/typography';
|
2023-02-02 21:15:26 +01:00
|
|
|
import { TypographyVariant } from '../../../helpers/constants/design-system';
|
2022-06-30 17:46:38 +02:00
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
export default function NftDefaultImage({ name, tokenId, handleImageClick }) {
|
2022-06-30 17:46:38 +02:00
|
|
|
const t = useI18nContext();
|
2023-01-18 23:39:15 +01:00
|
|
|
const Tag = handleImageClick ? 'button' : 'div';
|
2022-06-30 17:46:38 +02:00
|
|
|
return (
|
2023-01-18 23:39:15 +01:00
|
|
|
<Tag
|
|
|
|
tabIndex={0}
|
2023-02-16 20:23:29 +01:00
|
|
|
data-testid="nft-default-image"
|
|
|
|
className={classnames('nft-default', {
|
|
|
|
'nft-default--clickable': handleImageClick,
|
2022-06-30 17:46:38 +02:00
|
|
|
})}
|
|
|
|
onClick={handleImageClick}
|
|
|
|
>
|
2023-02-16 20:23:29 +01:00
|
|
|
<Typography variant={TypographyVariant.H6} className="nft-default__text">
|
2022-06-30 17:46:38 +02:00
|
|
|
{name ?? t('unknownCollection')} <br /> #{tokenId}
|
|
|
|
</Typography>
|
2023-01-18 23:39:15 +01:00
|
|
|
</Tag>
|
2022-06-30 17:46:38 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-16 20:23:29 +01:00
|
|
|
NftDefaultImage.propTypes = {
|
2022-06-30 17:46:38 +02:00
|
|
|
/**
|
2023-02-16 20:23:29 +01:00
|
|
|
* The name of the NFT collection if not supplied will default to "Unnamed collection"
|
2022-06-30 17:46:38 +02:00
|
|
|
*/
|
|
|
|
name: PropTypes.string,
|
|
|
|
/**
|
2023-02-16 20:23:29 +01:00
|
|
|
* The token id of the nft
|
2022-06-30 17:46:38 +02:00
|
|
|
*/
|
|
|
|
tokenId: PropTypes.string,
|
|
|
|
/**
|
2023-02-16 20:23:29 +01:00
|
|
|
* The click handler for the NFT default image
|
2022-06-30 17:46:38 +02:00
|
|
|
*/
|
|
|
|
handleImageClick: PropTypes.func,
|
|
|
|
};
|