Commit d3885474 authored by lynn's avatar lynn Committed by GitHub

feat: view my nft cards redesign (#5246)

* init

* link
parent 10a19638
...@@ -85,8 +85,11 @@ const useAssetMediaType = (asset: GenieAsset | WalletAsset) => ...@@ -85,8 +85,11 @@ const useAssetMediaType = (asset: GenieAsset | WalletAsset) =>
return assetMediaType return assetMediaType
}, [asset]) }, [asset])
const baseHref = (asset: GenieAsset | WalletAsset) => const baseHref = (asset: GenieAsset | WalletAsset) => {
'address' in asset ? `/#/nfts/asset/${asset.address}/${asset.tokenId}?origin=collection` : '/nfts/profile' if ('address' in asset) return `/#/nfts/asset/${asset.address}/${asset.tokenId}?origin=collection`
if ('asset_contract' in asset) return `/#/nfts/asset/${asset.asset_contract.address}/${asset.tokenId}?origin=profile`
return '/#/nfts/profile'
}
const DetailsLinkContainer = styled.a` const DetailsLinkContainer = styled.a`
display: flex; display: flex;
...@@ -486,29 +489,29 @@ const TruncatedTextRow = styled(Row)` ...@@ -486,29 +489,29 @@ const TruncatedTextRow = styled(Row)`
interface ProfileNftDetailsProps { interface ProfileNftDetailsProps {
asset: WalletAsset asset: WalletAsset
isSellMode: boolean hideDetails: boolean
} }
const ProfileNftDetails = ({ asset, isSellMode }: ProfileNftDetailsProps) => { const ProfileNftDetails = ({ asset, hideDetails }: ProfileNftDetailsProps) => {
const assetName = () => { const assetName = () => {
if (!asset.name && !asset.tokenId) return if (!asset.name && !asset.tokenId) return
return !!asset.name ? asset.name : `#${asset.tokenId}` return !!asset.name ? asset.name : `#${asset.tokenId}`
} }
const shouldShowUserListedPrice = const shouldShowUserListedPrice =
!!asset.floor_sell_order_price && !!asset.floor_sell_order_price && !asset.notForSale && asset.asset_contract.tokenType !== TokenType.ERC1155
!asset.notForSale &&
(asset.asset_contract.tokenType !== TokenType.ERC1155 || isSellMode)
const shouldShowFloorPrice = asset.notForSale && isSellMode && !!asset.floorPrice
return ( return (
<Box overflow="hidden" width="full" flexWrap="nowrap"> <Box overflow="hidden" width="full" flexWrap="nowrap">
<Row justifyItems="flex-start"> <PrimaryRow>
<TruncatedTextRow className={bodySmall} style={{ color: themeVars.colors.textSecondary }}> <PrimaryDetails>
{!!asset.asset_contract.name && <span>{asset.asset_contract.name}</span>} <TruncatedTextRow className={bodySmall} style={{ color: themeVars.colors.textSecondary }}>
</TruncatedTextRow> {!!asset.asset_contract.name && <span>{asset.asset_contract.name}</span>}
{asset.collectionIsVerified && <VerifiedIcon height="16px" width="16px" fill={colors.magentaVibrant} />} </TruncatedTextRow>
</Row> {asset.collectionIsVerified && <VerifiedIcon height="16px" width="16px" fill={colors.magentaVibrant} />}
</PrimaryDetails>
{!hideDetails && <DetailsLink />}
</PrimaryRow>
<Row justifyItems="flex-start"> <Row justifyItems="flex-start">
<TruncatedTextRow <TruncatedTextRow
className={subheadSmall} className={subheadSmall}
...@@ -525,11 +528,6 @@ const ProfileNftDetails = ({ asset, isSellMode }: ProfileNftDetailsProps) => { ...@@ -525,11 +528,6 @@ const ProfileNftDetails = ({ asset, isSellMode }: ProfileNftDetailsProps) => {
{`${floorFormatter(asset.floor_sell_order_price)} ETH`} {`${floorFormatter(asset.floor_sell_order_price)} ETH`}
</TruncatedTextRow> </TruncatedTextRow>
)} )}
{shouldShowFloorPrice && (
<TruncatedTextRow className={subhead} style={{ color: themeVars.colors.textSecondary }}>
{`${floorFormatter(asset.floorPrice)} ETH Floor`}
</TruncatedTextRow>
)}
</Box> </Box>
) )
} }
......
...@@ -51,7 +51,6 @@ export const ProfilePage = () => { ...@@ -51,7 +51,6 @@ export const ProfilePage = () => {
shallow shallow
) )
const sellAssets = useSellAsset((state) => state.sellAssets) const sellAssets = useSellAsset((state) => state.sellAssets)
const setSellPageState = useProfilePageState((state) => state.setProfilePageState) const setSellPageState = useProfilePageState((state) => state.setProfilePageState)
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
const isMobile = useIsMobile() const isMobile = useIsMobile()
...@@ -131,10 +130,10 @@ export const ProfilePage = () => { ...@@ -131,10 +130,10 @@ export const ProfilePage = () => {
? ownerAssets.map((asset, index) => ( ? ownerAssets.map((asset, index) => (
<div key={index}> <div key={index}>
<ViewMyNftsAsset <ViewMyNftsAsset
isSellMode
asset={asset} asset={asset}
mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia} mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia}
setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia} setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia}
hideDetails={sellAssets.length > 0}
/> />
</div> </div>
)) ))
......
...@@ -8,15 +8,12 @@ import { themeVars } from 'nft/css/sprinkles.css' ...@@ -8,15 +8,12 @@ import { themeVars } from 'nft/css/sprinkles.css'
import { useBag, useIsMobile, useSellAsset } from 'nft/hooks' import { useBag, useIsMobile, useSellAsset } from 'nft/hooks'
import { TokenType, WalletAsset } from 'nft/types' import { TokenType, WalletAsset } from 'nft/types'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useNavigate } from 'react-router-dom'
const NFT_DETAILS_HREF = (asset: WalletAsset) =>
`/nfts/asset/${asset.asset_contract.address}/${asset.tokenId}?origin=profile`
interface ViewMyNftsAssetProps { interface ViewMyNftsAssetProps {
asset: WalletAsset asset: WalletAsset
isSellMode: boolean
mediaShouldBePlaying: boolean mediaShouldBePlaying: boolean
setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void
hideDetails: boolean
} }
const getNftDisplayComponent = ( const getNftDisplayComponent = (
...@@ -36,9 +33,9 @@ const getNftDisplayComponent = ( ...@@ -36,9 +33,9 @@ const getNftDisplayComponent = (
export const ViewMyNftsAsset = ({ export const ViewMyNftsAsset = ({
asset, asset,
isSellMode,
mediaShouldBePlaying, mediaShouldBePlaying,
setCurrentTokenPlayingMedia, setCurrentTokenPlayingMedia,
hideDetails,
}: ViewMyNftsAssetProps) => { }: ViewMyNftsAssetProps) => {
const sellAssets = useSellAsset((state) => state.sellAssets) const sellAssets = useSellAsset((state) => state.sellAssets)
const selectSellAsset = useSellAsset((state) => state.selectSellAsset) const selectSellAsset = useSellAsset((state) => state.selectSellAsset)
...@@ -46,7 +43,6 @@ export const ViewMyNftsAsset = ({ ...@@ -46,7 +43,6 @@ export const ViewMyNftsAsset = ({
const cartExpanded = useBag((state) => state.bagExpanded) const cartExpanded = useBag((state) => state.bagExpanded)
const toggleCart = useBag((state) => state.toggleBag) const toggleCart = useBag((state) => state.toggleBag)
const isMobile = useIsMobile() const isMobile = useIsMobile()
const navigate = useNavigate()
const isSelected = useMemo(() => { const isSelected = useMemo(() => {
return sellAssets.some( return sellAssets.some(
...@@ -54,9 +50,7 @@ export const ViewMyNftsAsset = ({ ...@@ -54,9 +50,7 @@ export const ViewMyNftsAsset = ({
) )
}, [asset, sellAssets]) }, [asset, sellAssets])
const onCardClick = () => { const onCardClick = () => handleSelect(isSelected)
isSellMode ? handleSelect(isSelected) : navigate(NFT_DETAILS_HREF(asset))
}
const handleSelect = (removeAsset: boolean) => { const handleSelect = (removeAsset: boolean) => {
removeAsset ? removeSellAsset(asset) : selectSellAsset(asset) removeAsset ? removeSellAsset(asset) : selectSellAsset(asset)
...@@ -72,7 +66,7 @@ export const ViewMyNftsAsset = ({ ...@@ -72,7 +66,7 @@ export const ViewMyNftsAsset = ({
const assetMediaType = Card.useAssetMediaType(asset) const assetMediaType = Card.useAssetMediaType(asset)
const isDisabled = isSellMode && (asset.asset_contract.tokenType === TokenType.ERC1155 || asset.susFlag) const isDisabled = asset.asset_contract.tokenType === TokenType.ERC1155 || asset.susFlag
const disabledTooltipText = const disabledTooltipText =
asset.asset_contract.tokenType === TokenType.ERC1155 ? 'ERC-1155 support coming soon' : 'Blocked from trading' asset.asset_contract.tokenType === TokenType.ERC1155 ? 'ERC-1155 support coming soon' : 'Blocked from trading'
...@@ -101,7 +95,7 @@ export const ViewMyNftsAsset = ({ ...@@ -101,7 +95,7 @@ export const ViewMyNftsAsset = ({
{getNftDisplayComponent(assetMediaType, mediaShouldBePlaying, setCurrentTokenPlayingMedia)} {getNftDisplayComponent(assetMediaType, mediaShouldBePlaying, setCurrentTokenPlayingMedia)}
</Card.ImageContainer> </Card.ImageContainer>
<Card.DetailsContainer> <Card.DetailsContainer>
<Card.ProfileNftDetails asset={asset} isSellMode={isSellMode} /> <Card.ProfileNftDetails asset={asset} hideDetails={hideDetails} />
</Card.DetailsContainer> </Card.DetailsContainer>
</Card.Container> </Card.Container>
</MouseoverTooltip> </MouseoverTooltip>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment