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

fix(wallet): Select Send Loading Skeletons #20026

Merged
merged 1 commit into from
Sep 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ import CloseIcon from '../../../../../assets/svg-icons/close.svg'

// Components
import { TokenListItem } from '../token-list-item/token-list-item'
import {
TokenListItemSkeleton
} from '../token-list-item/token_list_item_skeleton'
import {
LoadingSkeleton
} from '../../../../../components/shared/loading-skeleton/index'
import { NetworkFilterWithSearch } from '../../../../../components/desktop/network-filter-with-search'

// Styled Components
Expand Down Expand Up @@ -265,8 +271,12 @@ export const SelectTokenModal = React.forwardRef<HTMLDivElement, Props>(

// Memos
const emptyTokensList = React.useMemo(() => {
return accounts.map((account) => getTokensBySearchValue(account)).flat(1).length === 0
}, [accounts, getTokensBySearchValue])
return !isLoadingBalances &&
accounts.map(
(account) =>
getTokensBySearchValue(account)
).flat(1).length === 0
}, [accounts, getTokensBySearchValue, isLoadingBalances])

const modalTitle = React.useMemo(() => {
if (selectedSendOption === SendPageTabHashes.nft) {
Expand All @@ -276,6 +286,26 @@ export const SelectTokenModal = React.forwardRef<HTMLDivElement, Props>(
}, [selectedSendOption])

const tokensByAccount = React.useMemo(() => {
if (isLoadingBalances) {
return (
<Column columnWidth='full'>
<AccountSection
rowWidth='full'
verticalPadding={9}
horizontalPadding={16}
>
<LoadingSkeleton width={80} height={14} />
</AccountSection>
<Column
columnWidth='full'
horizontalPadding={8}>
<TokenListItemSkeleton
isNFT={selectedSendOption === SendPageTabHashes.nft}
/>
</Column>
</Column>
)
}
if (emptyTokensList) {
return <Text textSize='14px' isBold={false} textColor='text03'>
{getLocale('braveWalletNoAvailableTokens')}
Expand Down Expand Up @@ -332,7 +362,8 @@ export const SelectTokenModal = React.forwardRef<HTMLDivElement, Props>(
getAccountFiatValue,
emptyTokensList,
selectedSendOption,
tokenBalancesRegistry
tokenBalancesRegistry,
isLoadingBalances
])

// render
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) 2023 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

import * as React from 'react'

// Styled Components
import {
Row,
Column,
VerticalSpace,
HorizontalSpace
} from '../../../../../components/shared/style'
import {
LoadingSkeleton
} from '../../../../../components/shared/loading-skeleton/index'

interface Props {
isNFT: boolean
}

export const TokenListItemSkeleton = (props: Props) => {
const { isNFT } = props
return (
<Row
padding='8px 12px'
justifyContent='space-between'
>
<Row
width='unset'
>
<LoadingSkeleton
circle={true}
width={40}
height={40}
/>
<HorizontalSpace space='16px' />
<Column
alignItems='flex-start'
>
<LoadingSkeleton width={isNFT ? 120 : 80} height={18} />
<VerticalSpace space='2px' />
<LoadingSkeleton width={120} height={18} />
</Column>
</Row>
{!isNFT &&
<Column
alignItems='flex-end'
>
<LoadingSkeleton width={60} height={18} />
<VerticalSpace space='2px' />
<LoadingSkeleton width={40} height={18} />
</Column>
}
</Row>
)
}

export default TokenListItemSkeleton