-
Notifications
You must be signed in to change notification settings - Fork 103
/
AccountSwitcher.svelte
44 lines (40 loc) · 1.8 KB
/
AccountSwitcher.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script lang="typescript">
import { sumBalanceForAccounts } from '@core/account'
import { localize } from '@core/i18n'
import { BASE_TOKEN } from '@core/network'
import { activeProfile, visibleActiveAccounts } from '@core/profile'
import { formatTokenAmountBestMatch } from '@core/wallet'
import features from '@features/features'
import { AccountSwitcherMenuItem } from '@components'
import { HR, Icon, Text, TextType } from '@ui'
export let onSwitch: () => unknown = () => {}
export let onAddClick: () => unknown = () => {}
$: totalBalance = sumBalanceForAccounts($visibleActiveAccounts)
</script>
<div class="felx-auto overflow-y-auto flex flex-col w-full">
<account-list class="accounts flex flex-col scrollable-y">
{#each $visibleActiveAccounts as account}
<AccountSwitcherMenuItem id="account-{account.index}" {account} onClick={onSwitch} />
{/each}
</account-list>
<HR />
<div class="flex flex-row-reverse h-16">
<Text classes="opacity-50 m-auto w-full text-right" type={TextType.h5}>
{localize('general.total', {
values: {
balance: formatTokenAmountBestMatch(totalBalance, BASE_TOKEN[$activeProfile.networkProtocol]),
},
})}
</Text>
{#if features?.dashboard?.createAccount?.enabled}
<button class="h-full" on:click={onAddClick}>
<div class="flex flex-row items-center space-x-4">
<Icon icon="plus" height="12" width="12" classes="text-blue-500" />
<Text highlighted type={TextType.h5} classes="whitespace-nowrap"
>{localize('general.addAWallet')}</Text
>
</div>
</button>
{/if}
</div>
</div>