-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
316 additions
and
205 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
13 changes: 13 additions & 0 deletions
13
packages/widget/src/components/SwapInProgress/SwapInProgress.style.ts
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,13 @@ | ||
import { styled } from '@mui/material/styles'; | ||
import { CardContainer, CardHeader } from '../Card'; | ||
|
||
export const Card = styled(CardContainer)(({ theme }) => ({ | ||
borderColor: '#F7D4FF', | ||
background: '#FEF0FF', | ||
})); | ||
|
||
export const RouteCard = styled(CardHeader)(({ theme }) => ({ | ||
cursor: 'pointer', | ||
paddingTop: 0, | ||
paddingBottom: 0, | ||
})); |
69 changes: 69 additions & 0 deletions
69
packages/widget/src/components/SwapInProgress/SwapInProgress.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,69 @@ | ||
import { | ||
ArrowForward as ArrowForwardIcon, | ||
KeyboardArrowRight as KeyboardArrowRightIcon, | ||
} from '@mui/icons-material'; | ||
import { Avatar, AvatarGroup, Box, BoxProps, Stack } from '@mui/material'; | ||
import { useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useExecutingRoutes } from '../../hooks'; | ||
import { routes } from '../../utils/routes'; | ||
import { CardTitle } from '../Card'; | ||
import { Card, RouteCard } from './SwapInProgress.style'; | ||
|
||
export const SwapInProgress: React.FC<BoxProps> = (props) => { | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
const executingRoutes = useExecutingRoutes(); | ||
|
||
const handleCardClick = useCallback( | ||
(routeId: string) => { | ||
navigate(routes.swap, { state: { routeId } }); | ||
}, | ||
[navigate], | ||
); | ||
|
||
if (!executingRoutes?.length) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Card {...props}> | ||
<CardTitle>Swaps in progress</CardTitle> | ||
<Stack spacing={2} py={2}> | ||
{executingRoutes.map(({ route, status }) => ( | ||
<RouteCard | ||
key={route.id} | ||
onClick={() => handleCardClick(route.id)} | ||
avatar={ | ||
<AvatarGroup total={2}> | ||
<Avatar | ||
src={route.fromToken.logoURI} | ||
alt={route.fromToken.symbol} | ||
sx={{ background: 'white' }} | ||
> | ||
{route.fromToken.symbol[0]} | ||
</Avatar> | ||
<Avatar | ||
src={route.toToken.logoURI} | ||
alt={route.toToken.symbol} | ||
sx={{ background: 'white' }} | ||
> | ||
{route.toToken.symbol[0]} | ||
</Avatar> | ||
</AvatarGroup> | ||
} | ||
action={<KeyboardArrowRightIcon />} | ||
title={ | ||
<Box sx={{ display: 'flex', alignItems: 'center' }}> | ||
{route.fromToken.symbol} | ||
<ArrowForwardIcon fontSize="small" sx={{ paddingX: 0.5 }} /> | ||
{route.toToken.symbol} | ||
</Box> | ||
} | ||
/> | ||
))} | ||
</Stack> | ||
</Card> | ||
); | ||
}; |
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 @@ | ||
export * from './SwapInProgress'; |
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
154 changes: 86 additions & 68 deletions
154
packages/widget/src/hooks/useRouteExecution/useRouteStore.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Box, Container } from '@mui/material'; | ||
import { styled } from '@mui/system'; | ||
|
||
export const FormContainer = styled(Container)({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
flexGrow: 1, | ||
position: 'relative', | ||
}); | ||
|
||
export const FormBox = styled(Box)(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
paddingTop: theme.spacing(2), | ||
paddingLeft: theme.spacing(3), | ||
paddingRight: theme.spacing(3), | ||
})); |
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,35 @@ | ||
import { Box } from '@mui/material'; | ||
import { ReverseTokensButton } from '../../components/ReverseTokensButton'; | ||
import { SelectTokenButton } from '../../components/SelectTokenButton'; | ||
import { SwapButton } from '../../components/SwapButton'; | ||
import { SwapInProgress } from '../../components/SwapInProgress'; | ||
import { SwapInput } from '../../components/SwapInput'; | ||
import { SwapRoutes } from '../../components/SwapRoutes'; | ||
import { FormBox, FormContainer } from './MainPage.style'; | ||
|
||
export const MainPage: React.FC = () => { | ||
return ( | ||
<FormContainer disableGutters> | ||
<FormBox> | ||
<SwapInProgress mb={3} /> | ||
<SelectTokenButton formType="from" /> | ||
<Box | ||
sx={{ display: 'flex', justifyContent: 'center', height: 40 }} | ||
py={0.5} | ||
> | ||
<ReverseTokensButton /> | ||
</Box> | ||
<Box mb={3}> | ||
<SelectTokenButton formType="to" /> | ||
</Box> | ||
<Box mb={3}> | ||
<SwapInput formType="from" /> | ||
</Box> | ||
<SwapRoutes mb={3} /> | ||
</FormBox> | ||
<Box px={3} pb={3}> | ||
<SwapButton /> | ||
</Box> | ||
</FormContainer> | ||
); | ||
}; |
File renamed without changes.
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 @@ | ||
export * from './MainPage'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.