Skip to content

Commit

Permalink
fix: some small UI issues with the new unified market feature (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo authored Jun 1, 2023
1 parent 6402e83 commit d2b218e
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 202 deletions.
28 changes: 17 additions & 11 deletions webapp/src/components/AssetCard/AssetCard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('AssetCard', () => {
expect(screen.getByTestId('asset-card-content')).toBeInTheDocument()
})
})

describe('when its not interesected', () => {
it('should not render the Asset Card content', () => {
renderAssetCard({
Expand All @@ -107,20 +108,25 @@ describe('AssetCard', () => {
asset = { ...asset, itemId: 'itemId' } as Asset
})

describe('when the asset is an item', () => {
beforeEach(() => {
asset = { ...asset, itemId: 'itemId' } as Asset
it('should render the favorites counter', () => {
renderAssetCard({
asset
})
mockAllIsIntersecting(true)
expect(screen.getByTestId(FAVORITES_COUNTER_TEST_ID)).toBeInTheDocument()
})
})

it('should render the favorites counter', () => {
renderAssetCard({
asset
})
mockAllIsIntersecting(true)
expect(
screen.getByTestId(FAVORITES_COUNTER_TEST_ID)
).toBeInTheDocument()
describe('when the asset is an nft', () => {
beforeEach(() => {
asset = { ...asset, tokenId: 'tokenId' } as Asset
})

it('should not render the favorites counter', () => {
const { queryByTestId } = renderAssetCard({
asset
})
expect(queryByTestId(FAVORITES_COUNTER_TEST_ID)).toBeNull()
})
})
})
39 changes: 30 additions & 9 deletions webapp/src/components/AssetCard/EmoteTags/EmoteTags.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
import { NFTCategory } from '@dcl/schemas'
import classNames from 'classnames'
import { NFTCategory } from '@dcl/schemas'
import { Popup } from 'decentraland-ui'
import { T } from 'decentraland-dapps/dist/modules/translation/utils'
import { isNFT } from '../../../modules/asset/utils'
import { AssetType } from '../../../modules/asset/types'
import RarityBadge from '../../RarityBadge'
import { Props } from './EmoteTags.types'
import styles from './EmoteTags.module.css'

const EmoteTags = (props: Props) => {
const { asset } = props
const { rarity } = asset.data.emote!
const { rarity, loop } = asset.data.emote || {}

return (
<div className={classNames([styles.EmoteTags, 'tags'])}>
<RarityBadge
size="small"
rarity={rarity}
assetType={AssetType.NFT}
category={NFTCategory.EMOTE}
withTooltip={false}
/>
{rarity ? (
<RarityBadge
size="small"
rarity={rarity}
assetType={AssetType.NFT}
category={NFTCategory.EMOTE}
withTooltip={false}
/>
) : null}
{isNFT(asset) && loop !== undefined ? (
<Popup
position="top center"
content={<T id={`emote.play_mode.${loop ? 'loop' : 'simple'}`} />}
trigger={
<div className={styles.PlayModeSmallBadge}>
<span
className={classNames(
styles.PlayIcon,
loop ? styles.PlayLoop : styles.PlayOnce
)}
></span>
</div>
}
/>
) : null}
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/AssetImage/AssetImage.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const mapState = (state: RootState, ownProps: OwnProps): MapStateProps => {
avatar = profile.avatars[0]
}
return {
wallet,
avatar,
wearableController: getWearablePreviewController(state),
isTryingOn: getIsTryingOn(state),
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/AssetImage/AssetImage.css
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
width: 100%;
bottom: -110px;
padding-top: 20px;
height: 84px;
height: 94px;
}
.AssetImage .rarity-background,
.AssetImage .WearablePreview {
Expand Down
27 changes: 22 additions & 5 deletions webapp/src/components/AssetImage/AssetImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const AssetImage = (props: Props) => {
onSetWearablePreviewController,
children,
hasBadges,
item
item,
wallet
} = props
const { parcel, estate, wearable, emote, ens } = asset.data

Expand Down Expand Up @@ -264,22 +265,26 @@ const AssetImage = (props: Props) => {

const isTryingOnEnabled = isTryingOn && hasRepresentation

const urn = !isNFT(asset) && asset.network === Network.ETHEREUM ? getEthereumItemUrn(asset) : ''
const ethereumUrn =
!isNFT(asset) && asset.network === Network.ETHEREUM
? getEthereumItemUrn(asset)
: ''

const wearablePreviewProps =
!isNFT(asset) && asset.network === Network.ETHEREUM
? {
urns: [urn],
urns: [ethereumUrn],
background: Rarity.getColor(asset.rarity),
type: isTryingOn ? PreviewType.AVATAR : PreviewType.WEARABLE
}
: {
contractAddress: asset.contractAddress,

itemId,
tokenId
}

const isOwnerOfNFT = isNFT(asset) && wallet?.address === asset.owner

wearablePreview = (
<>
<WearablePreview
Expand All @@ -298,7 +303,7 @@ const AssetImage = (props: Props) => {
{...wearablePreviewProps}
dev={config.is(Env.DEVELOPMENT)}
/>
{isAvailableForMint ? (
{isAvailableForMint && !isOwnerOfNFT ? (
<AvailableForMintPopup
price={item.price}
stock={item.available}
Expand Down Expand Up @@ -451,6 +456,8 @@ const AssetImage = (props: Props) => {
</div>
)

const isOwnerOfNFT = isNFT(asset) && wallet?.address === asset.owner

if (isDraggable) {
wearablePreview = (
<>
Expand All @@ -466,6 +473,16 @@ const AssetImage = (props: Props) => {
onError={handleError}
dev={config.is(Env.DEVELOPMENT)}
/>
{isAvailableForMint && !isOwnerOfNFT ? (
<AvailableForMintPopup
price={item.price}
stock={item.available}
rarity={item.rarity}
contractAddress={item.contractAddress}
itemId={item.itemId}
network={item.network}
/>
) : null}
{isLoadingWearablePreview ? (
<Center>
<Loader
Expand Down
9 changes: 8 additions & 1 deletion webapp/src/components/AssetImage/AssetImage.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { Dispatch } from 'redux'
import { Avatar, IPreviewController, Item, Rarity } from '@dcl/schemas'
import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types'
import {
setIsTryingOn,
SetIsTryingOnAction,
Expand Down Expand Up @@ -33,6 +34,7 @@ export type Props = {
children?: React.ReactNode
hasBadges?: boolean
item: Item | null
wallet: Wallet | null
}

export type OwnProps = Pick<Props, 'showOrderListedTag' | 'asset'>
Expand All @@ -46,7 +48,12 @@ export enum ControlOptionAction {

export type MapStateProps = Pick<
Props,
'avatar' | 'wearableController' | 'isTryingOn' | 'isPlayingEmote' | 'item'
| 'avatar'
| 'wearableController'
| 'isTryingOn'
| 'isPlayingEmote'
| 'item'
| 'wallet'
>
export type MapDispatchProps = Pick<
Props,
Expand Down
11 changes: 0 additions & 11 deletions webapp/src/components/AssetList/AssetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,19 @@ const AssetList = (props: Props) => {
)
}

// const currentSection =
// assetType === AssetType.ITEM
// ? t('browse_page.primary_market_title').toLocaleLowerCase()
// : t('browse_page.secondary_market_title').toLocaleLowerCase()
// const alternativeSection =
// assetType === AssetType.ITEM
// ? t('browse_page.secondary_market_title').toLocaleLowerCase()
// : t('browse_page.primary_market_title').toLocaleLowerCase()
return (
<div className="empty empty-assets">
<div className="watermelon" />
<span>
{t(`${emptyStateTranslationString}.title`, {
search
// currentSection
})}
</span>
<span>
<T
id={`${emptyStateTranslationString}.action`}
values={{
search,
// currentSection,
// section: alternativeSection,
'if-filters': (chunks: string) =>
hasFiltersEnabled ? chunks : '',
clearFilters: (chunks: string) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
display: flex;
align-items: center;
font-size: 14px;
flex-wrap: wrap;
}

.manaField :global(.ui.header:last-child) {
Expand All @@ -79,4 +80,9 @@
.linkedProfileRow {
margin-left: unset;
}
.viewListingContainer {
flex-direction: column;
gap: 6px;
padding: 6px;
}
}
9 changes: 7 additions & 2 deletions webapp/src/components/AssetPage/BidsTable/BidsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ConfirmInputValueModal } from '../../ConfirmInputValueModal'
import { formatDataToTable } from './utils'
import { Props } from './BidsTable.types'

export const ROWS_PER_PAGE = 6
export const ROWS_PER_PAGE = 5
const INITIAL_PAGE = 1

const BidsTable = (props: Props) => {
Expand Down Expand Up @@ -60,6 +60,7 @@ const BidsTable = (props: Props) => {

// We're doing this outside of redux to avoid having to store all orders when we only care about the first ROWS_PER_PAGE
useEffect(() => {
let cancel = false
if (nft) {
setIsLoading(true)
bidAPI
Expand All @@ -72,6 +73,7 @@ const BidsTable = (props: Props) => {
((page - 1) * ROWS_PER_PAGE).toString()
)
.then(response => {
if (cancel) return
setTotal(response.total)
setBids(
formatDataToTable(
Expand All @@ -83,10 +85,13 @@ const BidsTable = (props: Props) => {
)
setTotalPages(Math.ceil(response.total / ROWS_PER_PAGE) | 0)
})
.finally(() => setIsLoading(false))
.finally(() => !cancel && setIsLoading(false))
.catch(error => {
console.error(error)
})
return () => {
cancel = true
}
}
}, [nft, setIsLoading, setBids, page, sortBy, address, isMobileOrTablet])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,9 @@
.BuyNFTBox .informationContainer {
gap: 10px;
}

.BuyNFTBox .centerItems {
flex-direction: column;
margin-top: 12px;
}
}
Loading

0 comments on commit d2b218e

Please sign in to comment.