Skip to content

Commit ccff347

Browse files
committed
Migrate Marketplace Listing Stats on Contract Overview page to shadcn+tailwind (#5040)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring components in the `MarketplaceDetails.tsx` and `listing-stats.tsx` files to replace instances of the `Flex` component with standard `div` elements, while also introducing a new `StatCard` component for displaying statistics. ### Detailed summary - Replaced `Flex` components with `div` elements in `DirectListingCards`, `EnglishAuctionCards`, and `MarketplaceDetails`. - Introduced a new `StatCard` component in `listing-stats.tsx` for displaying statistics. - Updated the rendering of total listings, direct listings, and English auctions to use `StatCard`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 0cf478e commit ccff347

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/components/MarketplaceDetails.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { WalletAddress } from "@/components/blocks/wallet-address";
22
import {
3-
Flex,
43
GridItem,
54
SimpleGrid,
65
Skeleton,
@@ -84,7 +83,7 @@ const DirectListingCards: React.FC<ListingCardsSectionProps> = ({
8483

8584
return (
8685
<>
87-
<Flex align="center" justify="space-between" w="full">
86+
<div className="flex w-full items-center justify-between">
8887
<h2 className="font-semibold text-2xl tracking-tight">
8988
Direct Listing
9089
</h2>
@@ -100,7 +99,7 @@ const DirectListingCards: React.FC<ListingCardsSectionProps> = ({
10099
>
101100
View all -&gt;
102101
</TrackedLink>
103-
</Flex>
102+
</div>
104103
<ListingCards
105104
listings={listings}
106105
isPending={listingsQuery.isPending}
@@ -151,7 +150,7 @@ const EnglishAuctionCards: React.FC<ListingCardsSectionProps> = ({
151150

152151
return (
153152
<>
154-
<Flex align="center" justify="space-between" w="full">
153+
<div className="flex w-full items-center justify-between">
155154
<Heading size="label.lg">English Auctions</Heading>
156155
<TrackedLink
157156
category={trackingCategory}
@@ -165,7 +164,7 @@ const EnglishAuctionCards: React.FC<ListingCardsSectionProps> = ({
165164
>
166165
View all -&gt;
167166
</TrackedLink>
168-
</Flex>
167+
</div>
169168
<ListingCards
170169
listings={auctions}
171170
isPending={auctionsQuery.isPending}
@@ -193,28 +192,30 @@ export const MarketplaceDetails: React.FC<MarketplaceDetailsVersionProps> = ({
193192
chainSlug,
194193
}) => {
195194
return (
196-
<Flex gap={6} flexDirection="column">
197-
<Heading size="title.sm">Listings</Heading>
195+
<div className="flex flex-col gap-6">
196+
<h2 className="font-semibold text-2xl tracking-tight">Listings</h2>
198197
<ListingStatsV3
199198
contract={contract}
200199
hasDirectListings={hasDirectListings}
201200
hasEnglishAuctions={hasEnglishAuctions}
202201
/>
202+
203203
{hasDirectListings && contract && (
204204
<DirectListingCards
205205
contract={contract}
206206
trackingCategory={trackingCategory}
207207
chainSlug={chainSlug}
208208
/>
209209
)}
210+
210211
{hasEnglishAuctions && contract && (
211212
<EnglishAuctionCards
212213
contract={contract}
213214
trackingCategory={trackingCategory}
214215
chainSlug={chainSlug}
215216
/>
216217
)}
217-
</Flex>
218+
</div>
218219
);
219220
};
220221

@@ -298,7 +299,7 @@ const ListingCards: React.FC<ListingCardsProps> = ({
298299
/>
299300
</Skeleton>
300301
</div>
301-
<Flex p={4} pb={3} gap={1} direction="column">
302+
<div className="flex flex-col gap-1 p-4 pb-3">
302303
<Skeleton w={!isPending ? "100%" : "50%"} isLoaded={!isPending}>
303304
<Heading size="label.md">{listing.asset.metadata.name}</Heading>
304305
</Skeleton>
@@ -334,7 +335,7 @@ const ListingCards: React.FC<ListingCardsProps> = ({
334335
<b>{listing.currencyValue.displayValue}</b>{" "}
335336
{listing.currencyValue.symbol}
336337
</SkeletonText>
337-
</Flex>
338+
</div>
338339
</Card>
339340
</GridItem>
340341
))}

apps/dashboard/src/contract-ui/tabs/listings/components/listing-stats.tsx

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { Skeleton, Stat, StatLabel, StatNumber } from "@chakra-ui/react";
1+
import { SkeletonContainer } from "@/components/ui/skeleton";
22
import { useMemo } from "react";
33
import type { ThirdwebContract } from "thirdweb";
44
import { totalAuctions, totalListings } from "thirdweb/extensions/marketplace";
55
import { useReadContract } from "thirdweb/react";
6-
import { Card } from "tw-components";
76

87
const TotalListingsStat: React.FC<{ contract: ThirdwebContract }> = ({
98
contract,
@@ -20,16 +19,13 @@ const TotalListingsStat: React.FC<{ contract: ThirdwebContract }> = ({
2019
);
2120

2221
return (
23-
<Card as={Stat}>
24-
<StatLabel mb={{ base: 1, md: 0 }}>Total Listings</StatLabel>
25-
<Skeleton
26-
isLoaded={
27-
directListingsQuery.isSuccess && englishAuctionsQuery.isSuccess
28-
}
29-
>
30-
<StatNumber>{combinedListingCount.toString()}</StatNumber>
31-
</Skeleton>
32-
</Card>
22+
<StatCard
23+
value={combinedListingCount.toString()}
24+
label="Total Listings"
25+
isPending={
26+
directListingsQuery.isPending || englishAuctionsQuery.isPending
27+
}
28+
/>
3329
);
3430
};
3531

@@ -41,12 +37,11 @@ const DirectListingsStat: React.FC<{ contract: ThirdwebContract }> = ({
4137
});
4238

4339
return (
44-
<Card as={Stat}>
45-
<StatLabel mb={{ base: 1, md: 0 }}>Direct Listings</StatLabel>
46-
<Skeleton isLoaded={directListingsQuery.isSuccess}>
47-
<StatNumber>{(directListingsQuery.data || 0n).toString()}</StatNumber>
48-
</Skeleton>
49-
</Card>
40+
<StatCard
41+
value={(directListingsQuery.data || 0n).toString()}
42+
isPending={directListingsQuery.isPending}
43+
label="Direct Listings"
44+
/>
5045
);
5146
};
5247

@@ -58,12 +53,11 @@ const EnglishAuctionsStat: React.FC<{ contract: ThirdwebContract }> = ({
5853
});
5954

6055
return (
61-
<Card as={Stat}>
62-
<StatLabel mb={{ base: 1, md: 0 }}>English Auctions</StatLabel>
63-
<Skeleton isLoaded={englishAuctionsQuery.isSuccess}>
64-
<StatNumber>{(englishAuctionsQuery.data || 0n).toString()}</StatNumber>
65-
</Skeleton>
66-
</Card>
56+
<StatCard
57+
value={(englishAuctionsQuery.data || 0n).toString()}
58+
isPending={englishAuctionsQuery.isPending}
59+
label="English Auctions"
60+
/>
6761
);
6862
};
6963

@@ -79,7 +73,7 @@ export const ListingStatsV3: React.FC<ListingStatsV3Props> = ({
7973
hasEnglishAuctions,
8074
}) => {
8175
return (
82-
<div className="flex flex-row gap-3 md:gap-6">
76+
<div className="flex flex-row gap-3 md:gap-6 [&>*]:grow">
8377
{hasDirectListings && hasEnglishAuctions && contract && (
8478
<TotalListingsStat contract={contract} />
8579
)}
@@ -88,3 +82,20 @@ export const ListingStatsV3: React.FC<ListingStatsV3Props> = ({
8882
</div>
8983
);
9084
};
85+
86+
function StatCard(props: {
87+
value: string;
88+
isPending: boolean;
89+
label: string;
90+
}) {
91+
return (
92+
<dl className="block rounded-lg border border-border bg-muted/50 p-4">
93+
<dt className="mb-1.5 text-sm md:text-base">{props.label}</dt>
94+
<SkeletonContainer
95+
loadedData={props.isPending ? undefined : props.value}
96+
skeletonData={"0000"}
97+
render={(v) => <dd className="truncate font-semibold text-xl">{v}</dd>}
98+
/>
99+
</dl>
100+
);
101+
}

0 commit comments

Comments
 (0)