feat: add floor change on mobile (#5302)
* few more tweaks * remove extra code
This commit is contained in:
parent
54a7b943ce
commit
da01254247
@ -120,9 +120,12 @@ export const EthCell = ({
|
|||||||
: ethNumberStandardFormatter(denominatedValue, true, false, true)
|
: ethNumberStandardFormatter(denominatedValue, true, false, true)
|
||||||
: '-'
|
: '-'
|
||||||
|
|
||||||
|
const isMobile = useIsMobile()
|
||||||
|
const TextComponent = isMobile ? ThemedText.BodySmall : ThemedText.BodyPrimary
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EthContainer>
|
<EthContainer>
|
||||||
<ThemedText.BodyPrimary>{value ? formattedValue : '-'}</ThemedText.BodyPrimary>
|
<TextComponent>{value ? formattedValue : '-'}</TextComponent>
|
||||||
</EthContainer>
|
</EthContainer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -153,15 +156,17 @@ export const VolumeCell = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChangeCell = ({ change, children }: { children?: ReactNode; change?: number }) => (
|
export const ChangeCell = ({ change, children }: { children?: ReactNode; change?: number }) => {
|
||||||
<ChangeCellContainer change={change ?? 0}>
|
const isMobile = useIsMobile()
|
||||||
{!change || change > 0 ? (
|
const TextComponent = isMobile ? ThemedText.Caption : ThemedText.BodyPrimary
|
||||||
<SquareArrowUpIcon width="20px" height="20px" />
|
return (
|
||||||
) : (
|
<ChangeCellContainer change={change ?? 0}>
|
||||||
<SquareArrowDownIcon width="20px" height="20px" />
|
{!change || change > 0 ? (
|
||||||
)}
|
<SquareArrowUpIcon width="20px" height="20px" />
|
||||||
<ThemedText.BodyPrimary color="currentColor">
|
) : (
|
||||||
{children || `${change ? Math.abs(Math.round(change)) : 0}%`}
|
<SquareArrowDownIcon width="20px" height="20px" />
|
||||||
</ThemedText.BodyPrimary>
|
)}
|
||||||
</ChangeCellContainer>
|
<TextComponent color="currentColor">{children || `${change ? Math.abs(Math.round(change)) : 0}%`}</TextComponent>
|
||||||
)
|
</ChangeCellContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'
|
|||||||
import { CollectionTableColumn, TimePeriod } from 'nft/types'
|
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 { MediumOnly } from 'theme/components'
|
||||||
|
|
||||||
import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, TextCell, VolumeCell } from './Cells/Cells'
|
import { ChangeCell, CollectionTitleCell, DiscreteNumberCell, EthCell, TextCell, VolumeCell } from './Cells/Cells'
|
||||||
import { Table } from './Table'
|
import { Table } from './Table'
|
||||||
@ -65,11 +66,18 @@ const CollectionTable = ({ data, timePeriod }: { data: CollectionTableColumn[];
|
|||||||
sortType: floorSort,
|
sortType: floorSort,
|
||||||
Cell: function ethCell(cell: CellProps<CollectionTableColumn>) {
|
Cell: function ethCell(cell: CellProps<CollectionTableColumn>) {
|
||||||
return (
|
return (
|
||||||
<EthCell
|
<>
|
||||||
value={cell.row.original.floor.value}
|
<EthCell
|
||||||
denomination={cell.row.original.denomination}
|
value={cell.row.original.floor.value}
|
||||||
usdPrice={cell.row.original.usdPrice}
|
denomination={cell.row.original.denomination}
|
||||||
/>
|
usdPrice={cell.row.original.usdPrice}
|
||||||
|
/>
|
||||||
|
{timePeriod !== TimePeriod.AllTime && (
|
||||||
|
<MediumOnly>
|
||||||
|
<ChangeCell change={cell.row.original.floor.change} />
|
||||||
|
</MediumOnly>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -130,11 +130,11 @@ export function Table<D extends Record<string, unknown>>({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!width) return
|
if (!width) return
|
||||||
|
|
||||||
if (width < theme.breakpoint.sm) {
|
if (width <= theme.breakpoint.sm) {
|
||||||
setHiddenColumns(smallHiddenColumns)
|
setHiddenColumns(smallHiddenColumns)
|
||||||
} else if (width < theme.breakpoint.md) {
|
} else if (width <= theme.breakpoint.md) {
|
||||||
setHiddenColumns(mediumHiddenColumns)
|
setHiddenColumns(mediumHiddenColumns)
|
||||||
} else if (width < theme.breakpoint.lg) {
|
} else if (width <= theme.breakpoint.lg) {
|
||||||
setHiddenColumns(largeHiddenColumns)
|
setHiddenColumns(largeHiddenColumns)
|
||||||
} else {
|
} else {
|
||||||
setHiddenColumns([])
|
setHiddenColumns([])
|
||||||
|
@ -465,6 +465,13 @@ export const SmallOnly = styled.span`
|
|||||||
`};
|
`};
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const MediumOnly = styled.span`
|
||||||
|
display: none;
|
||||||
|
@media (max-width: ${({ theme }) => theme.breakpoint.md}px) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export const Separator = styled.div`
|
export const Separator = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
|
@ -14,12 +14,19 @@ type TextProps = Omit<TextPropsOriginal, 'css'>
|
|||||||
// todo: export each component individually
|
// todo: export each component individually
|
||||||
|
|
||||||
export const ThemedText = {
|
export const ThemedText = {
|
||||||
|
// todo: there should be just one `Body` with default color, no need to make all variations
|
||||||
BodyPrimary(props: TextProps) {
|
BodyPrimary(props: TextProps) {
|
||||||
return <TextWrapper fontWeight={400} fontSize={16} color="textPrimary" {...props} />
|
return <TextWrapper fontWeight={400} fontSize={16} color="textPrimary" {...props} />
|
||||||
},
|
},
|
||||||
BodySecondary(props: TextProps) {
|
BodySecondary(props: TextProps) {
|
||||||
return <TextWrapper fontWeight={400} fontSize={16} color="textSecondary" {...props} />
|
return <TextWrapper fontWeight={400} fontSize={16} color="textSecondary" {...props} />
|
||||||
},
|
},
|
||||||
|
BodySmall(props: TextProps) {
|
||||||
|
return <TextWrapper fontWeight={400} fontSize={14} color="textPrimary" {...props} />
|
||||||
|
},
|
||||||
|
Caption(props: TextProps) {
|
||||||
|
return <TextWrapper fontWeight={400} fontSize={12} color="textPrimary" {...props} />
|
||||||
|
},
|
||||||
HeadlineSmall(props: TextProps) {
|
HeadlineSmall(props: TextProps) {
|
||||||
return <TextWrapper fontWeight={600} fontSize={20} lineHeight="28px" color="textPrimary" {...props} />
|
return <TextWrapper fontWeight={600} fontSize={20} lineHeight="28px" color="textPrimary" {...props} />
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user