From b2fe5bf5a8e331c50be19692ce3e2dd7843d028f Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Wed, 6 Nov 2024 11:43:27 -0500 Subject: [PATCH 1/2] fix: nft responsiveness --- src/nft/components/view/NFTImage.test.tsx | 13 ----- src/nft/components/view/NFTImage.tsx | 64 +++++++++++------------ src/nft/components/view/NFTVideo.tsx | 4 +- src/styles/theme.ts | 2 +- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/nft/components/view/NFTImage.test.tsx b/src/nft/components/view/NFTImage.test.tsx index 1996efc49b..206f0c8df7 100644 --- a/src/nft/components/view/NFTImage.test.tsx +++ b/src/nft/components/view/NFTImage.test.tsx @@ -1,6 +1,5 @@ import '@testing-library/jest-dom'; import { fireEvent, render, waitFor } from '@testing-library/react'; -import { act } from 'react'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; import { useNFTContext } from '../NFTProvider'; import { NFTImage } from './NFTImage'; @@ -88,18 +87,6 @@ describe('NFTImage', () => { ); }); - it('should hide the svg on transition end', async () => { - (useNFTContext as Mock).mockReturnValue({ - imageUrl: 'transitionend', - description: 'Test NFT Image', - }); - const { getByTestId, queryByTestId } = render(); - await act(async () => { - fireEvent.transitionEnd(getByTestId('ockNFTImage')); - }); - expect(queryByTestId('ock-defaultNFTSvg')).toBeNull(); - }); - it('should retry loading the image when retry button is clicked', async () => { (useNFTContext as Mock).mockReturnValue({ imageUrl: 'error', diff --git a/src/nft/components/view/NFTImage.tsx b/src/nft/components/view/NFTImage.tsx index 27f609c620..00404b925f 100644 --- a/src/nft/components/view/NFTImage.tsx +++ b/src/nft/components/view/NFTImage.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from 'react'; +import { type MouseEvent, useCallback, useEffect, useState } from 'react'; import { defaultNFTSvg } from '../../../internal/svg/defaultNFTSvg'; import { cn } from '../../../styles/theme'; import type { NFTError } from '../../types'; @@ -22,7 +22,6 @@ export function NFTImage({ const { imageUrl, description } = useNFTContext(); const [loaded, setLoaded] = useState(false); const [error, setError] = useState(false); - const [transitionEnded, setTransitionEnded] = useState(false); const loadImage = useCallback(() => { if (imageUrl) { @@ -50,48 +49,49 @@ export function NFTImage({ loadImage(); }, [loadImage]); - const handleRetry = useCallback(async () => { - setError(false); - loadImage(); - }, [loadImage]); - - const handleTransitionEnd = useCallback(() => { - setTransitionEnded(true); - }, []); + const handleRetry = useCallback( + async (e: MouseEvent) => { + e.stopPropagation(); + setError(false); + loadImage(); + }, + [loadImage], + ); return (
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', className, )} > +
{defaultNFTSvg}
+
+ {description} +
{error && ( -
-
)} - {!transitionEnded && ( -
- {defaultNFTSvg} -
- )} - {description}
); } diff --git a/src/nft/components/view/NFTVideo.tsx b/src/nft/components/view/NFTVideo.tsx index 1e43cf138b..e14d475147 100644 --- a/src/nft/components/view/NFTVideo.tsx +++ b/src/nft/components/view/NFTVideo.tsx @@ -49,7 +49,9 @@ export function NFTVideo({ return (
*]:col-start-1 [&>*]:col-end-1 [&>*]:row-start-1 [&>*]:row-end-1', + { 'content-center justify-center': !square }, className, )} > diff --git a/src/styles/theme.ts b/src/styles/theme.ts index 9b1f68d1c5..caac3f0e9b 100644 --- a/src/styles/theme.ts +++ b/src/styles/theme.ts @@ -13,7 +13,7 @@ export const text = { label1: 'ock-font-family font-semibold text-sm leading-5', label2: 'ock-font-family text-sm leading-5', legal: 'ock-font-family text-xs leading-4', - title1: 'ock-font-family font-semibold text-[1.75rem] leading-9', + title1: 'ock-font-family font-semibold text-2xl leading-9', title3: 'ock-font-family font-semibold text-xl leading-7', } as const; From 27c1c6ecb918cf314563e8be0d9bc769b8f169e6 Mon Sep 17 00:00:00 2001 From: Adam Lessey Date: Wed, 6 Nov 2024 14:20:58 -0500 Subject: [PATCH 2/2] fix: add changeset --- .changeset/clever-days-compete.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clever-days-compete.md diff --git a/.changeset/clever-days-compete.md b/.changeset/clever-days-compete.md new file mode 100644 index 0000000000..9c4d2bd722 --- /dev/null +++ b/.changeset/clever-days-compete.md @@ -0,0 +1,5 @@ +--- +'@coinbase/onchainkit': patch +--- + +-**fix**: Update `NFTCard` and `NFTMintCard` to be more responsive. By @alessey #1590