Skip to content

Commit

Permalink
fix: do not show floor/volume change on all (#5214)
Browse files Browse the repository at this point in the history
* fix: do not show floor/volume change on all

* chore: nit

* chore: add new type of cell and fix lint

* chore: one more place
  • Loading branch information
grabbou committed Nov 15, 2022
1 parent 6257509 commit 72a8270
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/nft/components/explore/Cells/Cells.tsx
Expand Up @@ -129,6 +129,8 @@ export const EthCell = ({
)
}

export const TextCell = ({ value }: { value: string }) => <ThemedText.BodyPrimary>{value}</ThemedText.BodyPrimary>

export const VolumeCell = ({
value,
denomination,
Expand Down
22 changes: 16 additions & 6 deletions src/nft/components/explore/CollectionTable.tsx
@@ -1,9 +1,9 @@
import { BigNumber } from '@ethersproject/bignumber'
import { CollectionTableColumn, TimePeriod } from 'nft/types'
import { useMemo } from 'react'
import { CellProps, Column, Row } from 'react-table'

import { CollectionTableColumn } from '../../types'
import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, VolumeCell } from './Cells/Cells'
import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, TextCell, VolumeCell } from './Cells/Cells'
import { Table } from './Table'

export enum ColumnHeaders {
Expand All @@ -20,7 +20,7 @@ const compareFloats = (a: number, b: number): 1 | -1 => {
return Math.round(a * 100000) >= Math.round(b * 100000) ? 1 : -1
}

const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
const CollectionTable = ({ data, timePeriod }: { data: CollectionTableColumn[]; timePeriod: TimePeriod }) => {
const floorSort = useMemo(() => {
return (rowA: Row<CollectionTableColumn>, rowB: Row<CollectionTableColumn>) => {
const aFloor = BigNumber.from(rowA.original.floor.value ?? 0)
Expand Down Expand Up @@ -76,9 +76,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
Header: ColumnHeaders.FloorChange,
accessor: ({ floor }) => floor.value,
sortDescFirst: true,
disableSortBy: timePeriod === TimePeriod.AllTime,
sortType: floorChangeSort,
Cell: function changeCell(cell: CellProps<CollectionTableColumn>) {
return <ChangeCell change={cell.row.original.floor.change} />
return timePeriod === TimePeriod.AllTime ? (
<TextCell value="-" />
) : (
<ChangeCell change={cell.row.original.floor.change} />
)
},
},
{
Expand All @@ -102,9 +107,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
Header: ColumnHeaders.VolumeChange,
accessor: ({ volume }) => volume.value,
sortDescFirst: true,
disableSortBy: timePeriod === TimePeriod.AllTime,
sortType: volumeChangeSort,
Cell: function changeCell(cell: CellProps<CollectionTableColumn>) {
return <ChangeCell change={cell.row.original.volume.change} />
return timePeriod === TimePeriod.AllTime ? (
<TextCell value="-" />
) : (
<ChangeCell change={cell.row.original.volume.change} />
)
},
},
{
Expand All @@ -125,7 +135,7 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
},
},
],
[floorChangeSort, floorSort, volumeChangeSort, volumeSort]
[floorChangeSort, floorSort, volumeChangeSort, volumeSort, timePeriod]
)
return (
<>
Expand Down
12 changes: 6 additions & 6 deletions src/nft/components/explore/Table.tsx
Expand Up @@ -43,15 +43,15 @@ const StyledLoadingRow = styled.tr`
height: 80px;
`

const StyledHeader = styled.th<{ isFirstHeader: boolean }>`
${({ isFirstHeader }) => !isFirstHeader && `cursor: pointer;`}
const StyledHeader = styled.th<{ disabled?: boolean }>`
${({ disabled }) => !disabled && `cursor: pointer;`}
:hover {
${({ theme, isFirstHeader }) => !isFirstHeader && `opacity: ${theme.opacity.hover};`}
${({ theme, disabled }) => !disabled && `opacity: ${theme.opacity.hover};`}
}
:active {
${({ theme, isFirstHeader }) => !isFirstHeader && `opacity: ${theme.opacity.click};`}
${({ theme, disabled }) => !disabled && `opacity: ${theme.opacity.click};`}
}
`

Expand Down Expand Up @@ -154,7 +154,7 @@ export function Table<D extends Record<string, unknown>>({
textAlign: index === 0 ? 'left' : 'right',
paddingLeft: index === 0 ? (isMobile ? '16px' : '52px') : 0,
}}
isFirstHeader={index === 0}
disabled={column.disableSortBy}
key={index}
>
<Box as="span" color="accentAction" position="relative">
Expand Down Expand Up @@ -240,7 +240,7 @@ function LoadingTable({ headerGroups, visibleColumns, ...props }: LoadingTablePr
textAlign: index === 0 ? 'left' : 'right',
paddingLeft: index === 0 ? '52px' : 0,
}}
isFirstHeader={index === 0}
disabled={index === 0}
key={index}
>
<Box as="span" color="accentAction" position="relative">
Expand Down
2 changes: 1 addition & 1 deletion src/nft/components/explore/TrendingCollections.tsx
Expand Up @@ -155,7 +155,7 @@ const TrendingCollections = () => {
</Selector>
</Filter>
</FiltersRow>
<CollectionTable data={trendingCollections} />
<CollectionTable data={trendingCollections} timePeriod={timePeriod} />
</ExploreContainer>
)
}
Expand Down

1 comment on commit 72a8270

@vercel
Copy link

@vercel vercel bot commented on 72a8270 Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

interface – ./

interface-git-main-uniswap.vercel.app
interface-uniswap.vercel.app

Please sign in to comment.