Commit 72a82700 authored by Mike Grabowski's avatar Mike Grabowski Committed by GitHub

fix: do not show floor/volume change on all (#5214)

* fix: do not show floor/volume change on all

* chore: nit

* chore: add new type of cell and fix lint

* chore: one more place
parent 62575092
...@@ -129,6 +129,8 @@ export const EthCell = ({ ...@@ -129,6 +129,8 @@ export const EthCell = ({
) )
} }
export const TextCell = ({ value }: { value: string }) => <ThemedText.BodyPrimary>{value}</ThemedText.BodyPrimary>
export const VolumeCell = ({ export const VolumeCell = ({
value, value,
denomination, denomination,
......
import { BigNumber } from '@ethersproject/bignumber' import { BigNumber } from '@ethersproject/bignumber'
import { CollectionTableColumn, TimePeriod } from 'nft/types'
import { useMemo } from 'react' import { useMemo } from 'react'
import { CellProps, Column, Row } from 'react-table' import { CellProps, Column, Row } from 'react-table'
import { CollectionTableColumn } from '../../types' import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, TextCell, VolumeCell } from './Cells/Cells'
import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, VolumeCell } from './Cells/Cells'
import { Table } from './Table' import { Table } from './Table'
export enum ColumnHeaders { export enum ColumnHeaders {
...@@ -20,7 +20,7 @@ const compareFloats = (a: number, b: number): 1 | -1 => { ...@@ -20,7 +20,7 @@ const compareFloats = (a: number, b: number): 1 | -1 => {
return Math.round(a * 100000) >= Math.round(b * 100000) ? 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(() => { const floorSort = useMemo(() => {
return (rowA: Row<CollectionTableColumn>, rowB: Row<CollectionTableColumn>) => { return (rowA: Row<CollectionTableColumn>, rowB: Row<CollectionTableColumn>) => {
const aFloor = BigNumber.from(rowA.original.floor.value ?? 0) const aFloor = BigNumber.from(rowA.original.floor.value ?? 0)
...@@ -76,9 +76,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => { ...@@ -76,9 +76,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
Header: ColumnHeaders.FloorChange, Header: ColumnHeaders.FloorChange,
accessor: ({ floor }) => floor.value, accessor: ({ floor }) => floor.value,
sortDescFirst: true, sortDescFirst: true,
disableSortBy: timePeriod === TimePeriod.AllTime,
sortType: floorChangeSort, sortType: floorChangeSort,
Cell: function changeCell(cell: CellProps<CollectionTableColumn>) { 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} />
)
}, },
}, },
{ {
...@@ -102,9 +107,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => { ...@@ -102,9 +107,14 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
Header: ColumnHeaders.VolumeChange, Header: ColumnHeaders.VolumeChange,
accessor: ({ volume }) => volume.value, accessor: ({ volume }) => volume.value,
sortDescFirst: true, sortDescFirst: true,
disableSortBy: timePeriod === TimePeriod.AllTime,
sortType: volumeChangeSort, sortType: volumeChangeSort,
Cell: function changeCell(cell: CellProps<CollectionTableColumn>) { 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} />
)
}, },
}, },
{ {
...@@ -125,7 +135,7 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => { ...@@ -125,7 +135,7 @@ const CollectionTable = ({ data }: { data: CollectionTableColumn[] }) => {
}, },
}, },
], ],
[floorChangeSort, floorSort, volumeChangeSort, volumeSort] [floorChangeSort, floorSort, volumeChangeSort, volumeSort, timePeriod]
) )
return ( return (
<> <>
......
...@@ -43,15 +43,15 @@ const StyledLoadingRow = styled.tr` ...@@ -43,15 +43,15 @@ const StyledLoadingRow = styled.tr`
height: 80px; height: 80px;
` `
const StyledHeader = styled.th<{ isFirstHeader: boolean }>` const StyledHeader = styled.th<{ disabled?: boolean }>`
${({ isFirstHeader }) => !isFirstHeader && `cursor: pointer;`} ${({ disabled }) => !disabled && `cursor: pointer;`}
:hover { :hover {
${({ theme, isFirstHeader }) => !isFirstHeader && `opacity: ${theme.opacity.hover};`} ${({ theme, disabled }) => !disabled && `opacity: ${theme.opacity.hover};`}
} }
:active { :active {
${({ theme, isFirstHeader }) => !isFirstHeader && `opacity: ${theme.opacity.click};`} ${({ theme, disabled }) => !disabled && `opacity: ${theme.opacity.click};`}
} }
` `
...@@ -154,7 +154,7 @@ export function Table<D extends Record<string, unknown>>({ ...@@ -154,7 +154,7 @@ export function Table<D extends Record<string, unknown>>({
textAlign: index === 0 ? 'left' : 'right', textAlign: index === 0 ? 'left' : 'right',
paddingLeft: index === 0 ? (isMobile ? '16px' : '52px') : 0, paddingLeft: index === 0 ? (isMobile ? '16px' : '52px') : 0,
}} }}
isFirstHeader={index === 0} disabled={column.disableSortBy}
key={index} key={index}
> >
<Box as="span" color="accentAction" position="relative"> <Box as="span" color="accentAction" position="relative">
...@@ -240,7 +240,7 @@ function LoadingTable({ headerGroups, visibleColumns, ...props }: LoadingTablePr ...@@ -240,7 +240,7 @@ function LoadingTable({ headerGroups, visibleColumns, ...props }: LoadingTablePr
textAlign: index === 0 ? 'left' : 'right', textAlign: index === 0 ? 'left' : 'right',
paddingLeft: index === 0 ? '52px' : 0, paddingLeft: index === 0 ? '52px' : 0,
}} }}
isFirstHeader={index === 0} disabled={index === 0}
key={index} key={index}
> >
<Box as="span" color="accentAction" position="relative"> <Box as="span" color="accentAction" position="relative">
......
...@@ -155,7 +155,7 @@ const TrendingCollections = () => { ...@@ -155,7 +155,7 @@ const TrendingCollections = () => {
</Selector> </Selector>
</Filter> </Filter>
</FiltersRow> </FiltersRow>
<CollectionTable data={trendingCollections} /> <CollectionTable data={trendingCollections} timePeriod={timePeriod} />
</ExploreContainer> </ExploreContainer>
) )
} }
......
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