aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Balance.svelte
blob: 0e4f2ec2645aac8381dc4c79494fac29837f40cf (plain) (blame)
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
<script>
	import { Pin } from '$comp';
	import { f, s, sat, sats } from '$lib/utils';
	import { animatedRate, pin } from '$lib/store';
	import { t } from '$lib/translations';

	let show;
	export let user;
</script>

{#if show && user.haspin && $pin?.length !== 6}
	<Pin cancel={() => (show = false)} />
{/if}

<div class="space-y-2">
	{#if user.haspin && !$pin}
		<button
			class="text-sm md:text-lg rounded-full border py-2 px-4 hover:opacity-80 min-w-[72px] bg-black text-white"
			on:click={() => (show = true)}>{$t('user.showBalance')}</button
		>
	{:else}
		<div class="text-5xl font-bold tabular-nums">
			{#if isNaN($animatedRate)}
				<div class="text-gray-200">&mdash;</div>
			{:else}
				{f((user.balance * $animatedRate) / sats, user.currency)}
			{/if}
		</div>

		<div class="text-secondary text-2xl">
			⚡️{s(user.balance)}
		</div>
	{/if}
</div>