diff options
Diffstat (limited to 'src/components/Amount.svelte')
| -rw-r--r-- | src/components/Amount.svelte | 59 |
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} |
