mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Various NFT UI fixes (#17153)
* Various NFT UI fixes * Addressing review feedback * Using ButtonIcon component for copy icon * Using button for collectible item
This commit is contained in:
parent
d99854baac
commit
63a3de6768
@ -11,8 +11,10 @@ export default function CollectibleDefaultImage({
|
|||||||
handleImageClick,
|
handleImageClick,
|
||||||
}) {
|
}) {
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
|
const Tag = handleImageClick ? 'button' : 'div';
|
||||||
return (
|
return (
|
||||||
<div
|
<Tag
|
||||||
|
tabIndex={0}
|
||||||
className={classnames('collectible-default', {
|
className={classnames('collectible-default', {
|
||||||
'collectible-default--clickable': handleImageClick,
|
'collectible-default--clickable': handleImageClick,
|
||||||
})}
|
})}
|
||||||
@ -21,7 +23,7 @@ export default function CollectibleDefaultImage({
|
|||||||
<Typography variant={TYPOGRAPHY.H6} className="collectible-default__text">
|
<Typography variant={TYPOGRAPHY.H6} className="collectible-default__text">
|
||||||
{name ?? t('unknownCollection')} <br /> #{tokenId}
|
{name ?? t('unknownCollection')} <br /> #{tokenId}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</Tag>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { isEqual } from 'lodash';
|
|||||||
import Box from '../../ui/box';
|
import Box from '../../ui/box';
|
||||||
import Card from '../../ui/card';
|
import Card from '../../ui/card';
|
||||||
import Typography from '../../ui/typography/typography';
|
import Typography from '../../ui/typography/typography';
|
||||||
|
import { ButtonIcon, ICON_NAMES } from '../../component-library';
|
||||||
import {
|
import {
|
||||||
COLORS,
|
COLORS,
|
||||||
TYPOGRAPHY,
|
TYPOGRAPHY,
|
||||||
@ -26,7 +27,6 @@ import {
|
|||||||
getSelectedIdentity,
|
getSelectedIdentity,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
import AssetNavigation from '../../../pages/asset/components/asset-navigation';
|
import AssetNavigation from '../../../pages/asset/components/asset-navigation';
|
||||||
import Copy from '../../ui/icon/copy-icon.component';
|
|
||||||
import { getCollectibleContracts } from '../../../ducks/metamask/metamask';
|
import { getCollectibleContracts } from '../../../ducks/metamask/metamask';
|
||||||
import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes';
|
import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes';
|
||||||
import {
|
import {
|
||||||
@ -67,7 +67,8 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
const ipfsGateway = useSelector(getIpfsGateway);
|
const ipfsGateway = useSelector(getIpfsGateway);
|
||||||
const collectibleContracts = useSelector(getCollectibleContracts);
|
const collectibleContracts = useSelector(getCollectibleContracts);
|
||||||
const currentNetwork = useSelector(getCurrentChainId);
|
const currentNetwork = useSelector(getCurrentChainId);
|
||||||
const [copied, handleCopy] = useCopyToClipboard();
|
const [sourceCopied, handleSourceCopy] = useCopyToClipboard();
|
||||||
|
const [addressCopied, handleAddressCopy] = useCopyToClipboard();
|
||||||
|
|
||||||
const collectibleContractName = collectibleContracts.find(
|
const collectibleContractName = collectibleContracts.find(
|
||||||
({ address: contractAddress }) =>
|
({ address: contractAddress }) =>
|
||||||
@ -80,6 +81,7 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
imageOriginal ?? image,
|
imageOriginal ?? image,
|
||||||
ipfsGateway,
|
ipfsGateway,
|
||||||
);
|
);
|
||||||
|
const isDataURI = collectibleImageURL.startsWith('data:');
|
||||||
|
|
||||||
const onRemove = () => {
|
const onRemove = () => {
|
||||||
dispatch(removeAndIgnoreNft(address, tokenId));
|
dispatch(removeAndIgnoreNft(address, tokenId));
|
||||||
@ -239,23 +241,39 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
{t('source')}
|
{t('source')}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
<Typography
|
||||||
color={COLORS.PRIMARY_DEFAULT}
|
|
||||||
variant={TYPOGRAPHY.H6}
|
variant={TYPOGRAPHY.H6}
|
||||||
boxProps={{
|
boxProps={{
|
||||||
margin: 0,
|
margin: 0,
|
||||||
marginBottom: 4,
|
marginBottom: 4,
|
||||||
}}
|
}}
|
||||||
className="collectible-details__image-link"
|
className="collectible-details__image-source"
|
||||||
|
color={isDataURI ? COLORS.TEXT_DEFAULT : COLORS.PRIMARY_DEFAULT}
|
||||||
>
|
>
|
||||||
<a
|
{isDataURI ? (
|
||||||
target="_blank"
|
<>{collectibleImageURL}</>
|
||||||
rel="noopener noreferrer"
|
) : (
|
||||||
href={collectibleImageURL}
|
<a
|
||||||
title={collectibleImageURL}
|
target="_blank"
|
||||||
>
|
rel="noopener noreferrer"
|
||||||
{collectibleImageURL}
|
href={collectibleImageURL}
|
||||||
</a>
|
title={collectibleImageURL}
|
||||||
|
>
|
||||||
|
{collectibleImageURL}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<ButtonIcon
|
||||||
|
ariaLabel="copy"
|
||||||
|
className="collectible-details__contract-copy-button"
|
||||||
|
onClick={() => {
|
||||||
|
handleSourceCopy(collectibleImageURL);
|
||||||
|
}}
|
||||||
|
iconName={
|
||||||
|
sourceCopied
|
||||||
|
? ICON_NAMES.COPY_SUCCESS_FILLED
|
||||||
|
: ICON_NAMES.COPY_FILLED
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.ROW}>
|
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.ROW}>
|
||||||
<Typography
|
<Typography
|
||||||
@ -301,18 +319,18 @@ export default function CollectibleDetails({ collectible }) {
|
|||||||
{inPopUp ? shortenAddress(address) : address}
|
{inPopUp ? shortenAddress(address) : address}
|
||||||
</a>
|
</a>
|
||||||
</Typography>
|
</Typography>
|
||||||
<button
|
<ButtonIcon
|
||||||
|
ariaLabel="copy"
|
||||||
className="collectible-details__contract-copy-button"
|
className="collectible-details__contract-copy-button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handleCopy(address);
|
handleAddressCopy(address);
|
||||||
}}
|
}}
|
||||||
>
|
iconName={
|
||||||
{copied ? (
|
addressCopied
|
||||||
t('copiedExclamation')
|
? ICON_NAMES.COPY_SUCCESS_FILLED
|
||||||
) : (
|
: ICON_NAMES.COPY_FILLED
|
||||||
<Copy size={15} color="var(--color-icon-alternative)" />
|
}
|
||||||
)}
|
/>
|
||||||
</button>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{inPopUp ? renderSendButton() : null}
|
{inPopUp ? renderSendButton() : null}
|
||||||
|
@ -68,6 +68,7 @@ $spacer-break-small: 16px;
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: var(--color-text-alternative);
|
color: var(--color-text-alternative);
|
||||||
border: 0;
|
border: 0;
|
||||||
|
margin-top: -4px;
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transform: scale(0.97);
|
transform: scale(0.97);
|
||||||
@ -78,13 +79,14 @@ $spacer-break-small: 16px;
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
width: 332px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__image-link {
|
&__image-source {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-width: 332px;
|
width: 332px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__link-title {
|
&__link-title {
|
||||||
|
@ -164,8 +164,7 @@ export default function CollectiblesItems({
|
|||||||
<Typography
|
<Typography
|
||||||
color={COLORS.TEXT_DEFAULT}
|
color={COLORS.TEXT_DEFAULT}
|
||||||
variant={TYPOGRAPHY.H5}
|
variant={TYPOGRAPHY.H5}
|
||||||
marginTop={0}
|
margin={2}
|
||||||
marginBottom={2}
|
|
||||||
>
|
>
|
||||||
{`${collectionName ?? t('unknownCollection')} (${
|
{`${collectionName ?? t('unknownCollection')} (${
|
||||||
collectibles.length
|
collectibles.length
|
||||||
@ -203,18 +202,18 @@ export default function CollectiblesItems({
|
|||||||
className="collectibles-items__item-wrapper__card"
|
className="collectibles-items__item-wrapper__card"
|
||||||
>
|
>
|
||||||
{collectibleImage ? (
|
{collectibleImage ? (
|
||||||
<div
|
<button
|
||||||
className="collectibles-items__item"
|
className="collectibles-items__item"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
}}
|
}}
|
||||||
|
onClick={handleImageClick}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
onClick={handleImageClick}
|
|
||||||
className="collectibles-items__item-image"
|
className="collectibles-items__item-image"
|
||||||
src={collectibleImage}
|
src={collectibleImage}
|
||||||
/>
|
/>
|
||||||
</div>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<CollectibleDefaultImage
|
<CollectibleDefaultImage
|
||||||
name={name}
|
name={name}
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__item {
|
&__item {
|
||||||
border-radius: 4px;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
@ -54,7 +54,7 @@ export default function FormField({
|
|||||||
<Box
|
<Box
|
||||||
className="form-field__heading-title"
|
className="form-field__heading-title"
|
||||||
display={DISPLAY.FLEX}
|
display={DISPLAY.FLEX}
|
||||||
alignItems={ALIGN_ITEMS.CENTER}
|
alignItems={ALIGN_ITEMS.BASELINE}
|
||||||
>
|
>
|
||||||
{TitleTextCustomComponent ||
|
{TitleTextCustomComponent ||
|
||||||
(titleText && (
|
(titleText && (
|
||||||
|
Loading…
Reference in New Issue
Block a user