Skip to content

Commit

Permalink
Update nfts drawer tab to match design
Browse files Browse the repository at this point in the history
  • Loading branch information
serjonya-trili committed Oct 7, 2023
1 parent 5212e5c commit 3bdc795
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/components/AccountDrawer/AccountDrawerDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ describe("<AccountCard />", () => {
expect(screen.getByTestId("account-card-nfts-tab")).toBeInTheDocument();
screen.getByTestId("account-card-nfts-tab").click();
expect(screen.queryAllByTestId("account-card-nfts-tab")).toHaveLength(1);
expect(screen.getByText(mockNft.token.metadata?.name as string)).toBeInTheDocument();
});

it("should display accounts operations under operations tab if any", () => {
Expand Down
7 changes: 1 addition & 6 deletions src/components/AccountDrawer/AssetsPanel/AssetsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ export const AssetsPanel: React.FC<{
</TabPanel>

<TabPanel data-testid="account-card-nfts-tab" height="100%" overflow="hidden">
<NFTsGrid
nftsByOwner={{ [account.address.pkh]: nfts }}
showName={true}
columns={3}
spacing={5}
/>
<NFTsGrid nftsByOwner={{ [account.address.pkh]: nfts }} columns={3} spacing={5} />
</TabPanel>

<TabPanel data-testid="account-card-tokens-tab">
Expand Down
30 changes: 18 additions & 12 deletions src/components/AccountDrawer/AssetsPanel/NFTsGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import { AspectRatio, Heading, Image, SimpleGrid, SimpleGridProps } from "@chakra-ui/react";
import {
AspectRatio,
Card,
CardBody,
Image,
SimpleGrid,
SimpleGridProps,
} from "@chakra-ui/react";
import { every } from "lodash";
import { FC } from "react";
import { Link } from "react-router-dom";
import { RawPkh } from "../../../types/Address";
import { fullId, thumbnailUri } from "../../../types/Token";
import { NFTBalance } from "../../../types/TokenBalance";
import { truncate } from "../../../utils/format";
import { getIPFSurl } from "../../../utils/token/nftUtils";
import { NoNFTs } from "../../NoItems";
import colors from "../../../style/colors";

export const NFTsGrid: FC<
{ nftsByOwner: Record<RawPkh, NFTBalance[] | undefined>; showName?: boolean } & SimpleGridProps
> = ({ nftsByOwner, showName, ...rest }) => {
{ nftsByOwner: Record<RawPkh, NFTBalance[] | undefined> } & SimpleGridProps
> = ({ nftsByOwner, ...rest }) => {
const noNfts = every(nftsByOwner, nfts => !nfts || nfts.length === 0);
if (noNfts) {
return <NoNFTs small />;
Expand All @@ -25,14 +32,13 @@ export const NFTsGrid: FC<
const fallbackUrl = getIPFSurl(nft.displayUri);
return (
<Link to={`/nfts/${owner}/${fullId(nft)}`} key={`${owner}:${fullId(nft)}`}>
<AspectRatio width="100%" ratio={1}>
<Image width="100%" height={40} src={url} fallbackSrc={fallbackUrl} />
</AspectRatio>
{showName && nft.metadata.name && (
<Heading size="sm" mt={3}>
{truncate(nft.metadata.name, 12)}
</Heading>
)}
<Card bg={colors.gray[800]}>
<CardBody p="8px">
<AspectRatio width="100%" ratio={1}>
<Image width="100%" height={40} src={url} fallbackSrc={fallbackUrl} />
</AspectRatio>
</CardBody>
</Card>
</Link>
);
});
Expand Down

0 comments on commit 3bdc795

Please sign in to comment.