From c0ba00eae40dde1811fcb52099840b2b42120271 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 20 Aug 2025 13:42:50 -0700 Subject: numpad fixes --- src/components/Numpad.svelte | 67 +++++++++++++++++----- src/components/SetAmount.svelte | 10 ++-- src/routes/(app)/[username]/receive/+page.svelte | 2 +- src/routes/(app)/fund/[id]/withdraw/+page.svelte | 8 ++- .../(app)/send/bitcoin/[address]/+page.svelte | 5 +- .../[address]/[amount]/[...feeRate]/+page.svelte | 22 +++++-- .../send/fund/[...name]/[...amount]/+page.svelte | 5 +- 7 files changed, 88 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 00547e6a..8ebbfdf1 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -3,14 +3,15 @@ import Left from "$comp/Left.svelte"; import { f, s, focus, warning, sat, sats } from "$lib/utils"; import { t } from "$lib/translations"; + import { fiat as fiatStore } from "$lib/store"; // ---- Props (Svelte 5 runes) ---- let { - amount = $bindable(0), + amount = $bindable(), currency = "USD", - fiat = $bindable(true), + fiat = $bindable(), element, - rate, + rate = $bindable(), locale, submit = undefined, amountFiat = 0, @@ -217,12 +218,28 @@ sel.removeAllRanges(); sel.addRange(range); }); + + $fiatStore = fiat; }; const arrow = "<"; - const numPad = ["1","2","3","4","5","6","7","8","9","00","0",arrow]; + const numPad = [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "00", + "0", + arrow, + ]; onMount(() => { + fiat = $fiatStore; if (fiat) { const cents = Math.round((parseFloat(amountFiat || "0") || 0) * 100); fiatDigits = Math.max(0, cents).toString(); @@ -237,12 +254,18 @@
-
+
{#if fiat} {#if position === "before"}{symbol}{/if} {:else} - + {/if}
@@ -279,7 +302,11 @@ }} > {#if fiat} - + {s(amount, locale)} {:else} {f(amountFiat, currency, locale)} @@ -290,15 +317,29 @@
{#each numPad as value} {#if value === arrow} - {:else} - {/if} diff --git a/src/components/SetAmount.svelte b/src/components/SetAmount.svelte index a453b9d1..536c8e24 100644 --- a/src/components/SetAmount.svelte +++ b/src/components/SetAmount.svelte @@ -6,13 +6,13 @@ let submit = $state(); let { - currency = $bindable(), - fiat = $bindable(), - locale = $bindable(), - rate = $bindable(), + currency = $bindable("USD"), + fiat = $bindable(true), + locale = $bindable("en-US"), + rate = $bindable(0), settingAmount, setAmount, - newAmount = $bindable(), + newAmount = $bindable(0), toggleAmount, t, } = $props(); diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte index 9b7ffc00..cd692abf 100644 --- a/src/routes/(app)/[username]/receive/+page.svelte +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -99,7 +99,7 @@ await update(); }; - let newAmount = $state(); + let newAmount = $state(0); let settingAmount = $state(); let fiat = $state(true); let toggleAmount = () => (settingAmount = !settingAmount); diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte index 78f9b16c..69a74a3f 100644 --- a/src/routes/(app)/fund/[id]/withdraw/+page.svelte +++ b/src/routes/(app)/fund/[id]/withdraw/+page.svelte @@ -6,15 +6,17 @@ import Numpad from "$comp/Numpad.svelte"; import Spinner from "$comp/Spinner.svelte"; import { page } from "$app/stores"; - import { s } from "$lib/utils"; + import { loc, s } from "$lib/utils"; import { fiat, pin } from "$lib/store"; let { data, form } = $props(); - let { currency } = $derived(data.user); + let { user } = $derived(data); + let { currency } = $derived(user); let loading = $state(); let { id, balance, rate } = $derived(data); let { amount } = $state(data); + let locale = loc(user); let submit = $state(); let submitting = $state(); @@ -39,7 +41,7 @@ {/if}
- +
diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/+page.svelte index 671de954..529e2691 100644 --- a/src/routes/(app)/send/bitcoin/[address]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/+page.svelte @@ -5,13 +5,14 @@ import Numpad from "$comp/Numpad.svelte"; import { page } from "$app/stores"; import { rate } from "$lib/store"; - import { fail, s } from "$lib/utils"; + import { loc, fail, s } from "$lib/utils"; let { data } = $props(); let { balance, user } = data; let { address } = $page.params; let { currency, username } = user; + let locale = loc(user); let amount = $state(0); let a = $state(0); @@ -34,7 +35,7 @@
{address}
- +