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 +++--- 2 files changed, 59 insertions(+), 18 deletions(-) (limited to 'src/components') 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(); -- cgit v1.2.3