aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Amount.svelte4
-rw-r--r--src/components/Balance.svelte5
-rw-r--r--src/components/Numpad.svelte67
3 files changed, 11 insertions, 65 deletions
diff --git a/src/components/Amount.svelte b/src/components/Amount.svelte
index 46aa2d1b..035152d1 100644
--- a/src/components/Amount.svelte
+++ b/src/components/Amount.svelte
@@ -11,7 +11,7 @@
>
<div class="flex items-center">
<iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
- ></iconify-icon>{s(amount)}
+ ></iconify-icon>{s(amount, locale)}
</div>
{#if tip}
@@ -19,7 +19,7 @@
<div>+</div>
<iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
></iconify-icon>
- <div>{s(tip)}</div>
+ <div>{s(tip, locale)}</div>
</div>
{/if}
</h2>
diff --git a/src/components/Balance.svelte b/src/components/Balance.svelte
index 33597c18..28bd69b3 100644
--- a/src/components/Balance.svelte
+++ b/src/components/Balance.svelte
@@ -6,6 +6,7 @@
let show = $state();
let { user, rate, balance } = $props();
+ let locale = loc(user);
let toggleShow = (e) => {
e.preventDefault();
e.stopPropagation();
@@ -27,14 +28,14 @@
<div class="text-4xl font-bold flex items-center">
<iconify-icon icon="ph:lightning-fill" width="32" class="text-yellow-300"
></iconify-icon>
- {s(balance)}
+ {s(balance, locale)}
</div>
<div class="text-secondary text-xl">
{#if isNaN(rate)}
<div class="text-gray-200">&mdash;</div>
{:else}
- {f(toFiat(balance, rate), user.currency, loc(user))}
+ {f(toFiat(balance, rate), user.currency, locale)}
{/if}
</div>
{/if}
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte
index e813a24b..f694679a 100644
--- a/src/components/Numpad.svelte
+++ b/src/components/Numpad.svelte
@@ -72,65 +72,9 @@
];
const handleInput = (value) => {
- if (selecting) amount = 0;
- selecting = false;
-
- if ($fiat) {
- if (
- amountFiat === 0 &&
- value !== decimal &&
- value !== "<" &&
- value !== "0"
- ) {
- amountFiat = value;
- } else if ((amountFiat === 0 || amountFiat === "0") && value === "0") {
- return;
- } else if (amountFiat === 0 && value === decimal) {
- amountFiat = `0${decimal}`;
- } else if (
- amountFiat !== 0 &&
- amountFiat.includes(decimal) &&
- value === decimal
- ) {
- return;
- } else if (value === "<") {
- if (amountFiat !== 0) {
- amountFiat = amountFiat.slice(0, amountFiat.length - 1);
- if (amountFiat.length === 0) {
- amountFiat = 0;
- amount = 0;
- }
- }
- } else if (
- value !== decimal &&
- value !== "<" &&
- parseInt(amountFiat + value) > rate
- ) {
- warning($t("user.receive.lessThan1BTCWarning"));
- } else if (amountFiat !== 0 && amountFiat.match(/\.../)) {
- return;
- } else {
- amountFiat = amountFiat + value;
- }
- } else {
- if (value === decimal) {
- return;
- } else if (!amount && value !== "<" && value !== "0") {
- amount = parseInt(value);
- } else if (value === "<") {
- if (amount !== 0) {
- amount = Math.floor(amount / 10);
- if (amount.length === 0) {
- amount = 0;
- amountFiat = 0;
- }
- }
- } else if (value !== "<" && parseInt(amount + value) > sats) {
- warning($t("user.receive.lessThan1BTCWarning"));
- } else {
- amount = parseInt(amount.toString() + value);
- }
- }
+ if (value === "<") html = html.substr(0, html.length - 1);
+ else html += value;
+ input();
};
$: html = $fiat ? amountFiat : s(amount);
@@ -196,10 +140,11 @@
if (html.length < prev.length && p === 1 && i > 1) i--;
}
- let node = e.target.childNodes[0];
+ let node = element.childNodes[0];
let range = document.createRange();
if (node) {
+ if (i > node.length) i = node.length;
range.setStart(node, i);
range.setEnd(node, i);
@@ -280,7 +225,7 @@
{#if $fiat}
<iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
></iconify-icon>
- {s(amount)}
+ {s(amount, locale)}
{:else}
{f(amountFiat, currency, locale)}
{/if}