diff --git a/packages/wallets/src/App.tsx b/packages/wallets/src/App.tsx index 41793dc31d1b..bd56d16fc119 100644 --- a/packages/wallets/src/App.tsx +++ b/packages/wallets/src/App.tsx @@ -1,11 +1,11 @@ import React, { lazy, useMemo, useState } from 'react'; import { APIProvider } from '@deriv/api-v2'; import { initializeI18n, TranslationProvider } from '@deriv-com/translations'; -import { Loader } from '@deriv-com/ui'; import { ModalProvider } from './components/ModalProvider'; import useLanguage from './hooks/useLanguage'; import AppContent from './AppContent'; import WalletsAuthProvider from './AuthProvider'; +import { WalletLoader } from './components'; import { TLanguageType } from './types'; import './styles/fonts.scss'; import './index.scss'; @@ -47,7 +47,7 @@ const App: React.FC = ({ - }> + }> {!isWalletsOnboardingTourGuideVisible && Notifications && } = ({ {isWalletsOnboardingTourGuideVisible && ( - }> + }> diff --git a/packages/wallets/src/components/Base/WalletLoader/WalletLoader.scss b/packages/wallets/src/components/Base/WalletLoader/WalletLoader.scss new file mode 100644 index 000000000000..3a5de582c6a0 --- /dev/null +++ b/packages/wallets/src/components/Base/WalletLoader/WalletLoader.scss @@ -0,0 +1,53 @@ +/** @define barspinner */ +.wallets-barspinner { + margin: auto; + width: 6rem; + height: 2rem; + white-space: nowrap; + + &__rect { + margin: 0.4rem; + border-radius: 20px; + height: 40%; + width: 0.6rem; + display: inline-block; + @include createBarspinnerAnimation(5, 1.2s, 0.1); + } +} + +@keyframes sk-stretchdelay { + 0%, + 40%, + 100% { + transform: scaleY(1); + } + 20% { + transform: scaleY(2); + } +} + +/** @define initial-loader */ +.wallets-initial-loader { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + flex-direction: column; + display: flex; + background: transparent; + + &--fullscreen { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + + &__barspinner { + margin: 5rem auto; + + &--rect { + background-color: var(--brand-secondary); + } + } +} diff --git a/packages/wallets/src/components/Base/WalletLoader/WalletLoader.tsx b/packages/wallets/src/components/Base/WalletLoader/WalletLoader.tsx new file mode 100644 index 000000000000..65856b570bf4 --- /dev/null +++ b/packages/wallets/src/components/Base/WalletLoader/WalletLoader.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import classNames from 'classnames'; +import './WalletLoader.scss'; + +type TWalletLoaderProps = { + className?: string; + isFullScreen?: boolean; +}; + +const WalletLoader: React.FC = ({ className, isFullScreen = true }) => { + return ( +
+
+ {Array.from(new Array(5)).map((_, idx) => ( +
+ ))} +
+
+ ); +}; + +export default WalletLoader; diff --git a/packages/wallets/src/components/Base/WalletLoader/index.ts b/packages/wallets/src/components/Base/WalletLoader/index.ts new file mode 100644 index 000000000000..dc77ca8c4d9c --- /dev/null +++ b/packages/wallets/src/components/Base/WalletLoader/index.ts @@ -0,0 +1 @@ +export { default as WalletLoader } from './WalletLoader'; diff --git a/packages/wallets/src/components/Base/WalletPasswordFieldLazy/WalletPasswordFieldLazy.tsx b/packages/wallets/src/components/Base/WalletPasswordFieldLazy/WalletPasswordFieldLazy.tsx index 4e496bf32f15..48e876478f00 100644 --- a/packages/wallets/src/components/Base/WalletPasswordFieldLazy/WalletPasswordFieldLazy.tsx +++ b/packages/wallets/src/components/Base/WalletPasswordFieldLazy/WalletPasswordFieldLazy.tsx @@ -1,5 +1,5 @@ import React, { lazy, Suspense } from 'react'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../WalletLoader'; import { WalletTextFieldProps } from '../WalletTextField/WalletTextField'; export interface WalletPasswordFieldProps extends WalletTextFieldProps { @@ -16,7 +16,7 @@ const WalletPasswordFieldLazyContainer = lazy( ) as React.FC; const WalletPasswordFieldLazy: React.FC = props => ( - }> + }> ); diff --git a/packages/wallets/src/components/Base/index.ts b/packages/wallets/src/components/Base/index.ts index feb198794077..a4b165bec6e7 100644 --- a/packages/wallets/src/components/Base/index.ts +++ b/packages/wallets/src/components/Base/index.ts @@ -9,5 +9,6 @@ export * from './WalletButtonGroup'; export * from './WalletClipboard'; export * from './WalletDialog'; export * from './WalletLink'; +export * from './WalletLoader'; export * from './WalletPasswordFieldLazy'; export * from './WalletTextField'; diff --git a/packages/wallets/src/features/cashier/WalletCashier.tsx b/packages/wallets/src/features/cashier/WalletCashier.tsx index 66e3066325a0..1720b15adcb8 100644 --- a/packages/wallets/src/features/cashier/WalletCashier.tsx +++ b/packages/wallets/src/features/cashier/WalletCashier.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from 'react'; import { useActiveWalletAccount } from '@deriv/api-v2'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../../components'; import { WalletCashierContent, WalletCashierHeader } from './components'; import { CashierScrollContext } from './context'; import './WalletCashier.scss'; @@ -21,7 +21,7 @@ const WalletCashier = () => { [onCashierScroll] ); - if (isLoading) return ; + if (isLoading) return ; return (
diff --git a/packages/wallets/src/features/cashier/__tests__/WalletCashier.spec.tsx b/packages/wallets/src/features/cashier/__tests__/WalletCashier.spec.tsx index 49ff8c0b2b8d..60ae44e79154 100644 --- a/packages/wallets/src/features/cashier/__tests__/WalletCashier.spec.tsx +++ b/packages/wallets/src/features/cashier/__tests__/WalletCashier.spec.tsx @@ -8,8 +8,9 @@ jest.mock('@deriv/api-v2', () => ({ useActiveWalletAccount: jest.fn(), })); -jest.mock('@deriv-com/ui', () => ({ - Loader: jest.fn(() =>
Loading...
), +jest.mock('../../../components', () => ({ + ...jest.requireActual('../../../components'), + WalletLoader: () =>
Loading...
, })); jest.mock('../components/', () => ({ diff --git a/packages/wallets/src/features/cashier/flows/WalletDeposit/WalletDeposit.tsx b/packages/wallets/src/features/cashier/flows/WalletDeposit/WalletDeposit.tsx index 1e8629e34822..686cff4d8752 100644 --- a/packages/wallets/src/features/cashier/flows/WalletDeposit/WalletDeposit.tsx +++ b/packages/wallets/src/features/cashier/flows/WalletDeposit/WalletDeposit.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { useActiveWalletAccount } from '@deriv/api-v2'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import { DepositCryptoModule, DepositFiatModule } from '../../modules'; const WalletDeposit = () => { const { data: activeWallet } = useActiveWalletAccount(); - if (!activeWallet?.currency_config) return ; + if (!activeWallet?.currency_config) return ; const isCryptoProvider = activeWallet.currency_config.platform.cashier.includes('crypto'); diff --git a/packages/wallets/src/features/cashier/flows/WalletTransfer/WalletTransfer.tsx b/packages/wallets/src/features/cashier/flows/WalletTransfer/WalletTransfer.tsx index 08bd462a197c..4f9389084147 100644 --- a/packages/wallets/src/features/cashier/flows/WalletTransfer/WalletTransfer.tsx +++ b/packages/wallets/src/features/cashier/flows/WalletTransfer/WalletTransfer.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect } from 'react'; import { useTransferBetweenAccounts } from '@deriv/api-v2'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import { TransferModule } from '../../modules'; import { TransferNotAvailable } from '../../screens/TransferNotAvailable'; @@ -13,7 +13,7 @@ const WalletTransfer = () => { requestTransferAccounts(); }, [requestTransferAccounts]); - if (isTransferAccountsLoading || !data?.accounts) return ; + if (isTransferAccountsLoading || !data?.accounts) return ; return ( diff --git a/packages/wallets/src/features/cashier/flows/WalletTransfer/__tests__/WalletTransfer.spec.tsx b/packages/wallets/src/features/cashier/flows/WalletTransfer/__tests__/WalletTransfer.spec.tsx index 4ec6c9ab8b1a..1d8e39457718 100644 --- a/packages/wallets/src/features/cashier/flows/WalletTransfer/__tests__/WalletTransfer.spec.tsx +++ b/packages/wallets/src/features/cashier/flows/WalletTransfer/__tests__/WalletTransfer.spec.tsx @@ -4,8 +4,9 @@ import { render, screen } from '@testing-library/react'; import { CashierLocked } from '../../../modules'; import WalletTransfer from '../WalletTransfer'; -jest.mock('@deriv-com/ui', () => ({ - Loader: jest.fn(() =>
Loading...
), +jest.mock('../../../../../components', () => ({ + ...jest.requireActual('../../../../../components'), + WalletLoader: () =>
Loading...
, })); jest.mock('../../../modules', () => ({ diff --git a/packages/wallets/src/features/cashier/flows/WalletWithdrawal/WalletWithdrawal.tsx b/packages/wallets/src/features/cashier/flows/WalletWithdrawal/WalletWithdrawal.tsx index ec9fe1b084b3..60ef48e62f3e 100644 --- a/packages/wallets/src/features/cashier/flows/WalletWithdrawal/WalletWithdrawal.tsx +++ b/packages/wallets/src/features/cashier/flows/WalletWithdrawal/WalletWithdrawal.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useActiveWalletAccount, useAuthorize } from '@deriv/api-v2'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import useAllBalanceSubscription from '../../../../hooks/useAllBalanceSubscription'; import { WithdrawalCryptoModule, WithdrawalFiatModule, WithdrawalVerificationModule } from '../../modules'; import { WithdrawalNoBalance } from '../../screens'; @@ -42,7 +42,7 @@ const WalletWithdrawal = () => { }, [activeWallet?.loginid, switchAccount]); if (!activeWallet || isBalanceLoading) { - return ; + return ; } if (balanceData && !isBalanceLoading && balanceData[activeWallet?.loginid ?? 'USD'].balance <= 0) { diff --git a/packages/wallets/src/features/cashier/flows/WalletWithdrawal/__tests__/WalletWithdrawal.spec.tsx b/packages/wallets/src/features/cashier/flows/WalletWithdrawal/__tests__/WalletWithdrawal.spec.tsx index b2c2ab11be5a..f979a8c57938 100644 --- a/packages/wallets/src/features/cashier/flows/WalletWithdrawal/__tests__/WalletWithdrawal.spec.tsx +++ b/packages/wallets/src/features/cashier/flows/WalletWithdrawal/__tests__/WalletWithdrawal.spec.tsx @@ -5,6 +5,11 @@ import useAllBalanceSubscription from '../../../../../hooks/useAllBalanceSubscri import { CashierLocked, WithdrawalLocked } from '../../../modules'; import WalletWithdrawal from '../WalletWithdrawal'; +jest.mock('../../../../../components', () => ({ + ...jest.requireActual('../../../../../components'), + WalletLoader: () =>
Loading...
, +})); + jest.mock('../../../modules', () => ({ ...jest.requireActual('../../../modules'), CashierLocked: jest.fn(({ children }) => <>{children}), @@ -32,10 +37,6 @@ jest.mock('../../../screens', () => ({ WithdrawalNoBalance: jest.fn(() =>
WithdrawalNoBalance
), })); -jest.mock('@deriv-com/ui', () => ({ - Loader: jest.fn(() =>
Loading...
), -})); - const mockSwitchAccount = jest.fn(); jest.mock('@deriv/api-v2', () => ({ ...jest.requireActual('@deriv/api-v2'), diff --git a/packages/wallets/src/features/cashier/modules/CashierLocked/CashierLocked.tsx b/packages/wallets/src/features/cashier/modules/CashierLocked/CashierLocked.tsx index 83d757cbab99..493a07747cea 100644 --- a/packages/wallets/src/features/cashier/modules/CashierLocked/CashierLocked.tsx +++ b/packages/wallets/src/features/cashier/modules/CashierLocked/CashierLocked.tsx @@ -8,7 +8,8 @@ import { usePOI, } from '@deriv/api-v2'; import { Localize } from '@deriv-com/translations'; -import { ActionScreen, Loader } from '@deriv-com/ui'; +import { ActionScreen } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import getCashierLockedDesc, { getSystemMaintenanceContent } from './CashierLockedContent'; import './CashierLocked.scss'; @@ -79,7 +80,7 @@ const CashierLocked: React.FC = ({ children, module }) => { }); if (isLoading) { - return ; + return ; } if (isSystemMaintenance && systemMaintenanceContent) { diff --git a/packages/wallets/src/features/cashier/modules/CashierLocked/__tests__/CashierLocked.spec.tsx b/packages/wallets/src/features/cashier/modules/CashierLocked/__tests__/CashierLocked.spec.tsx index e2ea95cd90e2..5f897c3ee45b 100644 --- a/packages/wallets/src/features/cashier/modules/CashierLocked/__tests__/CashierLocked.spec.tsx +++ b/packages/wallets/src/features/cashier/modules/CashierLocked/__tests__/CashierLocked.spec.tsx @@ -20,9 +20,9 @@ jest.mock('@deriv/api-v2', () => ({ usePOI: jest.fn(), })); -jest.mock('@deriv-com/ui', () => ({ - ...jest.requireActual('@deriv-com/ui'), - Loader: jest.fn(() =>
Loading...
), +jest.mock('../../../../../components', () => ({ + ...jest.requireActual('../../../../../components'), + WalletLoader: () =>
Loading...
, })); jest.mock('../CashierLockedContent', () => ({ diff --git a/packages/wallets/src/features/cashier/modules/DepositCrypto/DepositCrypto.tsx b/packages/wallets/src/features/cashier/modules/DepositCrypto/DepositCrypto.tsx index b3e5c01d53c4..e67f1965f473 100644 --- a/packages/wallets/src/features/cashier/modules/DepositCrypto/DepositCrypto.tsx +++ b/packages/wallets/src/features/cashier/modules/DepositCrypto/DepositCrypto.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { useActiveWalletAccount, useCurrencyConfig, useDepositCryptoAddress } from '@deriv/api-v2'; -import { Divider, Loader, useDevice } from '@deriv-com/ui'; +import { Divider, useDevice } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import { isServerError } from '../../../../utils/utils'; import { DepositErrorScreen } from '../../screens'; import { TransactionStatus } from '../TransactionStatus'; @@ -21,7 +22,7 @@ const DepositCrypto = () => { const isTUSDT = activeWallet?.currency && getConfig(activeWallet.currency)?.is_tUSDT; const isOnrampAvailable = activeWallet?.currency_config && activeWallet.currency_config.platform.ramp.length > 0; - if (isLoading) return ; + if (isLoading) return ; if (isServerError(depositCryptoError)) { return ; diff --git a/packages/wallets/src/features/cashier/modules/DepositFiat/DepositFiat.tsx b/packages/wallets/src/features/cashier/modules/DepositFiat/DepositFiat.tsx index 9566700e2385..e1747be7ec0a 100644 --- a/packages/wallets/src/features/cashier/modules/DepositFiat/DepositFiat.tsx +++ b/packages/wallets/src/features/cashier/modules/DepositFiat/DepositFiat.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useAuthorize, useCashierFiatAddress } from '@deriv/api-v2'; -import { Loader } from '@deriv-com/ui'; +import { WalletLoader } from '../../../../components'; import { isServerError } from '../../../../utils/utils'; import { DepositErrorScreen } from '../../screens'; import './DepositFiat.scss'; @@ -22,7 +22,7 @@ const DepositFiat: React.FC = () => { } }, [isAuthorizeSuccess, mutateDepositFiat]); - if (isDepositFiatLoading) return ; + if (isDepositFiatLoading) return ; if (isServerError(depositFiatError)) { return ; @@ -30,7 +30,7 @@ const DepositFiat: React.FC = () => { return ( - {isIframeLoading && } + {isIframeLoading && } {iframeUrl && (