From dc478ce37e22ffd8e178784f15cbca7194fceafa Mon Sep 17 00:00:00 2001 From: Charles Bachmeier Date: Thu, 5 Jan 2023 08:46:54 -0800 Subject: [PATCH] chore: Migrate NFTListRow from vanilla-extract to styled-components (#5785) * remove redundant styles * wrap nft info * added back needed style * style nft image * style token and collection name * wrap token info and marketplace rows * use Row and Column shared components Co-authored-by: Charles Bachmeier --- .../components/profile/list/NFTListRow.tsx | 154 +++++++++++------- 1 file changed, 96 insertions(+), 58 deletions(-) diff --git a/src/nft/components/profile/list/NFTListRow.tsx b/src/nft/components/profile/list/NFTListRow.tsx index 583b5a8c23..0d9d162835 100644 --- a/src/nft/components/profile/list/NFTListRow.tsx +++ b/src/nft/components/profile/list/NFTListRow.tsx @@ -1,16 +1,50 @@ -import { Box } from 'nft/components/Box' -import { Column, Row } from 'nft/components/Flex' +import Column from 'components/Column' +import Row from 'components/Row' import { RowsCollpsedIcon, RowsExpandedIcon, VerifiedIcon } from 'nft/components/icons' -import { bodySmall, subhead } from 'nft/css/common.css' import { useSellAsset } from 'nft/hooks' import { ListingMarket, WalletAsset } from 'nft/types' import { Dispatch, useEffect, useState } from 'react' -import styled from 'styled-components/macro' +import styled, { css } from 'styled-components/macro' +import { BREAKPOINTS, ThemedText } from 'theme' import { MarketplaceRow } from './MarketplaceRow' import { SetPriceMethod } from './NFTListingsGrid' -const IconWrap = styled.div<{ hovered: boolean }>` +const NFTListRowWrapper = styled(Row)` + margin: 24px 0px; + align-items: center; +` + +const NFTInfoWrapper = styled(Row)` + align-items: center; + min-width: 0px; + flex: 2; + margin-bottom: auto; + + @media screen and (min-width: ${BREAKPOINTS.md}px) { + flex: 1.5; + } +` + +const ExpandMarketIconWrapper = styled.div` + cursor: pointer; + margin-right: 8px; +` + +const NFTImageWrapper = styled.div` + position: relative; + cursor: pointer; + height: 48px; + margin-right: 8px; +` + +const NFTImage = styled.img` + width: 48px; + height: 48px; + border-radius: 8px; +` + +const RemoveIconWrap = styled.div<{ hovered: boolean }>` position: absolute; left: 50%; top: 30px; @@ -19,11 +53,45 @@ const IconWrap = styled.div<{ hovered: boolean }>` visibility: ${({ hovered }) => (hovered ? 'visible' : 'hidden')}; ` -const StyledImg = styled.img` +const RemoveIcon = styled.img` width: 32px; height: 32px; ` +const HideTextOverflow = css` + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +` + +const TokenInfoWrapper = styled(Column)` + gap: 4px; + margin-right: 8px; + min-width: 0px; +` + +const TokenName = styled.div` + font-weight: 500; + font-size: 16px; + line-height: 24px; + ${HideTextOverflow} +` + +const CollectionName = styled(ThemedText.BodySmall)` + color: ${({ theme }) => theme.textSecondary}; + line-height: 20px; + ${HideTextOverflow}; +` + +const MarketPlaceRowWrapper = styled(Column)` + gap: 24px; + flex: 1; + + @media screen and (min-width: ${BREAKPOINTS.md}px) { + flex: 3; + } +` + interface NFTListRowProps { asset: WalletAsset globalPriceMethod?: SetPriceMethod @@ -55,64 +123,34 @@ export const NFTListRow = ({ }, [selectedMarkets]) return ( - - - 1 ? '28px' : '0', - opacity: localMarkets.length > 1 ? '1' : '0', - }} - cursor="pointer" - marginRight="8" - onClick={() => setExpandMarketplaceRows(!expandMarketplaceRows)} - > - {expandMarketplaceRows ? : } - - + + {localMarkets.length > 1 && ( + setExpandMarketplaceRows(!expandMarketplaceRows)}> + {expandMarketplaceRows ? : } + + )} + { removeAsset(asset) }} > - - - - - - - - {asset.name ? asset.name : `#${asset.tokenId}`} - - + + + + + + + {asset.name ? asset.name : `#${asset.tokenId}`} + {asset.collection?.name} {asset.collectionIsVerified && } - - - - + + + + {expandMarketplaceRows ? ( localMarkets.map((market, index) => { return ( @@ -139,7 +177,7 @@ export const NFTListRow = ({ showMarketplaceLogo={false} /> )} - - + + ) }