-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented trade success ui for multi-hop trades
- Loading branch information
1 parent
ac62005
commit 897b7ee
Showing
8 changed files
with
247 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/Hops.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Stack } from '@chakra-ui/react' | ||
import { memo } from 'react' | ||
import { | ||
selectActiveSwapperName, | ||
selectFirstHop, | ||
selectIsActiveQuoteMultiHop, | ||
selectLastHop, | ||
} from 'state/slices/tradeQuoteSlice/selectors' | ||
import { useAppSelector } from 'state/store' | ||
|
||
import { Hop } from './Hop' | ||
|
||
export type HopsProps = { | ||
isFirstHopOpen: boolean | ||
isSecondHopOpen: boolean | ||
onToggleFirstHop?: () => void | ||
onToggleSecondHop?: () => void | ||
} | ||
|
||
export const Hops = memo((props: HopsProps) => { | ||
const { isFirstHopOpen, isSecondHopOpen, onToggleFirstHop, onToggleSecondHop } = props | ||
const swapperName = useAppSelector(selectActiveSwapperName) | ||
const firstHop = useAppSelector(selectFirstHop) | ||
const lastHop = useAppSelector(selectLastHop) | ||
const isMultiHopTrade = useAppSelector(selectIsActiveQuoteMultiHop) | ||
|
||
if (!firstHop || !swapperName) return null | ||
|
||
return ( | ||
<Stack spacing={6}> | ||
<Hop | ||
tradeQuoteStep={firstHop} | ||
swapperName={swapperName} | ||
hopIndex={0} | ||
isOpen={isFirstHopOpen} | ||
onToggleIsOpen={onToggleFirstHop} | ||
/> | ||
{isMultiHopTrade && lastHop && ( | ||
<Hop | ||
tradeQuoteStep={lastHop} | ||
swapperName={swapperName} | ||
hopIndex={1} | ||
isOpen={isSecondHopOpen} | ||
onToggleIsOpen={onToggleSecondHop} | ||
/> | ||
)} | ||
</Stack> | ||
) | ||
}) |
39 changes: 39 additions & 0 deletions
39
src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/TwirlyToggle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ChevronUpIcon } from '@chakra-ui/icons' | ||
import type { BoxProps } from '@chakra-ui/react' | ||
import { Box, Circle, IconButton, useColorModeValue } from '@chakra-ui/react' | ||
import { useMemo } from 'react' | ||
import { useTranslate } from 'react-polyglot' | ||
|
||
export type TwirlyToggleProps = { isOpen: boolean; onToggle: () => void } & BoxProps | ||
|
||
export const TwirlyToggle = ({ isOpen, onToggle, ...boxProps }: TwirlyToggleProps) => { | ||
const translate = useTranslate() | ||
const backgroundColor = useColorModeValue('gray.100', 'gray.750') | ||
|
||
const icon = useMemo( | ||
() => ( | ||
<Circle size={8} bgColor={backgroundColor} borderWidth={0}> | ||
<ChevronUpIcon | ||
transform={isOpen ? 'rotate(180deg)' : 'rotate(0deg)'} | ||
transition='transform 0.2s ease-in-out' | ||
boxSize='16px' | ||
/> | ||
</Circle> | ||
), | ||
[backgroundColor, isOpen], | ||
) | ||
|
||
return ( | ||
<Box width='auto' {...boxProps}> | ||
<IconButton | ||
aria-label={translate('trade.expand')} | ||
variant='link' | ||
borderTopRadius='none' | ||
colorScheme='blue' | ||
onClick={onToggle} | ||
width='full' | ||
icon={icon} | ||
/> | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.