Skip to content

Commit

Permalink
fix: swap console logs, closes #4438
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf authored and kyranjamie committed Oct 30, 2023
1 parent dc209c2 commit e8fa72f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 27 deletions.
30 changes: 30 additions & 0 deletions src/app/pages/swap/components/select-asset-trigger-button.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<LeatherButton onClick={onChooseAsset} p="space.02" variant="ghost" {...field}>
<HStack>
{icon && <styled.img src={icon} width="32px" height="32px" alt="Swap asset" />}
<styled.span textStyle="label.01">{symbol}</styled.span>
<ChevronDownIcon />
</HStack>
</LeatherButton>
);
}
Original file line number Diff line number Diff line change
@@ -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 (
<styled.label
_focusWithin={{ border: 'action-primary-default' }}
Expand All @@ -28,12 +22,10 @@ export function SelectedAssetField({
width="100%"
>
<Box width="100%">
<Field as="div" name={name}>
<HStack alignItems="center" justifyContent="space-between">
{contentLeft}
{contentRight}
</HStack>
</Field>
<HStack alignItems="center" justifyContent="space-between">
{contentLeft}
{contentRight}
</HStack>
</Box>
</styled.label>
);
Expand Down
5 changes: 4 additions & 1 deletion src/app/pages/swap/components/swap-amount-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? (
<styled.span color={showError ? 'error' : 'accent.text-subdued'} textStyle="caption.02">
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/swap/components/swap-details/swap-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<HStack gap="space.01" key={route.name}>
<styled.span>{route.name}</styled.span>
{insertIcon && <ChevronUpIcon transform="rotate(90)" />}
</>
</HStack>
);
});
}
Expand Down
19 changes: 9 additions & 10 deletions src/app/pages/swap/components/swap-selected-asset.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -58,15 +58,14 @@ export function SwapSelectedAssetLayout({
<styled.span textStyle="label.01">{title}</styled.span>
{showToggle && <SwapToggleButton />}
</HStack>
<SelectedAssetField
<SelectedAsset
contentLeft={
<LeatherButton onClick={onChooseAsset} p="space.02" variant="ghost">
<HStack>
{icon && <styled.img src={icon} width="32px" height="32px" alt="Swap asset" />}
<styled.span textStyle="label.01">{symbol}</styled.span>
<ChevronDownIcon />
</HStack>
</LeatherButton>
<SelectAssetTriggerButton
icon={icon}
name={name}
onChooseAsset={onChooseAsset}
symbol={symbol}
/>
}
contentRight={swapAmountInput}
name={name}
Expand Down

0 comments on commit e8fa72f

Please sign in to comment.