-
Notifications
You must be signed in to change notification settings - Fork 316
feat: add view components #1483
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
b692955
to
c38f148
Compare
c38f148
to
64ebe5e
Compare
onLoading, | ||
onLoaded, | ||
onError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these just be onStatus
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd need to basically create a pseudo lifecycle status to change to onStatus. I could handle lifecycle status in the children, but I was trying to keep the mediaLoaded/success logic centralized in one place.
|
||
export function NFTLastSoldPrice({ | ||
className, | ||
label = 'Mint price', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we standardize on label
? we use text
in our other components
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label seems more flexible if you ever want to change from string to ReactNode
src/nft/components/view/NFTMedia.tsx
Outdated
if (mediaType.isVideo) { | ||
return ( | ||
<NFTVideo | ||
onLoading={handleLoading} | ||
onLoaded={handleLoaded} | ||
onError={handleError} | ||
/> | ||
); | ||
} | ||
|
||
if (mediaType.isAudio) { | ||
return ( | ||
<div className="relative w-full"> | ||
<NFTImage /> | ||
<div className="absolute bottom-[20px] mx-auto w-full"> | ||
<NFTAudio /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<NFTImage | ||
onLoading={handleLoading} | ||
onLoaded={handleLoaded} | ||
onError={handleError} | ||
/> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer a switch
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason? performance differences at this point are negligible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for performance but for > 2 cases ifl it's cleaner to just use a switch
compared to multiple if
statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely a nit though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, it made more sense when i switched to an enum anyways
src/nft/components/view/NFTMedia.tsx
Outdated
const mediaType = useMemo(() => { | ||
return { | ||
isVideo: mimeType?.startsWith('video'), | ||
isAudio: | ||
mimeType?.startsWith('audio') || mimeType?.startsWith('application'), | ||
isImage: mimeType?.startsWith('image'), | ||
}; | ||
}, [mimeType]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer returning an enum here rather than an object with always 2/3 null values
} as Record<string, ReactNode>; | ||
|
||
export function NFTNetwork({ className, label = 'Network' }: NFTNetworkProps) { | ||
const { chain } = useOnchainKit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should deprecate this top-level chain
prop, so I don't recommend using it here.
Is there any other way to tell which chain the NFT is on?
<circle cx="73" cy="73" r="73" fill="#0052FF" /> | ||
<path | ||
d="M73.323 123.729C101.617 123.729 124.553 100.832 124.553 72.5875C124.553 44.343 101.617 21.4463 73.323 21.4463C46.4795 21.4463 24.4581 42.0558 22.271 68.2887H89.9859V76.8864H22.271C24.4581 103.119 46.4795 123.729 73.323 123.729Z" | ||
fill="white" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the fill
always meant to be white here? Is the intention for it to NOT update based off of the current theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I didn't think the base logo should change
return ( | ||
<div | ||
className={cn( | ||
'flex items-center justify-between py-1', | ||
text.label2, | ||
className, | ||
)} | ||
> | ||
<div>{label}</div> | ||
<div>{formattedDate}</div> | ||
</div> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these divs are unnecessary and can be removed:
return ( | |
<div | |
className={cn( | |
'flex items-center justify-between py-1', | |
text.label2, | |
className, | |
)} | |
> | |
<div>{label}</div> | |
<div>{formattedDate}</div> | |
</div> | |
); | |
return ( | |
<div | |
className={cn( | |
'flex items-center justify-between py-1', | |
text.label2, | |
className, | |
)} | |
> | |
{label} | |
{formattedDate} | |
</div> | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since i'm flex space-between these divs are needed so the content is aligned left/right, otherwise they'd be treated as a single text node
return ( | ||
<div | ||
className={cn( | ||
'flex items-center justify-between py-1', | ||
text.label2, | ||
className, | ||
)} | ||
> | ||
<div>{label}</div> | ||
<div className="flex items-center gap-2"> | ||
<div className="h-4 w-4 object-cover">{networkMap[chain.name]}</div> | ||
<div>{chain.name}</div> | ||
</div> | ||
</div> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably can remove these divs that don't have styling:
return ( | |
<div | |
className={cn( | |
'flex items-center justify-between py-1', | |
text.label2, | |
className, | |
)} | |
> | |
<div>{label}</div> | |
<div className="flex items-center gap-2"> | |
<div className="h-4 w-4 object-cover">{networkMap[chain.name]}</div> | |
<div>{chain.name}</div> | |
</div> | |
</div> | |
); | |
return ( | |
<div | |
className={cn( | |
'flex items-center justify-between py-1', | |
text.label2, | |
className, | |
)} | |
> | |
{label} | |
<div className="flex items-center gap-2"> | |
<div className="h-4 w-4 object-cover">{networkMap[chain.name]}</div> | |
{chain.name} | |
</div> | |
</div> | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is possible, but I think its easier to see whats going on using an element as a flex-child vs. a text node.
className, | ||
)} | ||
> | ||
<div>{label}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div>{label}</div> | |
{label} |
videoRef.current.onerror = (error: string | Event) => { | ||
onError?.({ | ||
error: typeof error === 'string' ? error : error.type, | ||
code: 'NmNVc01', // NFT module NFTVideo component 01 error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add all of the possible error codes in a error / const file and reference from it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me revisit that at the end
src/nft/components/view/NFTImage.tsx
Outdated
|
||
const handleTransitionEnd = () => { | ||
setTransitionEnded(true); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but should this be useCallback just to keep consistent
onLoading?: (mediaUrl: string) => void; | ||
onLoaded?: () => void; | ||
onError?: (error: NFTError) => void; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit move to types file
type NFTLastSoldPriceProps = { | ||
className?: string; | ||
label?: ReactNode; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit move to types
type NFTMintDateProps = { | ||
className?: string; | ||
label?: ReactNode; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit move to types
What changed? Why?
Add nft view components
Notes to reviewers
How has it been tested?