Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve token list #2157

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/pages/TrueSightV2/components/TokenListVariants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Icon from 'components/Icons/Icon'

export default function TokenListVariants({
tokens,
iconSize = 12,
}: {
tokens: Array<{ address: string; logo: string; chain: string }>
iconSize?: number
}) {
return (
<>
{tokens.map((item, index) => {
const key = item.address + '_' + index
switch (item.chain) {
case 'ethereum':
return <Icon key={key} id="eth-mono" size={iconSize} title="Ethereum" />
case 'bsc':
return <Icon key={key} id="bnb-mono" size={iconSize} title="Binance" />
case 'avalanche':
return <Icon key={key} id="ava-mono" size={iconSize} title="Avalanche" />
case 'polygon':
return <Icon key={key} id="matic-mono" size={iconSize} title="Polygon" />
case 'arbitrum':
return <Icon key={key} id="arbitrum-mono" size={iconSize} title="Arbitrum" />
case 'fantom':
return <Icon key={key} id="fantom-mono" size={iconSize} title="Fantom" />
case 'optimism':
return <Icon key={key} id="optimism-mono" size={iconSize} title="Optimism" />
default:
return <></>
}
})}
</>
)
}
23 changes: 3 additions & 20 deletions src/pages/TrueSightV2/components/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import SimpleTooltip from '../SimpleTooltip'
import SmallKyberScoreMeter from '../SmallKyberScoreMeter'
import TimeFrameLegend from '../TimeFrameLegend'
import TokenChart from '../TokenChartSVG'
import TokenListVariants from '../TokenListVariants'
import { StarWithAnimation } from '../WatchlistStar'

const TableWrapper = styled.div`
Expand Down Expand Up @@ -698,16 +699,7 @@ const WidgetTokenRow = ({
{token.symbol}
</Text>{' '}
<RowFit gap="6px" color={theme.text}>
{token.tokens.map(item => {
if (item.chain === 'ethereum') return <Icon id="eth-mono" size={10} title="Ethereum" />
if (item.chain === 'bsc') return <Icon id="bnb-mono" size={10} title="Binance" />
if (item.chain === 'avalanche') return <Icon id="ava-mono" size={10} title="Avalanche" />
if (item.chain === 'polygon') return <Icon id="matic-mono" size={10} title="Polygon" />
if (item.chain === 'arbitrum') return <Icon id="arbitrum-mono" size={10} title="Arbitrum" />
if (item.chain === 'fantom') return <Icon id="fantom-mono" size={10} title="Fantom" />
if (item.chain === 'optimism') return <Icon id="optimism-mono" size={10} title="Optimism" />
return <></>
})}
<TokenListVariants tokens={token.tokens} iconSize={10} />
</RowFit>
</Column>
</RowFit>
Expand Down Expand Up @@ -757,16 +749,7 @@ const WidgetTokenRow = ({
<Column gap="4px" style={{ cursor: 'pointer', alignItems: 'flex-start' }}>
<Text style={{ textTransform: 'uppercase' }}>{token.symbol}</Text>{' '}
<RowFit gap="6px" color={theme.text}>
{token.tokens.map(item => {
if (item.chain === 'ethereum') return <Icon id="eth-mono" size={12} title="Ethereum" />
if (item.chain === 'bsc') return <Icon id="bnb-mono" size={12} title="Binance" />
if (item.chain === 'avalanche') return <Icon id="ava-mono" size={12} title="Avalanche" />
if (item.chain === 'polygon') return <Icon id="matic-mono" size={12} title="Polygon" />
if (item.chain === 'arbitrum') return <Icon id="arbitrum-mono" size={12} title="Arbitrum" />
if (item.chain === 'fantom') return <Icon id="fantom-mono" size={12} title="Fantom" />
if (item.chain === 'optimism') return <Icon id="optimism-mono" size={12} title="Optimism" />
return <></>
})}
<TokenListVariants tokens={token.tokens} />
</RowFit>
</Column>
</Row>
Expand Down
1 change: 1 addition & 0 deletions src/pages/TrueSightV2/pages/TechnicalAnalysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { defaultExplorePageToken } from './SingleToken'
const Wrapper = styled.div`
padding: 20px 0;
width: 100%;
position: relative;
`

type TechnicalAnalysisContextProps = {
Expand Down
45 changes: 24 additions & 21 deletions src/pages/TrueSightV2/pages/TokenAnalysisList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ReactComponent as DropdownSVG } from 'assets/svg/down.svg'
import { ButtonGray, ButtonLight, ButtonOutlined } from 'components/Button'
import Column from 'components/Column'
import Icon from 'components/Icons/Icon'
import AnimatedLoader from 'components/Loader/AnimatedLoader'
import Pagination from 'components/Pagination'
import Row, { RowBetween, RowFit } from 'components/Row'
import { APP_PATHS, ICON_ID } from 'constants/index'
Expand All @@ -34,6 +35,7 @@ import NetworkSelect from '../components/NetworkSelect'
import SimpleTooltip from '../components/SimpleTooltip'
import SmallKyberScoreMeter from '../components/SmallKyberScoreMeter'
import TokenChart from '../components/TokenChartSVG'
import TokenListVariants from '../components/TokenListVariants'
import { StarWithAnimation } from '../components/WatchlistStar'
import KyberScoreChart from '../components/chart/KyberScoreChart'
import TokenAnalysisListShareContent from '../components/shareContent/TokenAnalysisListShareContent'
Expand Down Expand Up @@ -549,7 +551,7 @@ const TokenRow = ({

const latestKyberScore: IKyberScoreChart | undefined = token?.ks_3d?.[token.ks_3d.length - 1]
return (
<tr key={token.sourceTokenId} ref={rowRef} onClick={handleRowClick} style={{ position: 'relative' }}>
<tr key={token.SourceTokenID} ref={rowRef} onClick={handleRowClick} style={{ position: 'relative' }}>
<td>
<RowFit gap="6px">
<SimpleTooltip
Expand All @@ -559,7 +561,7 @@ const TokenRow = ({
hideOnMobile
>
<StarWithAnimation
key={token.sourceTokenId}
key={token.SourceTokenID}
watched={isWatched}
loading={loadingStar}
onClick={handleWatchlistClick}
Expand All @@ -586,23 +588,7 @@ const TokenRow = ({
<Column gap="8px" style={{ cursor: 'pointer', alignItems: 'flex-start' }}>
<Text style={{ textTransform: 'uppercase' }}>{token.symbol}</Text>{' '}
<RowFit gap="6px" color={theme.text}>
{token.tokens.map(item => {
if (item.chain === 'ethereum')
return <Icon key={'eth-mono' + index} id="eth-mono" size={12} title="Ethereum" />
if (item.chain === 'bsc')
return <Icon key={'bnb-mono' + index} id="bnb-mono" size={12} title="Binance" />
if (item.chain === 'avalanche')
return <Icon key={'ava-mono' + index} id="ava-mono" size={12} title="Avalanche" />
if (item.chain === 'polygon')
return <Icon key={'matic-mono' + index} id="matic-mono" size={12} title="Polygon" />
if (item.chain === 'arbitrum')
return <Icon key={'arbitrum-mono' + index} id="arbitrum-mono" size={12} title="Arbitrum" />
if (item.chain === 'fantom')
return <Icon key={'fantom-mono' + index} id="fantom-mono" size={12} title="Fantom" />
if (item.chain === 'optimism')
return <Icon key={'optimism-mono' + index} id="optimism-mono" size={12} title="Optimism" />
return <></>
})}
<TokenListVariants tokens={token.tokens} />
</RowFit>
</Column>
</Row>
Expand Down Expand Up @@ -884,7 +870,24 @@ export default function TokenAnalysisList() {
<NetworkSelect filter={Number(chain) as ChainId} setFilter={handleChainChange} />
</RowFit>
</RowBetween>
<Column gap="0px">
<Column gap="0px" style={{ position: 'relative' }}>
{isFetching && (
<div
style={{
position: 'absolute',
inset: '0 0 0 0',
background: theme.background,
opacity: 0.8,
zIndex: 100,
borderRadius: '20px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<AnimatedLoader />
</div>
)}
<TableWrapper ref={wrapperRef}>
<Table ref={tableRef}>
<colgroup>
Expand Down Expand Up @@ -1057,7 +1060,7 @@ export default function TokenAnalysisList() {
listData.map((token: ITokenList, index: number) => (
<TokenRow
token={token}
key={token.sourceTokenId}
key={token.SourceTokenID + '_' + (pageSize * (page - 1) + index + 1)}
currentTab={listType}
index={pageSize * (page - 1) + index + 1}
isScrolling={isScrolling}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TrueSightV2/types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface ITokenOverview {
export interface ITokenList {
symbol: string
name: string
sourceTokenId: string
SourceTokenID: string
tokens: Array<{ address: string; logo: string; chain: string }>
price: number
percent_change_24h: number
Expand Down
Loading