@lifi/widget 1.11.1 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Header/Header.js +3 -1
- package/components/SwapButton/SwapButton.js +4 -0
- package/components/SwapRouteCard/SwapRouteCard.js +2 -2
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +2 -2
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +7 -8
- package/config/theme.js +19 -5
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/i18n/en/translation.json +5 -2
- package/i18n/index.d.ts +3 -0
- package/package.json +1 -1
- package/pages/MainPage/SwapRoutes.js +3 -3
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/pages/SwapPage/SwapPage.js +1 -1
- package/pages/SwapRoutesPage/SwapRoutesPage.js +3 -3
|
@@ -9,10 +9,12 @@ const stickyHeaderRoutes = [
|
|
|
9
9
|
navigationRoutes.selectWallet,
|
|
10
10
|
navigationRoutes.settings,
|
|
11
11
|
navigationRoutes.swapRoutes,
|
|
12
|
+
navigationRoutes.swapHistory,
|
|
13
|
+
navigationRoutes.swapDetails,
|
|
12
14
|
];
|
|
13
15
|
const HeaderContainer = ({ children }) => {
|
|
14
16
|
const { pathname } = useLocation();
|
|
15
|
-
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.includes(
|
|
17
|
+
return (_jsx(Container, Object.assign({ id: ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
16
18
|
};
|
|
17
19
|
export const Header = () => {
|
|
18
20
|
const { walletManagement } = useWidgetConfig();
|
|
@@ -52,6 +52,9 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
52
52
|
if (!isCurrentChainMatch) {
|
|
53
53
|
return t(`button.switchChain`);
|
|
54
54
|
}
|
|
55
|
+
if (!currentRoute) {
|
|
56
|
+
return t(`button.swap`);
|
|
57
|
+
}
|
|
55
58
|
return text || t(`button.reviewSwap`);
|
|
56
59
|
}
|
|
57
60
|
return t(`button.connectWallet`);
|
|
@@ -59,5 +62,6 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
59
62
|
return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
60
63
|
// loading={isLoading || isFetching}
|
|
61
64
|
disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
|
|
65
|
+
currentRoute &&
|
|
62
66
|
isCurrentChainMatch, fullWidth: true }, { children: getButtonText() })));
|
|
63
67
|
};
|
|
@@ -32,7 +32,7 @@ export const SwapRouteCard = (_a) => {
|
|
|
32
32
|
: null, _jsxs(Box, Object.assign({ sx: {
|
|
33
33
|
display: 'flex',
|
|
34
34
|
justifyContent: 'space-between',
|
|
35
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500" }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary" }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end" }, { children: ["~", (route.steps
|
|
35
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Typography, Object.assign({ fontSize: 18, fontWeight: "500", lineHeight: 1, pt: 0.25 }, { children: t(`swap.currency`, { value: (_c = route.gasCostUSD) !== null && _c !== void 0 ? _c : 0 }) })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", lineHeight: 1, mt: 0.5 }, { children: t(`swap.gas`) }))] }), _jsxs(Box, { children: [_jsxs(Typography, Object.assign({ fontSize: 18, fontWeight: "500", display: "flex", justifyContent: "flex-end", lineHeight: 1, pt: 0.25 }, { children: ["~", (route.steps
|
|
36
36
|
.map((step) => step.estimate.executionDuration)
|
|
37
|
-
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end" }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
37
|
+
.reduce((cumulated, x) => cumulated + x) / 60).toFixed(0)] })), _jsx(Typography, Object.assign({ fontSize: 12, color: "text.secondary", textAlign: "end", lineHeight: 1, mt: 0.5 }, { children: t(`swap.minutes`) }))] })] }))] })));
|
|
38
38
|
};
|
|
@@ -20,9 +20,9 @@ export const SwapRouteCardSkeleton = (_a) => {
|
|
|
20
20
|
} }, { children: [_jsx(Box, Object.assign({ mr: 2 }, { children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) })), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] })), _jsx(Box, Object.assign({ ml: 6 }, { children: _jsx(Skeleton, { variant: "text", width: 102, height: 16, sx: { borderRadius: 0.5 } }) }))] })), _jsxs(Box, Object.assign({ sx: {
|
|
21
21
|
display: 'flex',
|
|
22
22
|
justifyContent: 'space-between',
|
|
23
|
-
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height:
|
|
23
|
+
} }, { children: [_jsxs(Box, { children: [_jsx(Skeleton, { variant: "text", width: 56, height: 20 }), _jsx(Skeleton, { variant: "text", width: 52, height: 16 })] }), _jsxs(Box, Object.assign({ sx: {
|
|
24
24
|
display: 'flex',
|
|
25
25
|
alignItems: 'flex-end',
|
|
26
26
|
flexDirection: 'column',
|
|
27
|
-
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height:
|
|
27
|
+
} }, { children: [_jsx(Skeleton, { variant: "text", width: 40, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 16 })] }))] }))] })));
|
|
28
28
|
};
|
|
@@ -13,15 +13,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Route as RouteIcon } from '@mui/icons-material';
|
|
14
14
|
import { Box, Typography } from '@mui/material';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { Card } from '../Card';
|
|
17
16
|
export const SwapRouteNotFoundCard = (_a) => {
|
|
18
17
|
var { dense } = _a, other = __rest(_a, ["dense"]);
|
|
19
18
|
const { t } = useTranslation();
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return (_jsxs(Box, Object.assign({ sx: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
flexDirection: 'column',
|
|
24
|
+
flex: 1,
|
|
25
|
+
}, py: 2.375 }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(RouteIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.routeNotFound') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.routeNotFound') }))] })));
|
|
27
26
|
};
|
package/config/theme.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dialogActionsClasses } from '@mui/material/DialogActions';
|
|
2
|
-
import { alpha, createTheme as createMuiTheme, darken, lighten, } from '@mui/material/styles';
|
|
2
|
+
import { alpha, createTheme as createMuiTheme, darken, getContrastRatio, lighten, } from '@mui/material/styles';
|
|
3
|
+
import { dark, light } from '@mui/material/styles/createPalette';
|
|
3
4
|
const palette = {
|
|
4
5
|
primary: {
|
|
5
6
|
main: '#3F49E1',
|
|
@@ -24,8 +25,12 @@ const palette = {
|
|
|
24
25
|
main: '#297EFF',
|
|
25
26
|
},
|
|
26
27
|
};
|
|
28
|
+
const shape = {
|
|
29
|
+
borderRadius: 12,
|
|
30
|
+
borderRadiusSecondary: 6,
|
|
31
|
+
};
|
|
27
32
|
export const createTheme = (mode, theme = {}) => {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
29
34
|
return createMuiTheme({
|
|
30
35
|
typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
|
|
31
36
|
palette: Object.assign(Object.assign(Object.assign({ mode }, palette), { primary: {
|
|
@@ -57,7 +62,7 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
57
62
|
paper: '#212121',
|
|
58
63
|
},
|
|
59
64
|
})),
|
|
60
|
-
shape: Object.assign({
|
|
65
|
+
shape: Object.assign(Object.assign({}, shape), theme.shape),
|
|
61
66
|
breakpoints: {
|
|
62
67
|
values: {
|
|
63
68
|
xs: 0,
|
|
@@ -96,26 +101,35 @@ export const createTheme = (mode, theme = {}) => {
|
|
|
96
101
|
},
|
|
97
102
|
}
|
|
98
103
|
: {})), { root: {
|
|
99
|
-
borderRadius: (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary,
|
|
104
|
+
borderRadius: (_v = (_u = theme.shape) === null || _u === void 0 ? void 0 : _u.borderRadiusSecondary) !== null && _v !== void 0 ? _v : shape.borderRadiusSecondary,
|
|
100
105
|
textTransform: 'none',
|
|
101
106
|
fontSize: '1rem',
|
|
102
107
|
padding: '10px 16px',
|
|
103
108
|
[`.${dialogActionsClasses.root} &`]: {
|
|
104
109
|
padding: '6px 12px',
|
|
105
110
|
},
|
|
106
|
-
'&.Mui-disabled': {
|
|
111
|
+
'&.Mui-disabled, &.Mui-disabled:hover': {
|
|
107
112
|
color: mode === 'light'
|
|
108
113
|
? 'rgb(0 0 0 / 70%)'
|
|
109
114
|
: 'rgb(255 255 255 / 70%)',
|
|
110
115
|
cursor: 'not-allowed',
|
|
111
116
|
pointerEvents: 'auto',
|
|
112
117
|
},
|
|
118
|
+
}, contained: {
|
|
119
|
+
'&:hover': {
|
|
120
|
+
color: getContrastRatio(palette.primary.main, dark.text.primary) >= 3
|
|
121
|
+
? dark.text.primary
|
|
122
|
+
: light.text.primary,
|
|
123
|
+
},
|
|
113
124
|
} }),
|
|
114
125
|
},
|
|
115
126
|
MuiIconButton: {
|
|
116
127
|
styleOverrides: {
|
|
117
128
|
root: {
|
|
118
129
|
color: 'inherit',
|
|
130
|
+
'&:hover': {
|
|
131
|
+
color: 'inherit',
|
|
132
|
+
},
|
|
119
133
|
},
|
|
120
134
|
},
|
|
121
135
|
},
|
package/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.11.
|
|
2
|
+
export declare const version = "1.11.4";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.11.
|
|
2
|
+
export const version = '1.11.4';
|
package/i18n/en/translation.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"button": {
|
|
15
15
|
"connectWallet": "Connect wallet",
|
|
16
16
|
"switchChain": "Switch chain",
|
|
17
|
+
"swap": "Swap",
|
|
17
18
|
"reviewSwap": "Review swap",
|
|
18
19
|
"startSwap": "Start swap",
|
|
19
20
|
"restartSwap": "Restart swap",
|
|
@@ -78,10 +79,12 @@
|
|
|
78
79
|
},
|
|
79
80
|
"info": {
|
|
80
81
|
"title": {
|
|
81
|
-
"routeNotFound": "No routes available"
|
|
82
|
+
"routeNotFound": "No routes available",
|
|
83
|
+
"emptySwapHistory": "No recent swaps"
|
|
82
84
|
},
|
|
83
85
|
"message": {
|
|
84
|
-
"routeNotFound": "Try another token combination."
|
|
86
|
+
"routeNotFound": "Try another token combination.",
|
|
87
|
+
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data."
|
|
85
88
|
}
|
|
86
89
|
},
|
|
87
90
|
"warning": {
|
package/i18n/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const resources: {
|
|
|
17
17
|
button: {
|
|
18
18
|
connectWallet: string;
|
|
19
19
|
switchChain: string;
|
|
20
|
+
swap: string;
|
|
20
21
|
reviewSwap: string;
|
|
21
22
|
startSwap: string;
|
|
22
23
|
restartSwap: string;
|
|
@@ -82,9 +83,11 @@ export declare const resources: {
|
|
|
82
83
|
info: {
|
|
83
84
|
title: {
|
|
84
85
|
routeNotFound: string;
|
|
86
|
+
emptySwapHistory: string;
|
|
85
87
|
};
|
|
86
88
|
message: {
|
|
87
89
|
routeNotFound: string;
|
|
90
|
+
emptySwapHistory: string;
|
|
88
91
|
};
|
|
89
92
|
};
|
|
90
93
|
warning: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.4",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./index.js",
|
|
@@ -23,8 +23,8 @@ export const SwapRoutes = (props) => {
|
|
|
23
23
|
if (!currentRoute && !isLoading && !isFetching && !isFetched) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
const routeNotFound = !currentRoute &&
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
26
|
+
const routeNotFound = !currentRoute && !isLoading && !isFetching;
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
|
|
28
28
|
position: 'absolute',
|
|
29
29
|
top: 8,
|
|
30
30
|
right: 8,
|
|
@@ -32,5 +32,5 @@ export const SwapRoutes = (props) => {
|
|
|
32
32
|
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
33
33
|
? 1
|
|
34
34
|
: 0,
|
|
35
|
-
} }, { children:
|
|
35
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), _jsx(GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props))] }));
|
|
36
36
|
};
|
|
@@ -10,5 +10,5 @@ export const SwapHistoryEmpty = () => {
|
|
|
10
10
|
flexDirection: 'column',
|
|
11
11
|
alignItems: 'center',
|
|
12
12
|
justifyContent: 'center',
|
|
13
|
-
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children:
|
|
13
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(HistoryIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.emptySwapHistory') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.emptySwapHistory') }))] })));
|
|
14
14
|
};
|
|
@@ -41,5 +41,5 @@ export const SwapPage = () => {
|
|
|
41
41
|
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: index === 0
|
|
42
42
|
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined, toToken: index === steps.length - 1
|
|
43
43
|
? Object.assign(Object.assign({}, step.action.toToken), { amount: (_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toAmount) !== null && _b !== void 0 ? _b : step.estimate.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
|
|
44
|
-
}), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { onClick: handleSwapClick,
|
|
44
|
+
}), status === 'idle' ? (_jsx(GasSufficiencyMessage, { route: route, mt: 2 })) : null, status === 'idle' || status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route }) }))) : null, status === 'error' ? (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ variant: "outlined", onClick: handleRemoveRoute, fullWidth: true }, { children: t('button.removeSwap') })) }))) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null] }));
|
|
45
45
|
};
|
|
@@ -28,8 +28,8 @@ export const SwapRoutesPage = () => {
|
|
|
28
28
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
29
|
}, []);
|
|
30
30
|
useEffect(() => {
|
|
31
|
-
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt, timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
31
|
+
return setHeaderAction(_jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 }, size: "medium", edge: "end" }));
|
|
32
32
|
}, [dataUpdatedAt, isFetching, refetch, refetchTime, setHeaderAction]);
|
|
33
|
-
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) &&
|
|
34
|
-
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route
|
|
33
|
+
const routeNotFound = !(swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.length) && !isLoading && !isFetching;
|
|
34
|
+
return (_jsx(Stack, Object.assign({ direction: "column", spacing: 2, flex: 1 }, { children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || isFetching ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes.map((route) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route) }, route.id)))) })));
|
|
35
35
|
};
|