Skip to content

Commit

Permalink
fix: adjust swap/bridge terminology across the widget
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Jun 8, 2023
1 parent cecacb1 commit ca69314
Show file tree
Hide file tree
Showing 55 changed files with 385 additions and 348 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- adjust-terminology

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/src/AppDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const DrawerButtonText = ({ open }: { open: boolean }) => {

return (
<DrawerButtonTypography>
{open ? t('button.hide') : t('button.lifiSwap')}
{open ? t('button.hide') : t('button.lifiExchange')}
</DrawerButtonTypography>
);
};
12 changes: 6 additions & 6 deletions packages/widget/src/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@ export const AppRoutes = () => {
element: <SelectChainPage formType="to" />,
},
{
path: navigationRoutes.swapRoutes,
path: navigationRoutes.routes,
element: <SwapRoutesPage />,
},
{
path: navigationRoutes.activeSwaps,
path: navigationRoutes.activeTransactions,
element: <ActiveSwapsPage />,
},
{
path: navigationRoutes.swapHistory,
path: navigationRoutes.transactionHistory,
element: <SwapHistoryPage />,
},
{
path: `${navigationRoutes.swapHistory}?/${navigationRoutes.swapRoutes}?/${navigationRoutes.swapExecution}?/${navigationRoutes.swapDetails}`,
path: `${navigationRoutes.transactionHistory}?/${navigationRoutes.routes}?/${navigationRoutes.transactionExecution}?/${navigationRoutes.transactionDetails}`,
element: <SwapDetailsPage />,
},
{
path: `${navigationRoutes.swapRoutes}?/${navigationRoutes.swapExecution}?/${navigationRoutes.selectWallet}`,
path: `${navigationRoutes.routes}?/${navigationRoutes.transactionExecution}?/${navigationRoutes.selectWallet}`,
element: <SelectWalletPage />,
},
{
path: `${navigationRoutes.swapRoutes}?/${navigationRoutes.activeSwaps}?/${navigationRoutes.swapExecution}`,
path: `${navigationRoutes.routes}?/${navigationRoutes.activeTransactions}?/${navigationRoutes.transactionExecution}`,
element: <SwapPage />,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ActiveSwapItem: React.FC<{
}

const handleClick = () => {
navigate(navigationRoutes.swapExecution, { state: { routeId } });
navigate(navigationRoutes.transactionExecution, { state: { routeId } });
};

const getStatusComponent = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/widget/src/components/ActiveSwaps/ActiveSwaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export const ActiveSwaps: React.FC<BoxProps> = (props) => {
}

const handleShowAll = () => {
navigate(navigationRoutes.activeSwaps);
navigate(navigationRoutes.activeTransactions);
};

const hasShowAll = executingRoutes?.length > 2;

return (
<Card variant="selected" selectionColor="secondary" {...props}>
<CardTitle>{t('header.activeSwaps')}</CardTitle>
<CardTitle>{t('header.activeTransactions')}</CardTitle>
<Stack spacing={1.5} pt={1.5} pb={hasShowAll ? 0 : 2}>
{executingRoutes.slice(0, 2).map((routeId) => (
<ActiveSwapItem key={routeId} routeId={routeId} dense />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const FundsSufficiencyMessage = () => {
/>
</WarningMessageCardTitle>
<Typography variant="body2" px={2} pb={2} pt={2}>
{t(`swap.warning.message.insufficientFunds`)}
{t(`warning.message.insufficientFunds`)}
</Typography>
</WarningMessageCard>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const GasRefuelMessage: React.FC<BoxProps> = (props) => {
}}
/>
<Typography variant="body2" fontWeight={700}>
{t(`swap.info.title.autoRefuel`)}
{t(`info.title.autoRefuel`)}
</Typography>
</Box>
<InfoMessageSwitch checked={enabledAutoRefuel} onChange={onChange} />
Expand All @@ -56,7 +56,7 @@ export const GasRefuelMessage: React.FC<BoxProps> = (props) => {
mountOnEnter
>
<Typography variant="body2" px={2} pb={2}>
{t(`swap.info.message.autoRefuel`, {
{t(`info.message.autoRefuel`, {
chainName: chain?.name,
})}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const GasSufficiencyMessage: React.FC<GasSufficiencyMessageProps> = ({
}}
/>
<Typography variant="body2" fontWeight={700}>
{t(`swap.warning.title.insufficientGas`)}
{t(`warning.title.insufficientGas`)}
</Typography>
</WarningMessageCardTitle>
<Typography variant="body2" px={2} pt={1}>
{t(`swap.warning.message.insufficientGas`)}
{t(`warning.message.insufficientGas`)}
</Typography>
{insufficientGas?.map((item, index) => (
<Typography
Expand All @@ -39,7 +39,7 @@ export const GasSufficiencyMessage: React.FC<GasSufficiencyMessageProps> = ({
pb={insufficientGas?.length - 1 === index ? 2 : 0}
pt={0.5}
>
{t(`swap.tokenOnChainAmount`, {
{t(`main.tokenOnChainAmount`, {
amount: item.insufficientAmount?.toString(),
tokenSymbol: item.token.symbol,
chainName: item.chain?.name,
Expand Down
34 changes: 18 additions & 16 deletions packages/widget/src/components/Header/NavigationHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import {
import { HeaderAppBar } from './Header.style';
import { NavigationTabs } from './NavigationTabs';
import { WalletMenuButton } from './WalletHeader';
import { useHeaderActionStore } from './useHeaderActionStore';
import { useHeaderStore } from './useHeaderStore';

export const NavigationHeader: React.FC = () => {
const { t } = useTranslation();
const { variant, subvariant, hiddenUI } = useWidgetConfig();
const { navigate, navigateBack } = useNavigateBack();
const { account } = useWallet();
const { element } = useHeaderActionStore();
const { element, title } = useHeaderStore();
const { pathname } = useLocation();

const cleanedPathname = pathname.endsWith('/')
Expand All @@ -43,8 +43,8 @@ export const NavigationHeader: React.FC = () => {
return t(`settings.enabledBridges`);
case navigationRoutes.exchanges:
return t(`settings.enabledExchanges`);
case navigationRoutes.swapHistory:
return t(`header.swapHistory`);
case navigationRoutes.transactionHistory:
return t(`header.transactionHistory`);
case navigationRoutes.fromToken: {
if (variant === 'nft') {
return t(`header.payWith`);
Expand All @@ -57,21 +57,21 @@ export const NavigationHeader: React.FC = () => {
case navigationRoutes.toChain:
case navigationRoutes.toTokenNative:
return t(`header.selectChain`);
case navigationRoutes.swapRoutes:
return t(`header.routes`);
case navigationRoutes.activeSwaps:
return t(`header.activeSwaps`);
case navigationRoutes.swapExecution: {
case navigationRoutes.routes:
return t(`header.youGet`);
case navigationRoutes.activeTransactions:
return t(`header.activeTransactions`);
case navigationRoutes.transactionExecution: {
if (variant === 'nft') {
return t(`header.purchase`);
}
return t(`header.swap`);
return t(`header.exchange`);
}
case navigationRoutes.swapDetails: {
case navigationRoutes.transactionDetails: {
if (variant === 'nft') {
return t(`header.purchaseDetails`);
}
return t(`header.swapDetails`);
return t(`header.transactionDetails`);
}
default: {
switch (variant) {
Expand All @@ -80,7 +80,7 @@ export const NavigationHeader: React.FC = () => {
case 'refuel':
return t(`header.gas`);
default:
return t(`header.swap`);
return t(`header.exchange`);
}
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export const NavigationHeader: React.FC = () => {
flex={1}
noWrap
>
{handleHeaderTitle()}
{title || handleHeaderTitle()}
</Typography>
)}
<Routes>
Expand All @@ -118,14 +118,16 @@ export const NavigationHeader: React.FC = () => {
<>
{account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (
<Tooltip
title={t(`header.swapHistory`)}
title={t(`header.transactionHistory`)}
enterDelay={400}
arrow
>
<IconButton
size="medium"
edge="start"
onClick={() => navigate(navigationRoutes.swapHistory)}
onClick={() =>
navigate(navigationRoutes.transactionHistory)
}
>
<ReceiptLongIcon />
</IconButton>
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/src/components/Header/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './Header';
export * from './useHeaderActionStore';
export * from './useHeaderStore';
7 changes: 5 additions & 2 deletions packages/widget/src/components/Header/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export interface HeaderActionState {
export interface HeaderState {
element?: React.ReactNode | null;
title?: string;
}

export interface HeaderActionStore extends HeaderActionState {
export interface HeaderStore extends HeaderState {
setAction(element?: React.ReactNode | null): () => void;
setTitle(title?: string): () => void;
removeAction(): void;
removeTitle(): void;
}
16 changes: 0 additions & 16 deletions packages/widget/src/components/Header/useHeaderActionStore.ts

This file was deleted.

27 changes: 27 additions & 0 deletions packages/widget/src/components/Header/useHeaderStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { create } from 'zustand';
import type { HeaderStore } from './types';

export const useHeaderStore = create<HeaderStore>((set, get) => ({
setAction: (element) => {
set(() => ({
element,
}));
return get().removeAction;
},
setTitle: (title) => {
set(() => ({
title,
}));
return get().removeTitle;
},
removeAction: () => {
set(() => ({
element: null,
}));
},
removeTitle: () => {
set(() => ({
title: undefined,
}));
},
}));
12 changes: 6 additions & 6 deletions packages/widget/src/components/Insurance/InsuranceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
<VerifiedUserIcon fontSize="inherit" />
<CardLabelTypography type="icon">
{status === RouteExecutionStatus.Idle
? t('swap.tags.insurance')
: t('swap.tags.insured')}
? t('main.tags.insurance')
: t('main.tags.insured')}
</CardLabelTypography>
</CardLabel>
{status === RouteExecutionStatus.Idle ? (
Expand Down Expand Up @@ -76,11 +76,11 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
<Typography fontSize={14}>
<Trans>
{status === RouteExecutionStatus.Idle
? t('swap.insurance.insure', {
? t('insurance.insure', {
amount: insuredAmount,
tokenSymbol: insuredTokenSymbol,
})
: t('swap.insurance.insured', {
: t('insurance.insured', {
amount: insuredAmount,
tokenSymbol: insuredTokenSymbol,
})}
Expand All @@ -99,10 +99,10 @@ export const InsuranceCard: React.FC<InsuranceCardProps> = ({
}}
>
<Typography fontSize={14} display="list-item">
{t('swap.insurance.bridgeExploits')}
{t('insurance.bridgeExploits')}
</Typography>
<Typography fontSize={14} display="list-item">
{t('swap.insurance.slippageError')}
{t('insurance.slippageError')}
</Typography>
</Box>
</Collapse>
Expand Down
2 changes: 1 addition & 1 deletion packages/widget/src/components/NFT/NFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const NFT: React.FC<BoxProps & NFTProps> = ({
<Skeleton width={128} height={21} variant="text" />
) : owner ? (
<Typography fontSize={14} color="text.secondary">
{t('swap.ownedBy')}{' '}
{t('main.ownedBy')}{' '}
<Link
href={owner.url}
target="_blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export const SelectTokenButton: React.FC<
const onClick = !disabledUI?.includes(tokenKey) ? handleClick : undefined;
const defaultPlaceholder =
formType === 'to' && variant === 'refuel'
? t('swap.selectChain')
? t('main.selectChain')
: formType === 'to' && swapOnly
? t('swap.selectToken')
: t('swap.selectChainAndToken');
? t('main.selectToken')
: t('main.selectChainAndToken');
const cardTitle =
formType === 'from' && variant === 'nft'
? t(`header.payWith`)
: t(`swap.${formType}`);
: t(`main.${formType}`);
return (
<Card flex={1} onClick={onClick}>
<CardTitle>{cardTitle}</CardTitle>
Expand All @@ -69,7 +69,7 @@ export const SelectTokenButton: React.FC<
}
title={isSelected ? token.symbol : defaultPlaceholder}
subheader={
isSelected ? t(`swap.onChain`, { chainName: chain.name }) : null
isSelected ? t(`main.onChain`, { chainName: chain.name }) : null
}
selected={isSelected}
compact={compact}
Expand Down
Loading

0 comments on commit ca69314

Please sign in to comment.