Commit a57c19bb authored by Greg Bugyis's avatar Greg Bugyis Committed by GitHub

feat: Collection Activity mobile fixes (#5073)

parent 9fd6ab01
...@@ -29,7 +29,7 @@ export const eventRow = style([ ...@@ -29,7 +29,7 @@ export const eventRow = style([
baseRow, baseRow,
sprinkles({ sprinkles({
paddingY: '12', paddingY: '12',
paddingX: '16', paddingX: { sm: '4', md: '16' },
color: 'textPrimary', color: 'textPrimary',
cursor: 'pointer', cursor: 'pointer',
borderWidth: '1px', borderWidth: '1px',
......
...@@ -156,11 +156,19 @@ export const Activity = ({ contractAddress, rarityVerified, collectionName, chai ...@@ -156,11 +156,19 @@ export const Activity = ({ contractAddress, rarityVerified, collectionName, chai
> >
{events.map((event, i) => ( {events.map((event, i) => (
<Box as="a" href={baseHref(event)} className={styles.eventRow} key={i}> <Box as="a" href={baseHref(event)} className={styles.eventRow} key={i}>
<ItemCell event={event} rarityVerified={rarityVerified} collectionName={collectionName} /> <ItemCell
event={event}
rarityVerified={rarityVerified}
collectionName={collectionName}
eventTimestamp={event.eventTimestamp}
isMobile={isMobile}
/>
<EventCell <EventCell
eventType={event.eventType} eventType={event.eventType}
eventTimestamp={event.eventTimestamp} eventTimestamp={event.eventTimestamp}
eventTransactionHash={event.transactionHash} eventTransactionHash={event.transactionHash}
price={event.price}
isMobile={isMobile}
/> />
<PriceCell marketplace={event.marketplace} price={event.price} /> <PriceCell marketplace={event.marketplace} price={event.price} />
<AddressCell address={event.fromAddress} chainId={chainId} /> <AddressCell address={event.fromAddress} chainId={chainId} />
......
...@@ -204,6 +204,8 @@ interface EventCellProps { ...@@ -204,6 +204,8 @@ interface EventCellProps {
eventType: ActivityEventType eventType: ActivityEventType
eventTimestamp?: number eventTimestamp?: number
eventTransactionHash?: string eventTransactionHash?: string
price?: string
isMobile: boolean
} }
const renderEventIcon = (eventType: ActivityEventType) => { const renderEventIcon = (eventType: ActivityEventType) => {
...@@ -241,19 +243,21 @@ const eventColors = (eventType: ActivityEventType) => { ...@@ -241,19 +243,21 @@ const eventColors = (eventType: ActivityEventType) => {
return activityEvents[eventType] as 'gold' | 'green' | 'violet' | 'accentFailure' return activityEvents[eventType] as 'gold' | 'green' | 'violet' | 'accentFailure'
} }
export const EventCell = ({ eventType, eventTimestamp, eventTransactionHash }: EventCellProps) => { export const EventCell = ({ eventType, eventTimestamp, eventTransactionHash, price, isMobile }: EventCellProps) => {
const formattedPrice = useMemo(() => (price ? putCommas(formatEthPrice(price))?.toString() : null), [price])
return ( return (
<Column height="full" justifyContent="center" gap="4"> <Column height="full" justifyContent="center" gap="4">
<Row className={styles.eventDetail} color={eventColors(eventType)}> <Row className={styles.eventDetail} color={eventColors(eventType)}>
{renderEventIcon(eventType)} {renderEventIcon(eventType)}
{ActivityEventTypeDisplay[eventType]} {ActivityEventTypeDisplay[eventType]}
</Row> </Row>
{eventTimestamp && isValidDate(eventTimestamp) && ( {eventTimestamp && isValidDate(eventTimestamp) && !isMobile && (
<Row className={styles.eventTime}> <Row className={styles.eventTime}>
{getTimeDifference(eventTimestamp.toString())} {getTimeDifference(eventTimestamp.toString())}
{eventTransactionHash && <ExternalLinkIcon transactionHash={eventTransactionHash} />} {eventTransactionHash && <ExternalLinkIcon transactionHash={eventTransactionHash} />}
</Row> </Row>
)} )}
{isMobile && price && <Row fontSize="16" fontWeight="normal" color="textPrimary">{`${formattedPrice} ETH`}</Row>}
</Column> </Column>
) )
} }
...@@ -262,6 +266,8 @@ interface ItemCellProps { ...@@ -262,6 +266,8 @@ interface ItemCellProps {
event: ActivityEvent event: ActivityEvent
rarityVerified: boolean rarityVerified: boolean
collectionName: string collectionName: string
isMobile: boolean
eventTimestamp?: number
} }
const NoContentContainer = () => ( const NoContentContainer = () => (
...@@ -335,7 +341,7 @@ const getItemImage = (tokenMetadata?: TokenMetadata): string | undefined => { ...@@ -335,7 +341,7 @@ const getItemImage = (tokenMetadata?: TokenMetadata): string | undefined => {
return tokenMetadata?.smallImageUrl || tokenMetadata?.imageUrl return tokenMetadata?.smallImageUrl || tokenMetadata?.imageUrl
} }
export const ItemCell = ({ event, rarityVerified, collectionName }: ItemCellProps) => { export const ItemCell = ({ event, rarityVerified, collectionName, eventTimestamp, isMobile }: ItemCellProps) => {
const [loaded, setLoaded] = useState(false) const [loaded, setLoaded] = useState(false)
const [noContent, setNoContent] = useState(!getItemImage(event.tokenMetadata)) const [noContent, setNoContent] = useState(!getItemImage(event.tokenMetadata))
...@@ -359,13 +365,14 @@ export const ItemCell = ({ event, rarityVerified, collectionName }: ItemCellProp ...@@ -359,13 +365,14 @@ export const ItemCell = ({ event, rarityVerified, collectionName }: ItemCellProp
)} )}
<Column height="full" justifyContent="center" overflow="hidden" whiteSpace="nowrap" marginRight="24"> <Column height="full" justifyContent="center" overflow="hidden" whiteSpace="nowrap" marginRight="24">
<Box className={styles.detailsName}>{event.tokenMetadata?.name || event.tokenId}</Box> <Box className={styles.detailsName}>{event.tokenMetadata?.name || event.tokenId}</Box>
{event.tokenMetadata?.rarity && ( {event.tokenMetadata?.rarity && !isMobile && (
<Ranking <Ranking
rarity={event.tokenMetadata?.rarity} rarity={event.tokenMetadata?.rarity}
rarityVerified={rarityVerified} rarityVerified={rarityVerified}
collectionName={collectionName} collectionName={collectionName}
/> />
)} )}
{isMobile && eventTimestamp && isValidDate(eventTimestamp) && getTimeDifference(eventTimestamp.toString())}
</Column> </Column>
</Row> </Row>
) )
......
...@@ -48,10 +48,10 @@ export enum ActivityEventType { ...@@ -48,10 +48,10 @@ export enum ActivityEventType {
} }
export enum ActivityEventTypeDisplay { export enum ActivityEventTypeDisplay {
'LISTING' = 'Listing', 'LISTING' = 'Listed',
'SALE' = 'Sale', 'SALE' = 'Sold',
'TRANSFER' = 'Transfer', 'TRANSFER' = 'Transferred',
'CANCEL_LISTING' = 'Cancel', 'CANCEL_LISTING' = 'Cancelled',
} }
export enum OrderStatus { export enum OrderStatus {
......
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