diff --git a/packages/widget/src/components/SmallAvatar.tsx b/packages/widget/src/components/SmallAvatar.tsx new file mode 100644 index 000000000..2dbe33278 --- /dev/null +++ b/packages/widget/src/components/SmallAvatar.tsx @@ -0,0 +1,9 @@ +import { Avatar } from '@mui/material'; +import { styled } from '@mui/material/styles'; + +export const SmallAvatar = styled(Avatar)(({ theme }) => ({ + background: theme.palette.background.paper, + width: 16, + height: 16, + border: `2px solid ${theme.palette.background.paper}`, +})); diff --git a/packages/widget/src/components/StepActions/StepActions.style.tsx b/packages/widget/src/components/StepActions/StepActions.style.tsx index 5293a9961..867b792c2 100644 --- a/packages/widget/src/components/StepActions/StepActions.style.tsx +++ b/packages/widget/src/components/StepActions/StepActions.style.tsx @@ -44,8 +44,8 @@ export const StepLabel = styled(MuiStepLabel, { })(({ theme }) => ({ padding: 0, [`.${stepLabelClasses.iconContainer}`]: { - paddingLeft: theme.spacing(1.25), - paddingRight: theme.spacing(3.25), + paddingLeft: theme.spacing(0.75), + paddingRight: theme.spacing(2.75), }, [`&.${stepLabelClasses.disabled}`]: { cursor: 'inherit', diff --git a/packages/widget/src/components/StepActions/StepActions.tsx b/packages/widget/src/components/StepActions/StepActions.tsx index fa52f0f44..8eda8aeef 100644 --- a/packages/widget/src/components/StepActions/StepActions.tsx +++ b/packages/widget/src/components/StepActions/StepActions.tsx @@ -1,15 +1,21 @@ import { LifiStep, Step } from '@lifi/sdk'; import { ArrowForward as ArrowForwardIcon } from '@mui/icons-material'; -import { Box, Step as MuiStep, Stepper, Typography } from '@mui/material'; +import { + Box, + Step as MuiStep, + StepIconProps, + Stepper, + Typography, +} from '@mui/material'; import { useTranslation } from 'react-i18next'; import { useChains } from '../../hooks'; +import { ReactComponent as LiFiToolLogo } from '../../icons/LiFiToolLogo.svg'; import { formatTokenAmount } from '../../utils'; -import { LiFiLogo } from '../LiFiLogo'; +import { SmallAvatar } from '../SmallAvatar'; import { StepAvatar, StepConnector, StepContent, - StepIcon, StepLabel, } from './StepActions.style'; import { StepActionsProps } from './types'; @@ -24,18 +30,36 @@ export const StepActions: React.FC = ({ ? CrossStepDetailsLabel : SwapStepDetailsLabel; const isFullView = !dense && (step as LifiStep).includedSteps?.length > 1; + + // eslint-disable-next-line react/no-unstable-nested-components + const StepIconComponent = ({ icon }: StepIconProps) => { + const tool = (step as LifiStep).includedSteps?.[Number(icon) - 1]; + + return tool ? ( + + {tool.toolDetails.name[0]} + + ) : null; + }; + return ( - {step.type === 'lifi' ? : step.toolDetails.name[0]} + {step.type === 'lifi' ? : step.toolDetails.name[0]} = ({ > {(step as LifiStep).includedSteps.map((step) => ( - + {step.type === 'cross' || step.type === 'lifi' ? ( ) : ( diff --git a/packages/widget/src/components/SwapRouteCard/SwapRouteCard.tsx b/packages/widget/src/components/SwapRouteCard/SwapRouteCard.tsx index bd76dc8a5..48516780b 100644 --- a/packages/widget/src/components/SwapRouteCard/SwapRouteCard.tsx +++ b/packages/widget/src/components/SwapRouteCard/SwapRouteCard.tsx @@ -1,7 +1,7 @@ import { Box, BoxProps, Typography } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { StepActions } from '../StepActions'; -import { StepToken } from '../StepToken'; +import { Token } from '../Token'; import { Card, Label } from './SwapRouteCard.style'; import { SwapRouteCardProps } from './types'; @@ -28,10 +28,7 @@ export const SwapRouteCard: React.FC = ({ > - + {!dense ? route.steps.map((step) => ( diff --git a/packages/widget/src/components/StepToken.tsx b/packages/widget/src/components/Token.tsx similarity index 67% rename from packages/widget/src/components/StepToken.tsx rename to packages/widget/src/components/Token.tsx index ca9bd43b4..e2434126a 100644 --- a/packages/widget/src/components/StepToken.tsx +++ b/packages/widget/src/components/Token.tsx @@ -1,14 +1,18 @@ /* eslint-disable react/no-array-index-key */ import { TokenAmount } from '@lifi/sdk'; import { Box, BoxProps, Typography } from '@mui/material'; +import { useTranslation } from 'react-i18next'; +import { useChains } from '../hooks'; import { formatTokenAmount } from '../utils'; import { TextFitter } from './TextFitter'; import { TokenAvatar } from './TokenAvatar'; -export const StepToken: React.FC<{ token: TokenAmount } & BoxProps> = ({ +export const Token: React.FC<{ token: TokenAmount } & BoxProps> = ({ token, ...other }) => { + const { t } = useTranslation(); + const { getChainById } = useChains(); return ( @@ -23,14 +27,16 @@ export const StepToken: React.FC<{ token: TokenAmount } & BoxProps> = ({ - {token.symbol} + {t(`swap.tokenOnChain`, { + tokenSymbol: token.symbol, + chainName: getChainById(token.chainId)?.name, + })} ); diff --git a/packages/widget/src/components/TokenAvatar/TokenAvatar.style.tsx b/packages/widget/src/components/TokenAvatar/TokenAvatar.style.tsx index 5a33df0fc..5cd877434 100644 --- a/packages/widget/src/components/TokenAvatar/TokenAvatar.style.tsx +++ b/packages/widget/src/components/TokenAvatar/TokenAvatar.style.tsx @@ -1,15 +1,8 @@ -import { Avatar, AvatarGroup } from '@mui/material'; +import { AvatarGroup } from '@mui/material'; import { avatarClasses } from '@mui/material/Avatar'; import { badgeClasses } from '@mui/material/Badge'; import { styled } from '@mui/material/styles'; -export const SmallAvatar = styled(Avatar)(({ theme }) => ({ - background: theme.palette.background.paper, - width: 16, - height: 16, - border: `2px solid ${theme.palette.background.paper}`, -})); - export const TokenAvatarGroup = styled(AvatarGroup)(({ theme }) => ({ [`& .${avatarClasses.root}`]: { background: theme.palette.background.paper, diff --git a/packages/widget/src/components/TokenAvatar/TokenAvatar.tsx b/packages/widget/src/components/TokenAvatar/TokenAvatar.tsx index f5fa2531b..f3e87c56a 100644 --- a/packages/widget/src/components/TokenAvatar/TokenAvatar.tsx +++ b/packages/widget/src/components/TokenAvatar/TokenAvatar.tsx @@ -1,7 +1,7 @@ import { Token } from '@lifi/sdk'; import { Avatar, Badge, SxProps, Theme } from '@mui/material'; import { useChain } from '../../hooks'; -import { SmallAvatar } from './TokenAvatar.style'; +import { SmallAvatar } from '../SmallAvatar'; export const TokenAvatar: React.FC<{ token: Token; diff --git a/packages/widget/src/icons/LiFiToolLogo.svg b/packages/widget/src/icons/LiFiToolLogo.svg new file mode 100644 index 000000000..7087bf599 --- /dev/null +++ b/packages/widget/src/icons/LiFiToolLogo.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/packages/widget/src/pages/SwapPage/StatusBottomSheet.tsx b/packages/widget/src/pages/SwapPage/StatusBottomSheet.tsx index 45ed4c348..69d7367e1 100644 --- a/packages/widget/src/pages/SwapPage/StatusBottomSheet.tsx +++ b/packages/widget/src/pages/SwapPage/StatusBottomSheet.tsx @@ -9,7 +9,7 @@ import { useFormContext } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { BottomSheet, BottomSheetBase } from '../../components/BottomSheet'; -import { StepToken } from '../../components/StepToken'; +import { Token } from '../../components/Token'; import { useChains, useTokenBalance } from '../../hooks'; import { SwapFormKey } from '../../providers/SwapFormProvider'; import { RouteExecution } from '../../stores'; @@ -116,7 +116,7 @@ export const StatusBottomSheet: React.FC = ({ {title} {status === 'success' ? ( - - {fromToken ? : null} + {fromToken ? : null} {step.execution?.process.map((process, index) => ( ))} - {toToken ? : null} + {toToken ? : null} );