-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shayan/feq 2275/add skeleton loader to header (#137)
* feat: added preloader component [WIP] * feat: added preloader component [WIP] * feat: added skeleton loader for header * chore: removed nested ternary * fix: addressed pr comments * fix: addressed pr comments * fix: addressed pr comments * fix: fixed test issue * chore: removed console.log
- Loading branch information
1 parent
2bff9b7
commit b2e10c0
Showing
7 changed files
with
151 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import { api } from '@/hooks'; | ||
import { useActiveAccount } from '@/hooks/api/account'; | ||
import { CurrencyUsdIcon } from '@deriv/quill-icons'; | ||
import { AccountSwitcher as UIAccountSwitcher } from '@deriv-com/ui'; | ||
import { FormatUtils } from '@deriv-com/utils'; | ||
|
||
export const AccountSwitcher = () => { | ||
const { data } = api.account.useActiveAccount(); | ||
type TActiveAccount = NonNullable<ReturnType<typeof useActiveAccount>['data']>; | ||
type TAccountSwitcherProps = { | ||
account: TActiveAccount; | ||
}; | ||
|
||
export const AccountSwitcher = ({ account }: TAccountSwitcherProps) => { | ||
const activeAccount = { | ||
balance: FormatUtils.formatMoney(data?.balance ?? 0), | ||
currency: data?.currency || 'USD', | ||
currencyLabel: data?.currency || 'US Dollar', | ||
balance: FormatUtils.formatMoney(account?.balance ?? 0), | ||
currency: account?.currency || 'USD', | ||
currencyLabel: account?.currency || 'US Dollar', | ||
icon: <CurrencyUsdIcon iconSize='sm' />, | ||
isActive: true, | ||
isVirtual: Boolean(data?.is_virtual), | ||
loginid: data?.loginid || '', | ||
isVirtual: Boolean(account?.is_virtual), | ||
loginid: account?.loginid || '', | ||
}; | ||
return data && <UIAccountSwitcher activeAccount={activeAccount} buttonClassName='mr-4' isDisabled />; | ||
return account && <UIAccountSwitcher activeAccount={activeAccount} buttonClassName='mr-4' isDisabled />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import ContentLoader from 'react-content-loader'; | ||
|
||
type TAccountsInfoLoaderProps = { | ||
isLoggedIn: boolean; | ||
isMobile: boolean; | ||
speed: number; | ||
}; | ||
|
||
const LoggedInPreloader = ({ isMobile }: Pick<TAccountsInfoLoaderProps, 'isMobile'>) => ( | ||
<> | ||
{isMobile ? ( | ||
<> | ||
<circle cx='14' cy='22' r='13' /> | ||
<rect height='7' rx='4' ry='4' width='76' x='35' y='19' /> | ||
<rect height='32' rx='4' ry='4' width='82' x='120' y='6' /> | ||
</> | ||
) : ( | ||
<> | ||
<circle cx='14' cy='22' r='12' /> | ||
<circle cx='58' cy='22' r='12' /> | ||
<rect height='7' rx='4' ry='4' width='76' x='150' y='20' /> | ||
<circle cx='118' cy='24' r='13' /> | ||
<rect height='30' rx='4' ry='4' width='1' x='87' y='8' /> | ||
<rect height='32' rx='4' ry='4' width='82' x='250' y='8' /> | ||
</> | ||
)} | ||
</> | ||
); | ||
|
||
export const AccountsInfoLoader = ({ isMobile, speed }: TAccountsInfoLoaderProps) => ( | ||
<ContentLoader | ||
backgroundColor={'#f2f3f4'} | ||
data-testid='dt_accounts_info_loader' | ||
foregroundColor={'#e6e9e9'} | ||
height={isMobile ? 42 : 46} | ||
speed={speed} | ||
width={isMobile ? 216 : 350} | ||
> | ||
<LoggedInPreloader isMobile={isMobile} /> | ||
</ContentLoader> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters