diff --git a/src/app/pages/swap/components/select-asset-trigger-button.tsx b/src/app/pages/swap/components/select-asset-trigger-button.tsx new file mode 100644 index 00000000000..22200a7a2c3 --- /dev/null +++ b/src/app/pages/swap/components/select-asset-trigger-button.tsx @@ -0,0 +1,30 @@ +import { useField } from 'formik'; +import { HStack, styled } from 'leather-styles/jsx'; + +import { LeatherButton } from '@app/components/button/button'; +import { ChevronDownIcon } from '@app/components/icons/chevron-down-icon'; + +interface SelectAssetTriggerButtonProps { + icon?: string; + name: string; + onChooseAsset(): void; + symbol: string; +} +export function SelectAssetTriggerButton({ + icon, + name, + onChooseAsset, + symbol, +}: SelectAssetTriggerButtonProps) { + const [field] = useField(name); + + return ( + + + {icon && } + {symbol} + + + + ); +} diff --git a/src/app/pages/swap/components/selected-asset-field.tsx b/src/app/pages/swap/components/selected-asset.tsx similarity index 59% rename from src/app/pages/swap/components/selected-asset-field.tsx rename to src/app/pages/swap/components/selected-asset.tsx index aa47dbe4784..61454c32c23 100644 --- a/src/app/pages/swap/components/selected-asset-field.tsx +++ b/src/app/pages/swap/components/selected-asset.tsx @@ -1,18 +1,12 @@ -import { Field } from 'formik'; import { Box, HStack, styled } from 'leather-styles/jsx'; -interface SelectedAssetFieldProps { +interface SelectedAssetProps { contentLeft: React.JSX.Element; contentRight: React.JSX.Element; name: string; showError?: boolean; } -export function SelectedAssetField({ - contentLeft, - contentRight, - name, - showError, -}: SelectedAssetFieldProps) { +export function SelectedAsset({ contentLeft, contentRight, name, showError }: SelectedAssetProps) { return ( - - - {contentLeft} - {contentRight} - - + + {contentLeft} + {contentRight} + ); diff --git a/src/app/pages/swap/components/swap-amount-field.tsx b/src/app/pages/swap/components/swap-amount-field.tsx index 50a2e44dd60..0b6d1af3495 100644 --- a/src/app/pages/swap/components/swap-amount-field.tsx +++ b/src/app/pages/swap/components/swap-amount-field.tsx @@ -71,7 +71,10 @@ export function SwapAmountField({ amountAsFiat, isDisabled, name }: SwapAmountFi textStyle="heading.05" width="100%" {...field} - onBlur={onBlur} + onBlur={async e => { + field.onBlur(e); + await onBlur(e); + }} /> {amountAsFiat ? ( diff --git a/src/app/pages/swap/components/swap-details/swap-details.tsx b/src/app/pages/swap/components/swap-details/swap-details.tsx index b54e116a527..f5249a84263 100644 --- a/src/app/pages/swap/components/swap-details/swap-details.tsx +++ b/src/app/pages/swap/components/swap-details/swap-details.tsx @@ -19,10 +19,10 @@ function RouteNames(props: { swapSubmissionData: SwapSubmissionData }) { return props.swapSubmissionData.router.map((route, i) => { const insertIcon = isDefined(props.swapSubmissionData.router[i + 1]); return ( - <> + {route.name} {insertIcon && } - + ); }); } diff --git a/src/app/pages/swap/components/swap-selected-asset.layout.tsx b/src/app/pages/swap/components/swap-selected-asset.layout.tsx index 67744f7c936..4af8a1f7aad 100644 --- a/src/app/pages/swap/components/swap-selected-asset.layout.tsx +++ b/src/app/pages/swap/components/swap-selected-asset.layout.tsx @@ -3,10 +3,10 @@ import { Box, HStack, styled } from 'leather-styles/jsx'; import { noop } from '@shared/utils'; import { LeatherButton } from '@app/components/button/button'; -import { ChevronDownIcon } from '@app/components/icons/chevron-down-icon'; import { Tooltip } from '@app/components/tooltip'; -import { SelectedAssetField } from './selected-asset-field'; +import { SelectAssetTriggerButton } from './select-asset-trigger-button'; +import { SelectedAsset } from './selected-asset'; import { SwapToggleButton } from './swap-toggle-button'; function getTextColor(showError?: boolean, onClickHandler?: boolean) { @@ -58,15 +58,14 @@ export function SwapSelectedAssetLayout({ {title} {showToggle && } - - - {icon && } - {symbol} - - - + } contentRight={swapAmountInput} name={name}