-
Notifications
You must be signed in to change notification settings - Fork 559
[TOOL-4802] NFT Asset Page #7332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Fix `NFTMetadata` type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use client"; | ||
import { Suspense } from "react"; | ||
import { ClientOnly } from "../../components/ClientOnly/ClientOnly"; | ||
import { useIsMobile } from "../hooks/use-mobile"; | ||
|
||
export function ResponsiveLayout(props: { | ||
desktop: React.ReactNode; | ||
mobile: React.ReactNode; | ||
fallback: React.ReactNode; | ||
debugMode?: boolean; | ||
}) { | ||
const isMobile = useIsMobile(); | ||
|
||
if (props.debugMode) { | ||
return props.fallback; | ||
} | ||
|
||
return ( | ||
<Suspense fallback={props.fallback}> | ||
<ClientOnly ssr={props.fallback}> | ||
{isMobile ? props.mobile : props.desktop} | ||
</ClientOnly> | ||
</Suspense> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { MediaRenderer, type MediaRendererProps } from "thirdweb/react"; | ||
import { cn } from "../../lib/utils"; | ||
import { Skeleton } from "../ui/skeleton"; | ||
|
||
export function CustomMediaRenderer(props: MediaRendererProps) { | ||
const [loadedSrc, setLoadedSrc] = useState<string | undefined>(undefined); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
useEffect(() => { | ||
if (loadedSrc && loadedSrc !== props.src) { | ||
setLoadedSrc(undefined); | ||
} | ||
}, [loadedSrc, props.src]); | ||
|
||
return ( | ||
<div | ||
className="relative" | ||
onLoad={() => { | ||
if (props.src) { | ||
setLoadedSrc(props.src); | ||
} | ||
}} | ||
> | ||
{!loadedSrc && <Skeleton className="absolute inset-0" />} | ||
<MediaRenderer | ||
{...props} | ||
className={cn( | ||
props.className, | ||
"[&>div]:!bg-accent [&_a]:!text-muted-foreground [&_a]:!no-underline [&_svg]:!size-6 [&_svg]:!text-muted-foreground relative z-10", | ||
)} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 11 additions & 3 deletions
14
.../(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/PageHeader.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...[chain_id]/[contractAddress]/public-pages/_components/supply-claimed-progress.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { Meta, StoryObj } from "@storybook/nextjs"; | ||
import { maxUint256 } from "thirdweb/utils"; | ||
import { BadgeContainer } from "../../../../../../../../stories/utils"; | ||
import { SupplyClaimedProgress } from "./supply-claimed-progress"; | ||
|
||
const meta = { | ||
title: "Assets/NFT/SupplyClaimedProgress", | ||
component: StoryVariants, | ||
} satisfies Meta<typeof StoryVariants>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Variants: Story = { | ||
args: {}, | ||
}; | ||
|
||
function StoryVariants() { | ||
return ( | ||
<div className="container max-w-md space-y-10 py-10"> | ||
<BadgeContainer label="10 / Unlimited Supply"> | ||
<SupplyClaimedProgress claimedSupply={10n} totalSupply={maxUint256} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="500/1000 Supply"> | ||
<SupplyClaimedProgress claimedSupply={500n} totalSupply={1000n} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="10/1M Supply"> | ||
<SupplyClaimedProgress claimedSupply={10n} totalSupply={1000000n} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="0/1M Supply"> | ||
<SupplyClaimedProgress claimedSupply={0n} totalSupply={1000000n} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="10/10 Supply"> | ||
<SupplyClaimedProgress claimedSupply={10n} totalSupply={10n} /> | ||
</BadgeContainer> | ||
|
||
<BadgeContainer label="0 Supply - don't show anything"> | ||
<SupplyClaimedProgress claimedSupply={0n} totalSupply={0n} /> | ||
</BadgeContainer> | ||
</div> | ||
); | ||
} |
50 changes: 50 additions & 0 deletions
50
...(chain)/[chain_id]/[contractAddress]/public-pages/_components/supply-claimed-progress.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Progress } from "@/components/ui/progress"; | ||
import { InfinityIcon } from "lucide-react"; | ||
import { maxUint256 } from "thirdweb/utils"; | ||
import { supplyFormatter } from "../nft/format"; | ||
|
||
export function SupplyClaimedProgress(props: { | ||
claimedSupply: bigint; | ||
totalSupply: bigint; | ||
}) { | ||
// if total supply is unlimited | ||
if (props.totalSupply === maxUint256) { | ||
return ( | ||
<p className="flex items-center justify-between gap-2"> | ||
<span className="font-medium text-sm">Claimed Supply </span> | ||
<span className="flex items-center gap-1 font-bold text-sm"> | ||
{supplyFormatter.format(props.claimedSupply)} /{" "} | ||
<InfinityIcon className="size-4" aria-label="Unlimited" /> | ||
</span> | ||
</p> | ||
); | ||
} | ||
|
||
// if total supply is 0 - don't show anything | ||
if (props.totalSupply === 0n) { | ||
return null; | ||
} | ||
|
||
// multiply by 10k to have precision up to 2 decimal places in percentage value | ||
const soldFractionTimes10KBigInt = | ||
(props.claimedSupply * 10000n) / props.totalSupply; | ||
|
||
const soldPercentage = Number(soldFractionTimes10KBigInt) / 100; | ||
jnsdls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<div className="space-y-2"> | ||
<div className="flex items-center justify-between"> | ||
<span className="font-medium text-sm">Supply Claimed</span> | ||
<span className="font-bold text-sm"> | ||
{supplyFormatter.format(props.claimedSupply)} /{" "} | ||
{supplyFormatter.format(props.totalSupply)} | ||
</span> | ||
</div> | ||
<Progress value={soldPercentage} className="h-2.5" /> | ||
<p className="font-medium text-muted-foreground text-xs"> | ||
{soldPercentage === 0 && props.claimedSupply !== 0n && "~"} | ||
{soldPercentage.toFixed(2)}% Sold | ||
</p> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.