Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #80 from brave/virtualize-token-list
Browse files Browse the repository at this point in the history
fix(swap): Virtualize Token List
  • Loading branch information
Douglashdaniel authored Oct 27, 2022
2 parents bed3cb4 + 355b3fa commit 9f5ae50
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 22 deletions.
105 changes: 103 additions & 2 deletions interface/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brave/swap-interface",
"version": "0.10.0",
"version": "0.10.1",
"description": "Brave Swap - an open-source swap interface by Brave, focussed on usability and multi-chain support.",
"type": "module",
"license": "MPL-2.0",
Expand Down Expand Up @@ -46,11 +46,14 @@
},
"dependencies": {
"@brave/leo": "github:brave-experiments/leo",
"@brave/react-virtualized-auto-sizer": "^1.0.4",
"@types/react-window": "^1.8.2",
"@types/styled-components": "^5.1.25",
"bignumber.js": "^9.1.0",
"ethereum-blockies": "github:brave/blockies",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-window": "^1.8.5",
"styled-components": "^5.3.5"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions interface/src/components/buttons/token-list-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ export const TokenListButton = (props: Props) => {
}

const Button = styled(StyledButton)`
background-color: ${p => p.theme.color.legacy.background01};
background-color: none;
border-radius: 8px;
justify-content: space-between;
padding: 16px 8px;
white-space: nowrap;
width: 100%;
width: calc(100% - 24px);
margin-left: 12px;
:disabled {
opacity: 0.3;
}
&:hover:not([disabled]) {
box-shadow: var(--token-list-button-shadow);
z-index: 20px;
position: relative;
background-color: ${(p) => p.theme.color.legacy.background01};
}
`
23 changes: 9 additions & 14 deletions interface/src/components/swap/select-token-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import Amount from '~/utils/amount'
import CloseIcon from '~/assets/close-icon.svg'

// Components
import { StandardButton, TokenListButton } from '~/components/buttons'
import { StandardButton } from '~/components/buttons'
import { SearchWithNetworkSelector } from './search-with-network-selector'
import { StandardModal } from '~/components/modals'
import { VirtualizedTokenList } from './virtualized-tokens-list'

// Styled Components
import { Column, Row, Text, VerticalDivider, IconButton } from '~/components/shared.styles'
Expand Down Expand Up @@ -117,22 +118,18 @@ export const SelectTokenModal = React.forwardRef<HTMLDivElement, Props>(
<VerticalDivider />
<ScrollContainer
columnWidth='full'
horizontalPadding={12}
verticalAlign='flex-start'
verticalPadding={8}
>
{filteredTokenList.map(token => (
<TokenListButton
key={token.contractAddress}
onClick={onSelectToken}
balance={getAssetBalance(token)}
{filteredTokenList.length !== 0 && (
<VirtualizedTokenList
disabledToken={disabledToken}
getAssetBalance={getAssetBalance}
isWalletConnected={isWalletConnected}
token={token}
disabled={
disabledToken ? disabledToken.contractAddress === token.contractAddress : false
}
onSelectToken={onSelectToken}
tokenList={filteredTokenList}
/>
))}
)}
</ScrollContainer>
{showZeroBalanceButton && (
<Button
Expand Down Expand Up @@ -160,6 +157,4 @@ const Button = styled(StandardButton)`

const ScrollContainer = styled(Column)`
flex: 1;
overflow-x: hidden;
overflow-y: scroll;
`
Loading

0 comments on commit 9f5ae50

Please sign in to comment.