From 7bd39ca6f942c146a6e21be625c03bef84c1d3ee Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 30 Oct 2022 22:11:10 -0700 Subject: revamped tip prompt --- src/components/Tip.svelte | 200 +++++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 92 deletions(-) (limited to 'src/components') diff --git a/src/components/Tip.svelte b/src/components/Tip.svelte index 6af1e00a..c915da80 100644 --- a/src/components/Tip.svelte +++ b/src/components/Tip.svelte @@ -6,9 +6,9 @@ import { tick } from 'svelte'; import { goto } from '$app/navigation'; - export let amountFiat, showMobileTip, tipPercent, tipAmount, amount, currency, tip, username; + export let amountFiat, showMobileTip, tipPercent, tipAmount, amount, currency, tip, username, rate; - const tipAmounts = ['None', '10%', '15%', '20%']; + const tipAmounts = ['No thanks', '10%', '15%', '20%']; let showCustomAmount; let customInput; @@ -19,10 +19,12 @@ tipPercent = (customTipAmount / amountFiat) * 100; showMobileTip = false; showCustomAmount = false; - update(); } }; + let active = (amount) => + !customTipAmount && Math.round(tipPercent) === parseInt(amount.slice(0, 2)); + const handleCustomTipAmount = (e) => { tipPercent = 0; customTipAmount = e.target.value; @@ -40,116 +42,126 @@ timeout = setTimeout(update, 800); }; - const handleTipButtonClick = (amount) => { - customTipAmount = ''; - if (customInput) { - customInput.value = ''; - } - - if (amount === 'None') { + let submitting; + const handleTipButtonClick = async (amount) => { + submitting = true; + if (amount === 'No thanks') { tipPercent = 0; } else { tipPercent = parseInt(amount.slice(0, 2)); } - showMobileTip = false; - update(); + + await tick(); + submit.click(); }; let submit; let update = async () => { await tick(); - submit.click(); + //submit.click(); }; -
-
- - - - - -

{$t('invoice.addTipq')}

- {#if !showCustomAmount} -
- {f(tipAmount, currency)} - {`(${s(tip)} SAT)`} -
{Math.round(tipPercent)}%
+ + + + + + + +

{$t('invoice.addTipq')}

+ {#if !showCustomAmount} +
{Math.round(tipPercent)}%
+ + (showMobileTip = false)} + /> + +
+
+ + {f(amountFiat, currency)} + +{f(tipAmount, currency)}
- (showMobileTip = false)} - /> - {#each tipAmounts as amount} +
+ {s(amount)} + +{s(tip)} SAT +
+
+ + {#if tip} +
submit.click()}>Next - {/each} - -
(tipPercent = 0)}>Reset
- {/if} - - handleTipButtonClick(amount)}>{amount} - -
- + {/each} + {/if} + +
+ +
{/if} -
- + +{/if} -- cgit v1.2.3