Commit 27936cf3 authored by lynn's avatar lynn Committed by GitHub

feat: image cropping / sizing on view my nfts (#5177)

init
parent ff6f43d7
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
} from 'nft/hooks' } from 'nft/hooks'
import { ScreenBreakpointsPaddings } from 'nft/pages/collection/index.css' import { ScreenBreakpointsPaddings } from 'nft/pages/collection/index.css'
import { OSCollectionsFetcher } from 'nft/queries' import { OSCollectionsFetcher } from 'nft/queries'
import { UniformHeight, UniformHeights } from 'nft/types'
import { ProfilePageStateType, WalletAsset, WalletCollection } from 'nft/types' import { ProfilePageStateType, WalletAsset, WalletCollection } from 'nft/types'
import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react' import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react'
import InfiniteScroll from 'react-infinite-scroll-component' import InfiniteScroll from 'react-infinite-scroll-component'
...@@ -80,6 +81,7 @@ export const ProfilePage = () => { ...@@ -80,6 +81,7 @@ export const ProfilePage = () => {
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
const isMobile = useIsMobile() const isMobile = useIsMobile()
const [currentTokenPlayingMedia, setCurrentTokenPlayingMedia] = useState<string | undefined>() const [currentTokenPlayingMedia, setCurrentTokenPlayingMedia] = useState<string | undefined>()
const [uniformHeight, setUniformHeight] = useState<UniformHeight>(UniformHeights.unset)
const handleSellModeClick = useCallback(() => { const handleSellModeClick = useCallback(() => {
resetSellAssets() resetSellAssets()
...@@ -178,6 +180,8 @@ export const ProfilePage = () => { ...@@ -178,6 +180,8 @@ export const ProfilePage = () => {
isSellMode={isSellMode} isSellMode={isSellMode}
mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia} mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia}
setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia} setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia}
uniformHeight={uniformHeight}
setUniformHeight={setUniformHeight}
/> />
</div> </div>
)) ))
......
...@@ -7,6 +7,7 @@ import { bodySmall } from 'nft/css/common.css' ...@@ -7,6 +7,7 @@ import { bodySmall } from 'nft/css/common.css'
import { themeVars } from 'nft/css/sprinkles.css' import { themeVars } from 'nft/css/sprinkles.css'
import { useBag, useIsMobile, useSellAsset } from 'nft/hooks' import { useBag, useIsMobile, useSellAsset } from 'nft/hooks'
import { WalletAsset } from 'nft/types' import { WalletAsset } from 'nft/types'
import { UniformHeight } from 'nft/types'
import { useMemo } from 'react' import { useMemo } from 'react'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
const NFT_DETAILS_HREF = (asset: WalletAsset) => const NFT_DETAILS_HREF = (asset: WalletAsset) =>
...@@ -17,20 +18,38 @@ interface ViewMyNftsAssetProps { ...@@ -17,20 +18,38 @@ interface ViewMyNftsAssetProps {
isSellMode: boolean isSellMode: boolean
mediaShouldBePlaying: boolean mediaShouldBePlaying: boolean
setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void
uniformHeight: UniformHeight
setUniformHeight: (u: UniformHeight) => void
} }
const getNftDisplayComponent = ( const getNftDisplayComponent = (
assetMediaType: AssetMediaType, assetMediaType: AssetMediaType,
mediaShouldBePlaying: boolean, mediaShouldBePlaying: boolean,
setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void setCurrentTokenPlayingMedia: (tokenId: string | undefined) => void,
uniformHeight: UniformHeight,
setUniformHeight: (u: UniformHeight) => void
) => { ) => {
switch (assetMediaType) { switch (assetMediaType) {
case AssetMediaType.Image: case AssetMediaType.Image:
return <Card.Image /> return <Card.Image uniformHeight={uniformHeight} setUniformHeight={setUniformHeight} />
case AssetMediaType.Video: case AssetMediaType.Video:
return <Card.Video shouldPlay={mediaShouldBePlaying} setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia} /> return (
<Card.Video
uniformHeight={uniformHeight}
setUniformHeight={setUniformHeight}
shouldPlay={mediaShouldBePlaying}
setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia}
/>
)
case AssetMediaType.Audio: case AssetMediaType.Audio:
return <Card.Audio shouldPlay={mediaShouldBePlaying} setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia} /> return (
<Card.Audio
uniformHeight={uniformHeight}
setUniformHeight={setUniformHeight}
shouldPlay={mediaShouldBePlaying}
setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia}
/>
)
} }
} }
...@@ -39,6 +58,8 @@ export const ViewMyNftsAsset = ({ ...@@ -39,6 +58,8 @@ export const ViewMyNftsAsset = ({
isSellMode, isSellMode,
mediaShouldBePlaying, mediaShouldBePlaying,
setCurrentTokenPlayingMedia, setCurrentTokenPlayingMedia,
uniformHeight,
setUniformHeight,
}: 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)
...@@ -98,7 +119,13 @@ export const ViewMyNftsAsset = ({ ...@@ -98,7 +119,13 @@ export const ViewMyNftsAsset = ({
disableHover={!isDisabled} disableHover={!isDisabled}
> >
<Card.ImageContainer> <Card.ImageContainer>
{getNftDisplayComponent(assetMediaType, mediaShouldBePlaying, setCurrentTokenPlayingMedia)} {getNftDisplayComponent(
assetMediaType,
mediaShouldBePlaying,
setCurrentTokenPlayingMedia,
uniformHeight,
setUniformHeight
)}
</Card.ImageContainer> </Card.ImageContainer>
</MouseoverTooltip> </MouseoverTooltip>
<Card.DetailsContainer> <Card.DetailsContainer>
......
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