From c48495c7d693ed605fabdcebf6318536cb333515 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Fri, 31 May 2024 17:12:01 +0200 Subject: [PATCH 1/3] improve nabla swap design --- .../Form/From/NumericInput/index.tsx | 3 ++ src/components/nabla/Swap/From.tsx | 2 +- src/components/nabla/Swap/To.tsx | 6 ++-- .../nabla/common/AmountSelector.tsx | 21 ++++++------ src/components/nabla/common/NumberInput.tsx | 34 ------------------- 5 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 src/components/nabla/common/NumberInput.tsx diff --git a/src/components/Form/From/NumericInput/index.tsx b/src/components/Form/From/NumericInput/index.tsx index 728f95af..6ff751dd 100644 --- a/src/components/Form/From/NumericInput/index.tsx +++ b/src/components/Form/From/NumericInput/index.tsx @@ -8,6 +8,7 @@ interface NumericInputProps { additionalStyle?: string; maxDecimals?: number; defaultValue?: string; + autoFocus?: boolean; } function isValidNumericInput(value: string): boolean { @@ -42,6 +43,7 @@ export const NumericInput = ({ additionalStyle, maxDecimals = USER_INPUT_MAX_DECIMALS.PENDULUM, defaultValue, + autoFocus, }: NumericInputProps) => (
@@ -64,6 +66,7 @@ export const NumericInput = ({ type="text" inputmode="decimal" value={defaultValue} + autoFocus={autoFocus} {...register} />
diff --git a/src/components/nabla/Swap/From.tsx b/src/components/nabla/Swap/From.tsx index f447a077..24521def 100644 --- a/src/components/nabla/Swap/From.tsx +++ b/src/components/nabla/Swap/From.tsx @@ -66,7 +66,7 @@ export function From - Your Balance: + Balance:
diff --git a/src/components/nabla/common/AmountSelector.tsx b/src/components/nabla/common/AmountSelector.tsx index aab76fc4..f6962be5 100644 --- a/src/components/nabla/common/AmountSelector.tsx +++ b/src/components/nabla/common/AmountSelector.tsx @@ -1,13 +1,14 @@ import { Button, Range } from 'react-daisyui'; -import { FieldPath, FieldValues, PathValue, UseFormReturn, useWatch } from 'react-hook-form'; +import { FieldPath, FieldValues, PathValue, UseFormRegisterReturn, UseFormReturn, useWatch } from 'react-hook-form'; import { useEffect, useMemo } from 'preact/hooks'; import Big from 'big.js'; -import { NumberInput } from './NumberInput'; import { ChangeEvent, ReactNode } from 'preact/compat'; import { fractionOfValue } from '../../../shared/parseNumbers/metric'; import { ContractBalance } from '../../../helpers/contracts'; import { calcSharePercentageNumber } from '../../../helpers/calc'; +import { NumericInput } from '../../Form/From/NumericInput'; +import { USER_INPUT_MAX_DECIMALS } from '../../../shared/parseNumbers/decimal'; interface AmountSelectorProps> { maxBalance: ContractBalance | undefined; @@ -65,11 +66,11 @@ export function AmountSelector ); } @@ -78,11 +79,11 @@ export function AmountSelector
-