From 63a3de6768198d05af6a876c7319ccc331b1539a Mon Sep 17 00:00:00 2001 From: ryanml Date: Wed, 18 Jan 2023 15:39:15 -0700 Subject: [PATCH] Various NFT UI fixes (#17153) * Various NFT UI fixes * Addressing review feedback * Using ButtonIcon component for copy icon * Using button for collectible item --- .../collectible-default-image.js | 6 +- .../collectible-details.js | 60 ++++++++++++------- .../app/collectible-details/index.scss | 6 +- .../collectibles-items/collectibles-items.js | 9 ++- .../app/collectibles-items/index.scss | 2 +- ui/components/ui/form-field/form-field.js | 2 +- 6 files changed, 53 insertions(+), 32 deletions(-) diff --git a/ui/components/app/collectible-default-image/collectible-default-image.js b/ui/components/app/collectible-default-image/collectible-default-image.js index c301c2c2c..c1206307d 100644 --- a/ui/components/app/collectible-default-image/collectible-default-image.js +++ b/ui/components/app/collectible-default-image/collectible-default-image.js @@ -11,8 +11,10 @@ export default function CollectibleDefaultImage({ handleImageClick, }) { const t = useI18nContext(); + const Tag = handleImageClick ? 'button' : 'div'; return ( -
{name ?? t('unknownCollection')}
#{tokenId} -
+ ); } diff --git a/ui/components/app/collectible-details/collectible-details.js b/ui/components/app/collectible-details/collectible-details.js index 546986da7..1f0212c3c 100644 --- a/ui/components/app/collectible-details/collectible-details.js +++ b/ui/components/app/collectible-details/collectible-details.js @@ -7,6 +7,7 @@ import { isEqual } from 'lodash'; import Box from '../../ui/box'; import Card from '../../ui/card'; import Typography from '../../ui/typography/typography'; +import { ButtonIcon, ICON_NAMES } from '../../component-library'; import { COLORS, TYPOGRAPHY, @@ -26,7 +27,6 @@ import { getSelectedIdentity, } from '../../../selectors'; import AssetNavigation from '../../../pages/asset/components/asset-navigation'; -import Copy from '../../ui/icon/copy-icon.component'; import { getCollectibleContracts } from '../../../ducks/metamask/metamask'; import { DEFAULT_ROUTE, SEND_ROUTE } from '../../../helpers/constants/routes'; import { @@ -67,7 +67,8 @@ export default function CollectibleDetails({ collectible }) { const ipfsGateway = useSelector(getIpfsGateway); const collectibleContracts = useSelector(getCollectibleContracts); const currentNetwork = useSelector(getCurrentChainId); - const [copied, handleCopy] = useCopyToClipboard(); + const [sourceCopied, handleSourceCopy] = useCopyToClipboard(); + const [addressCopied, handleAddressCopy] = useCopyToClipboard(); const collectibleContractName = collectibleContracts.find( ({ address: contractAddress }) => @@ -80,6 +81,7 @@ export default function CollectibleDetails({ collectible }) { imageOriginal ?? image, ipfsGateway, ); + const isDataURI = collectibleImageURL.startsWith('data:'); const onRemove = () => { dispatch(removeAndIgnoreNft(address, tokenId)); @@ -239,23 +241,39 @@ export default function CollectibleDetails({ collectible }) { {t('source')} - - {collectibleImageURL} - + {isDataURI ? ( + <>{collectibleImageURL} + ) : ( + + {collectibleImageURL} + + )} + { + handleSourceCopy(collectibleImageURL); + }} + iconName={ + sourceCopied + ? ICON_NAMES.COPY_SUCCESS_FILLED + : ICON_NAMES.COPY_FILLED + } + /> - + iconName={ + addressCopied + ? ICON_NAMES.COPY_SUCCESS_FILLED + : ICON_NAMES.COPY_FILLED + } + /> {inPopUp ? renderSendButton() : null} diff --git a/ui/components/app/collectible-details/index.scss b/ui/components/app/collectible-details/index.scss index 44cad6eb5..aa059e216 100644 --- a/ui/components/app/collectible-details/index.scss +++ b/ui/components/app/collectible-details/index.scss @@ -68,6 +68,7 @@ $spacer-break-small: 16px; cursor: pointer; color: var(--color-text-alternative); border: 0; + margin-top: -4px; &:active { transform: scale(0.97); @@ -78,13 +79,14 @@ $spacer-break-small: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + width: 332px; } - &__image-link { + &__image-source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - max-width: 332px; + width: 332px; } &__link-title { diff --git a/ui/components/app/collectibles-items/collectibles-items.js b/ui/components/app/collectibles-items/collectibles-items.js index d4d7d9d51..f28006ae0 100644 --- a/ui/components/app/collectibles-items/collectibles-items.js +++ b/ui/components/app/collectibles-items/collectibles-items.js @@ -164,8 +164,7 @@ export default function CollectiblesItems({ {`${collectionName ?? t('unknownCollection')} (${ collectibles.length @@ -203,18 +202,18 @@ export default function CollectiblesItems({ className="collectibles-items__item-wrapper__card" > {collectibleImage ? ( -
-
+ ) : ( {TitleTextCustomComponent || (titleText && (