aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Amount.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-04 12:42:42 -0800
committerAdam Soltys <[email protected]>2026-02-11 15:34:19 -0800
commit78c201d8d9d2f3ec07f6ea36201977846e29ccd9 (patch)
tree413d697c2cfa9d3e867c791e161183bad958ed86 /src/components/Amount.svelte
parent882c3bd3fd01b6001172c61e0d2227d962254c62 (diff)
downloadcoinos-ui-78c201d8d9d2f3ec07f6ea36201977846e29ccd9.tar.gz
coinos-ui-78c201d8d9d2f3ec07f6ea36201977846e29ccd9.zip
homepage design and currency toggling
Diffstat (limited to 'src/components/Amount.svelte')
-rw-r--r--src/components/Amount.svelte59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/components/Amount.svelte b/src/components/Amount.svelte
index e5aeabde..7dea7cf1 100644
--- a/src/components/Amount.svelte
+++ b/src/components/Amount.svelte
@@ -9,56 +9,57 @@
rate,
currency,
locked = false,
- showFiat = true,
} = $props();
const icon = $derived(locked ? "ph:lock-fill" : "ph:lightning-fill");
+ const canShowFiat = $derived($fiat && rate && currency);
+
+ const toggleFiat = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ $fiat = !$fiat;
+ };
+
</script>
{#if typeof amount !== "undefined"}
<div>
<h2
- class="text-2xl md:text-3xl font-semibold flex items-end cursor-copy"
+ class="text-2xl md:text-3xl font-semibold flex items-end"
class:justify-center={align !== "left"}
>
<button
type="button"
class="flex items-center"
- onclick={() => copy(amount)}
- aria-label="Copy amount"
+ onclick={toggleFiat}
+ aria-label="Toggle currency display"
>
- <iconify-icon noobserver {icon} class="text-yellow-300"
- ></iconify-icon>{s(amount, locale)}
+ {#if !canShowFiat}
+ <iconify-icon
+ noobserver
+ icon={icon}
+ class="text-yellow-300"
+ ></iconify-icon>
+ {/if}
+ {#if canShowFiat}
+ {f(toFiat(amount, rate), currency, locale)}
+ {:else}
+ {s(amount, locale)}
+ {/if}
</button>
{#if tip}
<div class="flex items-center text-lg ml-2">
<div>+</div>
- <iconify-icon noobserver {icon} class="text-yellow-300"
- ></iconify-icon>
- <div>{s(tip, locale)}</div>
+ <div class="font-semibold">
+ {#if canShowFiat}
+ {f(toFiat(tip, rate), currency, locale)}
+ {:else}
+ {s(tip, locale)}
+ {/if}
+ </div>
</div>
{/if}
</h2>
- {#if showFiat}
- <h3
- class="flex text-secondary md:text-lg cursor-copy items-center gap-1"
- class:justify-center={align !== "left"}
- >
- <button
- type="button"
- class="flex items-center gap-1"
- onclick={() => copy(toFiat(amount, rate).toFixed(2))}
- aria-label="Copy fiat amount"
- >
- {f(toFiat(amount, rate), currency, locale)}
- {#if tip}
- <span class="text-base">
- +{f(toFiat(tip, rate), currency, locale)}
- </span>
- {/if}
- </button>
- </h3>
- {/if}
</div>
{/if}