aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-08-20 13:42:50 -0700
committerAdam Soltys <[email protected]>2025-08-20 13:42:50 -0700
commitc0ba00eae40dde1811fcb52099840b2b42120271 (patch)
tree31c6f8fd778315dc4b7dad23b7135564a6932b31 /src/components
parente129c615b1b46ea307a00994c84cb2ed086d8c51 (diff)
downloadcoinos-ui-c0ba00eae40dde1811fcb52099840b2b42120271.tar.gz
coinos-ui-c0ba00eae40dde1811fcb52099840b2b42120271.zip
numpad fixes
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Numpad.svelte67
-rw-r--r--src/components/SetAmount.svelte10
2 files changed, 59 insertions, 18 deletions
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 @@
<div class="flex justify-center items-center">
<div class="space-y-5 w-full">
<div class="text-center">
- <div class="text-5xl md:text-6xl font-semibold tracking-widest flex justify-center">
+ <div
+ class="text-5xl md:text-6xl font-semibold tracking-widest flex justify-center"
+ >
<div class="my-auto" class:text-5xl={!fiat}>
{#if fiat}
{#if position === "before"}{symbol}{/if}
{:else}
- <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300"></iconify-icon>
+ <iconify-icon
+ noobserver
+ icon="ph:lightning-fill"
+ class="text-yellow-300"
+ ></iconify-icon>
{/if}
</div>
@@ -279,7 +302,11 @@
}}
>
{#if fiat}
- <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300"></iconify-icon>
+ <iconify-icon
+ noobserver
+ icon="ph:lightning-fill"
+ class="text-yellow-300"
+ ></iconify-icon>
{s(amount, locale)}
{:else}
{f(amountFiat, currency, locale)}
@@ -290,15 +317,29 @@
<div class="grid grid-cols-3 gap-2 w-full mx-auto">
{#each numPad as value}
{#if value === arrow}
- <button type="button" class="btn" aria-label="Backspace" onclick={(e) => {
- e.preventDefault(); e.stopPropagation(); handleInput(value);
- }}>
+ <button
+ type="button"
+ class="btn"
+ aria-label="Backspace"
+ onclick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ handleInput(value);
+ }}
+ >
<Left />
</button>
{:else}
- <button type="button" class="btn" aria-label={`Key ${value}`} onclick={(e) => {
- e.preventDefault(); e.stopPropagation(); handleInput(value);
- }}>
+ <button
+ type="button"
+ class="btn"
+ aria-label={`Key ${value}`}
+ onclick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ handleInput(value);
+ }}
+ >
{value}
</button>
{/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();