From ff3e9f4bca62e33da0bee63177751e372b01d9ec Mon Sep 17 00:00:00 2001 From: Aryeh Harris Date: Fri, 29 Sep 2023 18:25:31 -0400 Subject: [PATCH] UI Updates (#20) * Auto select all text in input on focus * Expand slider to take up full row * Format large numbers to have commas * Use steps for the range slider --- src/components/Faucet/FaucetRequestButton.tsx | 78 +++++++++++++------ .../Faucet/FaucetToInputRequest.tsx | 3 +- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/components/Faucet/FaucetRequestButton.tsx b/src/components/Faucet/FaucetRequestButton.tsx index c1310ae..604e496 100644 --- a/src/components/Faucet/FaucetRequestButton.tsx +++ b/src/components/Faucet/FaucetRequestButton.tsx @@ -28,6 +28,7 @@ export default function FaucetRequestButton({ status: StatusContext }) { const [amount, setAmount] = useState(minTez) + const formattedAmount = amount.toLocaleString() const [isLocalLoading, setLocalLoading] = useState(false) const recaptchaRef: RefObject = useRef(null) @@ -216,6 +217,29 @@ export default function FaucetRequestButton({ return {} } + const computeStep = () => { + const magnitude = Math.floor(Math.log10(maxTez)) + + switch (magnitude) { + case 1: + case 2: + return 1 + case 3: + return 10 + case 4: + return 100 + case 5: + return 1_000 + case 6: + return 10_000 + default: + return 100_000 + } + } + + const currentStep = computeStep() + const adjustedMin = Math.ceil(minTez / currentStep) * currentStep + return ( <> - - - Select Tez Amount - - - {minTez} - - - - - + Select Tez Amount + + + + {minTez.toLocaleString()} + + + + + + - - {maxTez} - - + + + {maxTez.toLocaleString()} + + - + + e.target.select()} /> - +