Commit 400666cd authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

chore: migrate MarketplaceRow to styled-components (#5798)

* style ethPrice

* style old price info and fix up ethpricedisplay

* share style and use for remove icon

* style icon

* style fee column

* style returns column

* marketplace wrapper

* needed column

* remove unused style file
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent 7f4fe6cc
import { style } from '@vanilla-extract/css'
export const removeMarketplace = style({
top: '11px',
right: '14px',
})
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { t } from '@lingui/macro' import { t } from '@lingui/macro'
import Column from 'components/Column'
import Row from 'components/Row'
import { MouseoverTooltip } from 'components/Tooltip' import { MouseoverTooltip } from 'components/Tooltip'
import { Box } from 'nft/components/Box'
import { Column, Row } from 'nft/components/Flex'
import { body, bodySmall } from 'nft/css/common.css'
import { useSellAsset } from 'nft/hooks' import { useSellAsset } from 'nft/hooks'
import { ListingMarket, ListingWarning, WalletAsset } from 'nft/types' import { ListingMarket, ListingWarning, WalletAsset } from 'nft/types'
import { LOOKS_RARE_CREATOR_BASIS_POINTS } from 'nft/utils' import { LOOKS_RARE_CREATOR_BASIS_POINTS } from 'nft/utils'
import { formatEth, formatUsdPrice } from 'nft/utils/currency' import { formatEth, formatUsdPrice } from 'nft/utils/currency'
import { fetchPrice } from 'nft/utils/fetchPrice' import { fetchPrice } from 'nft/utils/fetchPrice'
import { Dispatch, useEffect, useMemo, useState } from 'react' import { Dispatch, useEffect, useMemo, useState } from 'react'
import styled from 'styled-components/macro'
import { BREAKPOINTS, ThemedText } from 'theme'
import * as styles from './ListPage.css'
import { SetPriceMethod } from './NFTListingsGrid' import { SetPriceMethod } from './NFTListingsGrid'
import { PriceTextInput } from './PriceTextInput' import { PriceTextInput } from './PriceTextInput'
import { RoyaltyTooltip } from './RoyaltyTooltip' import { RoyaltyTooltip } from './RoyaltyTooltip'
import { RemoveIconWrap } from './shared'
const PastPriceInfo = styled(Column)`
text-align: left;
display: none;
flex: 1;
@media screen and (min-width: ${BREAKPOINTS.xxl}px) {
display: flex;
}
`
const RemoveMarketplaceWrap = styled(RemoveIconWrap)`
top: 11px;
`
const MarketIconWrapper = styled(Column)`
position: relative;
cursor: pointer;
margin-right: 16px;
`
const MarketIcon = styled.img`
width: 28px;
height: 28px;
border-radius: 4px;
object-fit: cover;
`
const FeeColumnWrapper = styled(Column)`
flex: 1;
align-items: flex-end;
display: none;
@media screen and (min-width: ${BREAKPOINTS.lg}px) {
display: flex;
}
`
const FeeWrapper = styled.div`
width: min-content;
white-space: nowrap;
`
const ReturnColumn = styled(Column)`
flex: 1.5;
display: none;
@media screen and (min-width: ${BREAKPOINTS.lg}px) {
display: flex;
}
`
const getRoyalty = (listingMarket: ListingMarket, asset: WalletAsset) => { const getRoyalty = (listingMarket: ListingMarket, asset: WalletAsset) => {
// LooksRare is a unique case where royalties for creators are a flat 0.5% or 50 basis points // LooksRare is a unique case where royalties for creators are a flat 0.5% or 50 basis points
...@@ -134,31 +186,21 @@ export const MarketplaceRow = ({ ...@@ -134,31 +186,21 @@ export const MarketplaceRow = ({
} }
return ( return (
<Row transition="500" marginLeft="0"> <Row>
<Column <PastPriceInfo>
className={bodySmall} <ThemedText.BodySmall color="textSecondary" lineHeight="20px">
color="textSecondary" {asset.floorPrice ? `${asset.floorPrice.toFixed(3)} ETH` : '-'}
textAlign="left" </ThemedText.BodySmall>
flex="1" </PastPriceInfo>
display={{ sm: 'none', xxl: 'flex' }} <PastPriceInfo>
> <ThemedText.BodySmall color="textSecondary" lineHeight="20px">
{asset.floorPrice ? `${asset.floorPrice.toFixed(3)} ETH` : '-'} {asset.lastPrice ? `${asset.lastPrice.toFixed(3)} ETH` : '-'}
</Column> </ThemedText.BodySmall>
<Column </PastPriceInfo>
className={bodySmall}
color="textSecondary"
textAlign="left"
flex="1"
display={{ sm: 'none', xxl: 'flex' }}
>
{asset.lastPrice ? `${asset.lastPrice.toFixed(3)} ETH` : '-'}
</Column>
<Row flex="2"> <Row flex="2">
{showMarketplaceLogo && ( {showMarketplaceLogo && (
<Column <MarketIconWrapper
position="relative"
cursor="pointer"
onMouseEnter={handleHover} onMouseEnter={handleHover}
onMouseLeave={handleHover} onMouseLeave={handleHover}
onClick={(e) => { onClick={(e) => {
...@@ -167,20 +209,11 @@ export const MarketplaceRow = ({ ...@@ -167,20 +209,11 @@ export const MarketplaceRow = ({
removeMarket && removeMarket() removeMarket && removeMarket()
}} }}
> >
<Box className={styles.removeMarketplace} visibility={hovered ? 'visible' : 'hidden'} position="absolute"> <MarketIcon alt={selectedMarkets[0].name} src={selectedMarkets[0].icon} />
<Box as="img" width="32" src="/nft/svgs/minusCircle.svg" alt="Remove item" /> <RemoveMarketplaceWrap hovered={hovered}>
</Box> <img width="32px" src="/nft/svgs/minusCircle.svg" alt="Remove item" />
<Box </RemoveMarketplaceWrap>
as="img" </MarketIconWrapper>
alt={selectedMarkets[0].name}
width="28"
height="28"
borderRadius="4"
objectFit="cover"
src={selectedMarkets[0].icon}
marginRight="16"
/>
</Column>
)} )}
{globalPriceMethod === SetPriceMethod.SAME_PRICE && !globalOverride ? ( {globalPriceMethod === SetPriceMethod.SAME_PRICE && !globalOverride ? (
<PriceTextInput <PriceTextInput
...@@ -207,30 +240,24 @@ export const MarketplaceRow = ({ ...@@ -207,30 +240,24 @@ export const MarketplaceRow = ({
)} )}
</Row> </Row>
<Column flex="1" display={{ sm: 'none', lg: 'flex' }}> <FeeColumnWrapper>
<Box className={body} color="textSecondary" width="full" textAlign="right"> <MouseoverTooltip
<MouseoverTooltip text={selectedMarkets.map((selectedMarket, index) => {
text={ return <RoyaltyTooltip selectedMarket={selectedMarket} key={index} />
<Row> })}
<Box width="full" fontSize="14"> placement="left"
{selectedMarkets.map((selectedMarket, index) => { >
return <RoyaltyTooltip selectedMarket={selectedMarket} key={index} /> <FeeWrapper>
})} <ThemedText.BodyPrimary color="textSecondary">
</Box> {fees > 0 ? `${fees}${selectedMarkets.length > 1 ? t`% max` : '%'}` : '--%'}
</Row> </ThemedText.BodyPrimary>
} </FeeWrapper>
placement="left" </MouseoverTooltip>
> </FeeColumnWrapper>
{fees > 0 ? `${fees}${selectedMarkets.length > 1 ? t`% max` : '%'}` : '--%'}
</MouseoverTooltip> <ReturnColumn>
</Box> <EthPriceDisplay ethPrice={userReceives} />
</Column> </ReturnColumn>
<Column flex="1.5" display={{ sm: 'none', lg: 'flex' }}>
<Column width="full">
<EthPriceDisplay ethPrice={userReceives} />
</Column>
</Column>
</Row> </Row>
) )
} }
...@@ -244,23 +271,19 @@ const EthPriceDisplay = ({ ethPrice = 0 }: { ethPrice?: number }) => { ...@@ -244,23 +271,19 @@ const EthPriceDisplay = ({ ethPrice = 0 }: { ethPrice?: number }) => {
}, []) }, [])
return ( return (
<Column width="full"> <Row width="100%" justify="flex-end">
<Row width="full" justifyContent="flex-end" color={ethPrice !== 0 ? 'textPrimary' : 'textSecondary'}> <ThemedText.BodyPrimary lineHeight="24px" color={ethPrice ? 'textPrimary' : 'textSecondary'} textAlign="right">
{ethPrice !== 0 ? ( {ethPrice !== 0 ? (
<> <Column>
<Column> <span>{formatEth(ethPrice)} ETH</span>
<Box className={body} color="textPrimary" textAlign="right" marginLeft="12" marginRight="0"> <ThemedText.BodyPrimary color="textSecondary">
{formatEth(ethPrice)} ETH {formatUsdPrice(ethPrice * ethConversion)}
</Box> </ThemedText.BodyPrimary>
<Box className={body} color="textSecondary" textAlign="right" marginLeft="12" marginRight="0"> </Column>
{formatUsdPrice(ethPrice * ethConversion)}
</Box>
</Column>
</>
) : ( ) : (
'- ETH' '- ETH'
)} )}
</Row> </ThemedText.BodyPrimary>
</Column> </Row>
) )
} }
...@@ -9,6 +9,7 @@ import { BREAKPOINTS, ThemedText } from 'theme' ...@@ -9,6 +9,7 @@ import { BREAKPOINTS, ThemedText } from 'theme'
import { MarketplaceRow } from './MarketplaceRow' import { MarketplaceRow } from './MarketplaceRow'
import { SetPriceMethod } from './NFTListingsGrid' import { SetPriceMethod } from './NFTListingsGrid'
import { RemoveIconWrap } from './shared'
const NFTListRowWrapper = styled(Row)` const NFTListRowWrapper = styled(Row)`
margin: 24px 0px; margin: 24px 0px;
...@@ -44,15 +45,6 @@ const NFTImage = styled.img` ...@@ -44,15 +45,6 @@ const NFTImage = styled.img`
border-radius: 8px; border-radius: 8px;
` `
const RemoveIconWrap = styled.div<{ hovered: boolean }>`
position: absolute;
left: 50%;
top: 30px;
transform: translateX(-50%);
width: 32px;
visibility: ${({ hovered }) => (hovered ? 'visible' : 'hidden')};
`
const RemoveIcon = styled.img` const RemoveIcon = styled.img`
width: 32px; width: 32px;
height: 32px; height: 32px;
......
...@@ -2,13 +2,14 @@ import { Trans } from '@lingui/macro' ...@@ -2,13 +2,14 @@ import { Trans } from '@lingui/macro'
import { ListingMarket } from 'nft/types' import { ListingMarket } from 'nft/types'
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ThemedText } from 'theme'
const FeeWrap = styled.div` const FeeWrap = styled.div`
margin-bottom: 4px; margin-bottom: 4px;
color: ${({ theme }) => theme.textPrimary}; color: ${({ theme }) => theme.textPrimary};
` `
const RoyaltyContainer = styled.div` const RoyaltyContainer = styled(ThemedText.BodySmall)`
margin-bottom: 8px; margin-bottom: 8px;
` `
......
import styled from 'styled-components/macro'
export const RemoveIconWrap = styled.div<{ hovered: boolean }>`
position: absolute;
left: 50%;
top: 30px;
transform: translateX(-50%);
width: 32px;
visibility: ${({ hovered }) => (hovered ? 'visible' : 'hidden')};
`
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