Skip to content

Commit

Permalink
Show all available tokens in asset selector. (wormhole-foundation#2533)
Browse files Browse the repository at this point in the history
* [Redesign]: Show all available tokens with a scroll

* fix(redesign): reduce token address clickable area
  • Loading branch information
nikarm22 committed Sep 6, 2024
1 parent 443ba3c commit 53af315
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type SearchableListProps<T> = {
listTitle?: ReactNode;
searchPlaceholder?: string;
className?: string;
initialItems?: T[]; // Items to render when search is not performed
items: T[];
loading?: ReactNode;
renderFn: (item: T, index: number) => ReactNode;
Expand All @@ -35,11 +34,7 @@ function SearchableList<T>(props: SearchableListProps<T>): ReactNode {
const [query, setQuery] = useState('');

const filteredList = useMemo(() => {
if (!query && props.initialItems) {
return props.initialItems;
} else {
return props.items.filter((item) => props.filterFn(item, query));
}
return props.items.filter((item) => props.filterFn(item, query));
}, [props.items, props.filterFn, query]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const useStyles = makeStyles()(() => ({
display: 'inline-flex',
alignItems: 'center',
marginLeft: 4,
height: '10px',
overflow: 'hidden',
},
}));

Expand Down
12 changes: 4 additions & 8 deletions wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const TokenList = (props: Props) => {
props.tokenList || [],
);

const topTokens = useMemo(() => {
const sortedTokens = useMemo(() => {
const { selectedToken, selectedChainConfig } = props;

const selectedTokenConfig = selectedToken
Expand Down Expand Up @@ -142,11 +142,8 @@ const TokenList = (props: Props) => {
return;
}

const tokenNotAdded = !tokens.find(
(addedToken) => addedToken.key === t.key,
);

if (tokens.length < SHORT_LIST_SIZE && tokenNotAdded) {
// Adding remaining tokens
if (!tokenSet.has(t.key)) {
addToken(t);
}
});
Expand All @@ -170,8 +167,7 @@ const TokenList = (props: Props) => {
</ListItemButton>
)
}
initialItems={topTokens}
items={props.tokenList ?? []}
items={sortedTokens}
filterFn={(token, query) => {
if (query.length === 0) return true;

Expand Down

0 comments on commit 53af315

Please sign in to comment.