@rango-dev/widget-embedded 0.1.16-next.2 → 0.1.16-next.21
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/CHANGELOG.md +15 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/Footer.d.ts +111 -1
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/RoutesOverview.d.ts +111 -1
- package/dist/components/RoutesOverview.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +111 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +2 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +11 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +127 -159
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +127 -159
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +129 -156
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +16 -13
- package/src/QueueManager.tsx +4 -1
- package/src/components/AppRoutes.tsx +1 -1
- package/src/components/BottomLogo.tsx +1 -1
- package/src/components/Layout.tsx +23 -17
- package/src/components/RoutesOverview.tsx +4 -4
- package/src/components/TokenInfo.tsx +13 -12
- package/src/components/TokenPreview.tsx +9 -9
- package/src/components/warnings/BalanceErrors.tsx +2 -2
- package/src/components/warnings/MinRequiredSlippage.tsx +2 -2
- package/src/hooks/useTheme.ts +46 -63
- package/src/index.tsx +1 -7
- package/src/pages/ConfirmSwapPage.tsx +38 -28
- package/src/pages/SettingsPage.tsx +4 -2
- package/src/pages/SwapDetailsPage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +6 -2
- package/src/store/wallets.ts +13 -11
- package/src/types/config.ts +8 -1
- package/src/utils/common.ts +0 -21
- package/src/utils/wallets.ts +7 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.1.16-next.
|
|
3
|
+
"version": "0.1.16-next.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsdx build"
|
|
13
|
+
"build": "tsdx build --tsconfig ./tsconfig.json"
|
|
14
14
|
},
|
|
15
15
|
"husky": {
|
|
16
16
|
"hooks": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"trailingComma": "es5"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@rango-dev/provider-all": "^0.1.
|
|
28
|
-
"@rango-dev/queue-manager-core": "^0.1.
|
|
29
|
-
"@rango-dev/queue-manager-rango-preset": "^0.1.
|
|
30
|
-
"@rango-dev/queue-manager-react": "^0.1.
|
|
31
|
-
"@rango-dev/ui": "^0.1.
|
|
32
|
-
"@rango-dev/wallets-core": "^0.1.
|
|
33
|
-
"@rango-dev/wallets-shared": "^0.1.
|
|
27
|
+
"@rango-dev/provider-all": "^0.1.14-next.15",
|
|
28
|
+
"@rango-dev/queue-manager-core": "^0.1.13-next.16",
|
|
29
|
+
"@rango-dev/queue-manager-rango-preset": "^0.1.13-next.17",
|
|
30
|
+
"@rango-dev/queue-manager-react": "^0.1.12-next.13",
|
|
31
|
+
"@rango-dev/ui": "^0.1.14-next.12",
|
|
32
|
+
"@rango-dev/wallets-core": "^0.1.14-next.16",
|
|
33
|
+
"@rango-dev/wallets-shared": "^0.1.13-next.18",
|
|
34
34
|
"bignumber.js": "^9.1.1",
|
|
35
35
|
"copy-to-clipboard": "^3.3.3",
|
|
36
36
|
"dayjs": "^1.11.7",
|
|
@@ -40,14 +40,17 @@
|
|
|
40
40
|
"immer": "^9.0.19",
|
|
41
41
|
"mitt": "^3.0.0",
|
|
42
42
|
"parcel": "^2.8.0",
|
|
43
|
-
"rango-sdk": "^0.1.
|
|
44
|
-
"rango-types": "^0.1.
|
|
45
|
-
"react": "^18.2.0",
|
|
46
|
-
"react-dom": "^18.2.0",
|
|
43
|
+
"rango-sdk": "^0.1.27",
|
|
44
|
+
"rango-types": "^0.1.32",
|
|
47
45
|
"react-i18next": "^12.2.0",
|
|
48
46
|
"react-router-dom": "^6.8.0",
|
|
47
|
+
"values.js": "2.1.1",
|
|
49
48
|
"zustand": "^4.3.2"
|
|
50
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"react": ">=16",
|
|
52
|
+
"react-dom": ">=16"
|
|
53
|
+
},
|
|
51
54
|
"publishConfig": {
|
|
52
55
|
"access": "public"
|
|
53
56
|
}
|
package/src/QueueManager.tsx
CHANGED
|
@@ -52,6 +52,9 @@ function QueueManager(props: PropsWithChildren<{}>) {
|
|
|
52
52
|
return connect(wallet, network);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
const isMobileWallet = (walletType: WalletType): boolean =>
|
|
56
|
+
!!getWalletInfo(walletType).mobileWallet;
|
|
57
|
+
|
|
55
58
|
// TODO: this code copy & pasted from rango, should be refactored.
|
|
56
59
|
const allBlockchains = blockchains
|
|
57
60
|
.filter((blockchain) => blockchain.enabled)
|
|
@@ -106,12 +109,12 @@ function QueueManager(props: PropsWithChildren<{}>) {
|
|
|
106
109
|
switchNetwork,
|
|
107
110
|
connect,
|
|
108
111
|
state,
|
|
112
|
+
isMobileWallet,
|
|
109
113
|
notifier,
|
|
110
114
|
};
|
|
111
115
|
|
|
112
116
|
return (
|
|
113
117
|
<ManagerProvider
|
|
114
|
-
//@ts-ignore
|
|
115
118
|
queuesDefs={[swapQueueDef]}
|
|
116
119
|
context={context}
|
|
117
120
|
onPersistedDataLoaded={(manager) => {
|
|
@@ -55,7 +55,7 @@ export function AppRoutes(props: PropTypes) {
|
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
57
|
path: navigationRoutes.settings,
|
|
58
|
-
element: <SettingsPage supportedSwappers={config?.liquiditySources} />,
|
|
58
|
+
element: <SettingsPage singleTheme= {config?.theme?.singleTheme} supportedSwappers={config?.liquiditySources} />,
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
path: navigationRoutes.liquiditySources,
|
|
@@ -29,7 +29,7 @@ export function BottomLogo() {
|
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<Container>
|
|
32
|
-
<Typography variant="caption" color="$
|
|
32
|
+
<Typography variant="caption" color="$neutral600">
|
|
33
33
|
{t('Powered By')}
|
|
34
34
|
</Typography>
|
|
35
35
|
<StyledAnchor href="https://rango.exchange" target="_blank">
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Typography,
|
|
5
5
|
styled,
|
|
6
6
|
Spinner,
|
|
7
|
+
Image,
|
|
7
8
|
} from '@rango-dev/ui';
|
|
8
9
|
import React, { useEffect } from 'react';
|
|
9
10
|
import { useNavigate } from 'react-router-dom';
|
|
@@ -23,7 +24,6 @@ import { useTranslation } from 'react-i18next';
|
|
|
23
24
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
24
25
|
import { useMetaStore } from '../store/meta';
|
|
25
26
|
import { useSettingsStore } from '../store/settings';
|
|
26
|
-
import { Image } from '@rango-dev/ui';
|
|
27
27
|
|
|
28
28
|
const Header = styled('div', {
|
|
29
29
|
display: 'flex',
|
|
@@ -34,6 +34,11 @@ const Header = styled('div', {
|
|
|
34
34
|
},
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
const WalletImages = styled('div', {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
paddingLeft: '12px',
|
|
40
|
+
});
|
|
41
|
+
|
|
37
42
|
const WalletImageContainer = styled('div', {
|
|
38
43
|
marginLeft: -15,
|
|
39
44
|
marginRight: '$6',
|
|
@@ -52,7 +57,7 @@ export function Layout({ config }: LayoutProps) {
|
|
|
52
57
|
const { getWalletInfo } = useWallets();
|
|
53
58
|
const connectedWalletsImages = removeDuplicateFrom(
|
|
54
59
|
getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(
|
|
55
|
-
|
|
60
|
+
w => w.image
|
|
56
61
|
)
|
|
57
62
|
);
|
|
58
63
|
const { blockchains, tokens } = useMetaStore.use.meta();
|
|
@@ -64,8 +69,7 @@ export function Layout({ config }: LayoutProps) {
|
|
|
64
69
|
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
65
70
|
|
|
66
71
|
const totalBalance = calculateWalletUsdValue(connectedWallets);
|
|
67
|
-
const connectWalletsButtonDisabled =
|
|
68
|
-
useUiStore.use.connectWalletsButtonDisabled();
|
|
72
|
+
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
69
73
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
70
74
|
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
71
75
|
|
|
@@ -73,9 +77,9 @@ export function Layout({ config }: LayoutProps) {
|
|
|
73
77
|
useEffect(() => {
|
|
74
78
|
if (loadingMetaStatus === 'success') {
|
|
75
79
|
const chain = blockchains.find(
|
|
76
|
-
|
|
80
|
+
chain => chain.name === config?.to?.blockchain
|
|
77
81
|
);
|
|
78
|
-
const token = tokens.find(
|
|
82
|
+
const token = tokens.find(t =>
|
|
79
83
|
tokensAreEqual(t, config?.to?.token || null)
|
|
80
84
|
);
|
|
81
85
|
setToChain(chain || null);
|
|
@@ -90,9 +94,9 @@ export function Layout({ config }: LayoutProps) {
|
|
|
90
94
|
useEffect(() => {
|
|
91
95
|
if (loadingMetaStatus === 'success') {
|
|
92
96
|
const chain = blockchains.find(
|
|
93
|
-
|
|
97
|
+
chain => chain.name === config?.from?.blockchain
|
|
94
98
|
);
|
|
95
|
-
const token = tokens.find(
|
|
99
|
+
const token = tokens.find(t =>
|
|
96
100
|
tokensAreEqual(t, config?.from?.token || null)
|
|
97
101
|
);
|
|
98
102
|
|
|
@@ -118,16 +122,18 @@ export function Layout({ config }: LayoutProps) {
|
|
|
118
122
|
if (!connectWalletsButtonDisabled)
|
|
119
123
|
navigate(navigationRoutes.wallets);
|
|
120
124
|
}}
|
|
125
|
+
prefix={
|
|
126
|
+
connectedWalletsImages?.length ? (
|
|
127
|
+
<WalletImages>
|
|
128
|
+
{connectedWalletsImages.map((walletImage, index) => (
|
|
129
|
+
<WalletImageContainer key={index}>
|
|
130
|
+
<Image src={walletImage} size={24} />
|
|
131
|
+
</WalletImageContainer>
|
|
132
|
+
))}
|
|
133
|
+
</WalletImages>
|
|
134
|
+
) : null
|
|
135
|
+
}
|
|
121
136
|
>
|
|
122
|
-
{connectedWalletsImages?.length ? (
|
|
123
|
-
connectedWalletsImages.map((walletImage, index) => (
|
|
124
|
-
<WalletImageContainer key={index}>
|
|
125
|
-
<Image src={walletImage} size={24} />
|
|
126
|
-
</WalletImageContainer>
|
|
127
|
-
))
|
|
128
|
-
) : (
|
|
129
|
-
<></>
|
|
130
|
-
)}
|
|
131
137
|
<div className="balance">
|
|
132
138
|
<Typography variant="body2">
|
|
133
139
|
{!connectedWallets?.length
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { styled, ChevronRightIcon, GasIcon,
|
|
2
|
+
import { styled, ChevronRightIcon, GasIcon, Divider } from '@rango-dev/ui';
|
|
3
3
|
import { BestRouteResponse } from 'rango-sdk';
|
|
4
4
|
|
|
5
5
|
export const Container = styled('div', {
|
|
@@ -8,8 +8,8 @@ export const Container = styled('div', {
|
|
|
8
8
|
justifyContent: 'space-between',
|
|
9
9
|
padding: '$8',
|
|
10
10
|
borderRadius: '$5',
|
|
11
|
-
backgroundColor: '$
|
|
12
|
-
color: '$
|
|
11
|
+
backgroundColor: '$neutral100',
|
|
12
|
+
color: '$neutral800',
|
|
13
13
|
fontSize: '$12',
|
|
14
14
|
|
|
15
15
|
'.routes': {
|
|
@@ -47,7 +47,7 @@ function RoutesOverview(props: PropTypes) {
|
|
|
47
47
|
{props.totalFee ? (
|
|
48
48
|
<div className="fee">
|
|
49
49
|
<GasIcon size={12} />
|
|
50
|
-
<
|
|
50
|
+
<Divider size={4} direction="horizontal" />${props.totalFee}
|
|
51
51
|
</div>
|
|
52
52
|
) : null}
|
|
53
53
|
</Container>
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
TextField,
|
|
8
8
|
Typography,
|
|
9
9
|
Image,
|
|
10
|
-
|
|
10
|
+
Divider,
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
12
|
import { useMetaStore } from '../store/meta';
|
|
13
13
|
import { BlockchainMeta, Token } from 'rango-sdk';
|
|
@@ -48,10 +48,11 @@ const Container = styled('div', {
|
|
|
48
48
|
variants: {
|
|
49
49
|
type: {
|
|
50
50
|
filled: {
|
|
51
|
-
backgroundColor: '$
|
|
51
|
+
backgroundColor: '$neutral100',
|
|
52
52
|
},
|
|
53
53
|
outlined: {
|
|
54
|
-
border: '1px solid $
|
|
54
|
+
border: '1px solid $neutral100',
|
|
55
|
+
backgroundColor: '$surface',
|
|
55
56
|
},
|
|
56
57
|
},
|
|
57
58
|
},
|
|
@@ -105,7 +106,7 @@ const Options = styled('div', {
|
|
|
105
106
|
const ImagePlaceholder = styled('span', {
|
|
106
107
|
width: '24px',
|
|
107
108
|
height: '24px',
|
|
108
|
-
backgroundColor: '$
|
|
109
|
+
backgroundColor: '$neutral100',
|
|
109
110
|
borderRadius: '99999px',
|
|
110
111
|
});
|
|
111
112
|
|
|
@@ -113,7 +114,7 @@ const OutputContainer = styled('div', {
|
|
|
113
114
|
windth: '100%',
|
|
114
115
|
height: '$48',
|
|
115
116
|
borderRadius: '$5',
|
|
116
|
-
backgroundColor: '$
|
|
117
|
+
backgroundColor: '$surface',
|
|
117
118
|
border: '1px solid transparent',
|
|
118
119
|
position: 'relative',
|
|
119
120
|
display: 'flex',
|
|
@@ -185,7 +186,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
185
186
|
<Box>
|
|
186
187
|
<Container type={props.type === 'From' ? 'filled' : 'outlined'}>
|
|
187
188
|
<div className="head">
|
|
188
|
-
<Typography variant="body2" color="
|
|
189
|
+
<Typography variant="body2" color="neutral800">
|
|
189
190
|
{t(type)}
|
|
190
191
|
</Typography>
|
|
191
192
|
{props.type === 'From' ? (
|
|
@@ -197,10 +198,10 @@ export function TokenInfo(props: PropTypes) {
|
|
|
197
198
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
198
199
|
}}
|
|
199
200
|
>
|
|
200
|
-
<Typography variant="body3" color="
|
|
201
|
+
<Typography variant="body3" color="neutral600">{`${t(
|
|
201
202
|
'Balance'
|
|
202
203
|
)}: ${tokenBalance} ${fromToken?.symbol || ''}`}</Typography>
|
|
203
|
-
<
|
|
204
|
+
<Divider size={4} />
|
|
204
205
|
<Button type="primary" variant="ghost" size="compact">
|
|
205
206
|
{t('Max')}
|
|
206
207
|
</Button>
|
|
@@ -215,7 +216,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
215
216
|
<div>
|
|
216
217
|
<Typography
|
|
217
218
|
variant="caption"
|
|
218
|
-
color="
|
|
219
|
+
color="neutral600"
|
|
219
220
|
>{`$${numberToString(props.outputUsdValue)}`}</Typography>
|
|
220
221
|
</div>
|
|
221
222
|
</div>
|
|
@@ -245,7 +246,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
245
246
|
? chain.displayName
|
|
246
247
|
: t('Chain')}
|
|
247
248
|
</Button>
|
|
248
|
-
<
|
|
249
|
+
<Divider size={12} direction="horizontal" />
|
|
249
250
|
<Button
|
|
250
251
|
className="selectors"
|
|
251
252
|
onClick={() => {
|
|
@@ -271,7 +272,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
271
272
|
>
|
|
272
273
|
{loadingStatus === 'success' && token ? token.symbol : t('Token')}
|
|
273
274
|
</Button>
|
|
274
|
-
<
|
|
275
|
+
<Divider size={12} direction="horizontal" />
|
|
275
276
|
<div className="amount">
|
|
276
277
|
{props.type === 'From' ? (
|
|
277
278
|
<TextField
|
|
@@ -293,7 +294,7 @@ export function TokenInfo(props: PropTypes) {
|
|
|
293
294
|
>
|
|
294
295
|
<Typography
|
|
295
296
|
variant="caption"
|
|
296
|
-
color="
|
|
297
|
+
color="neutral800"
|
|
297
298
|
>{`$${numberToString(inputUsdValue)}`}</Typography>
|
|
298
299
|
</span>
|
|
299
300
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
InfoCircleIcon,
|
|
5
5
|
styled,
|
|
6
6
|
Typography,
|
|
7
|
-
|
|
7
|
+
Divider,
|
|
8
8
|
Image,
|
|
9
9
|
} from '@rango-dev/ui';
|
|
10
10
|
import { LoadingStatus } from '../store/meta';
|
|
@@ -27,10 +27,10 @@ const Container = styled('div', {
|
|
|
27
27
|
variants: {
|
|
28
28
|
type: {
|
|
29
29
|
filled: {
|
|
30
|
-
backgroundColor: '$
|
|
30
|
+
backgroundColor: '$neutral100',
|
|
31
31
|
},
|
|
32
32
|
outlined: {
|
|
33
|
-
border: '1px solid $
|
|
33
|
+
border: '1px solid $neutral100',
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
@@ -70,7 +70,7 @@ const Container = styled('div', {
|
|
|
70
70
|
const ImagePlaceholder = styled('span', {
|
|
71
71
|
width: '24px',
|
|
72
72
|
height: '24px',
|
|
73
|
-
backgroundColor: '$
|
|
73
|
+
backgroundColor: '$neutral100',
|
|
74
74
|
borderRadius: '99999px',
|
|
75
75
|
});
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ const OutputContainer = styled('div', {
|
|
|
78
78
|
windth: '100%',
|
|
79
79
|
height: '$48',
|
|
80
80
|
borderRadius: '$5',
|
|
81
|
-
backgroundColor: '$
|
|
81
|
+
backgroundColor: '$surface',
|
|
82
82
|
border: '1px solid transparent',
|
|
83
83
|
position: 'relative',
|
|
84
84
|
display: 'flex',
|
|
@@ -123,7 +123,7 @@ export function TokenPreview(props: PropTypes) {
|
|
|
123
123
|
<Box>
|
|
124
124
|
<Container type={'outlined'}>
|
|
125
125
|
<div className="head">
|
|
126
|
-
<Typography variant="body2" color="
|
|
126
|
+
<Typography variant="body2" color="neutral800">
|
|
127
127
|
{props.label}
|
|
128
128
|
</Typography>
|
|
129
129
|
<div>
|
|
@@ -131,7 +131,7 @@ export function TokenPreview(props: PropTypes) {
|
|
|
131
131
|
{props.usdValue && (
|
|
132
132
|
<Typography
|
|
133
133
|
variant="caption"
|
|
134
|
-
color="
|
|
134
|
+
color="neutral600"
|
|
135
135
|
className="usd-value"
|
|
136
136
|
>{`$${numberToString(props.usdValue)}`}</Typography>
|
|
137
137
|
)}
|
|
@@ -157,7 +157,7 @@ export function TokenPreview(props: PropTypes) {
|
|
|
157
157
|
? chain.displayName
|
|
158
158
|
: t('Chain')}
|
|
159
159
|
</Button>
|
|
160
|
-
<
|
|
160
|
+
<Divider size={12} direction="horizontal" />
|
|
161
161
|
<Button
|
|
162
162
|
className="selectors"
|
|
163
163
|
variant="outlined"
|
|
@@ -175,7 +175,7 @@ export function TokenPreview(props: PropTypes) {
|
|
|
175
175
|
>
|
|
176
176
|
{loadingStatus === 'success' && token ? token.symbol : t('Token')}
|
|
177
177
|
</Button>
|
|
178
|
-
<
|
|
178
|
+
<Divider size={12} direction="horizontal" />
|
|
179
179
|
<div className="amount">
|
|
180
180
|
<OutputContainer>
|
|
181
181
|
<Typography variant="h4">{props.amount}</Typography>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Divider, styled, Typography } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
interface PropTypes {
|
|
@@ -34,7 +34,7 @@ export function BalanceErrors({ messages }: PropTypes) {
|
|
|
34
34
|
<Typography className="title" variant="title" color={'error'}>
|
|
35
35
|
Insufficent Balance:
|
|
36
36
|
</Typography>
|
|
37
|
-
<
|
|
37
|
+
<Divider size={8} />
|
|
38
38
|
<List showListStyle={showListStyle}>
|
|
39
39
|
{messages.map((warning, index) => (
|
|
40
40
|
<ListItem showListStyle={showListStyle} key={index}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Divider, Typography, styled } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ChangeSlippageButton } from '../ChangeSlippageButton';
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ export function MinRequiredSlippage({ minRequiredSlippage }: PropTypes) {
|
|
|
16
16
|
We recommend you to increase slippage to at least
|
|
17
17
|
{minRequiredSlippage}
|
|
18
18
|
for this route.
|
|
19
|
-
<
|
|
19
|
+
<Divider size={8}/>
|
|
20
20
|
<ChangeSlippageButton />
|
|
21
21
|
</StyledMessage>
|
|
22
22
|
);
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -1,112 +1,94 @@
|
|
|
1
|
-
import { createTheme } from '@rango-dev/ui';
|
|
1
|
+
import { createTheme, generateRangeColors } from '@rango-dev/ui';
|
|
2
2
|
import { useState, useEffect, useLayoutEffect } from 'react';
|
|
3
3
|
import { useMetaStore } from '../store/meta';
|
|
4
4
|
import { useSettingsStore } from '../store/settings';
|
|
5
5
|
import { WidgetTheme } from '../types';
|
|
6
|
-
import { shadeColor } from '../utils/common';
|
|
7
6
|
import usePrevious from './usePrevious';
|
|
8
7
|
|
|
9
8
|
export function useTheme({
|
|
10
9
|
colors: themeColors,
|
|
11
|
-
fontFamily = '
|
|
10
|
+
fontFamily = 'Roboto',
|
|
12
11
|
borderRadius = 8,
|
|
13
12
|
mode = 'auto',
|
|
14
13
|
}: WidgetTheme) {
|
|
15
14
|
const theme = useSettingsStore.use.theme();
|
|
16
15
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
17
16
|
const setTheme = useSettingsStore.use.setTheme();
|
|
17
|
+
const light = themeColors?.light;
|
|
18
|
+
const dark = themeColors?.dark;
|
|
19
|
+
const neutral = light?.neutral || '#fafafa';
|
|
20
|
+
const background = light?.background || '#fff';
|
|
21
|
+
const foreground = light?.foreground || '#000';
|
|
18
22
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
primary300: shadeColor(primary, -15),
|
|
38
|
-
primary400: shadeColor(primary, -20),
|
|
39
|
-
primary500: shadeColor(primary, -25),
|
|
40
|
-
primary600: shadeColor(primary, -30),
|
|
41
|
-
primary700: shadeColor(primary, -35),
|
|
42
|
-
primary800: shadeColor(primary, -40),
|
|
43
|
-
primary900: shadeColor(primary, -45),
|
|
23
|
+
const darkColors = {
|
|
24
|
+
...generateRangeColors('primary', 'dark', dark?.primary),
|
|
25
|
+
...generateRangeColors('error', 'dark', dark?.error),
|
|
26
|
+
...generateRangeColors('warning', 'dark', dark?.warning),
|
|
27
|
+
...generateRangeColors('success', 'dark', dark?.success),
|
|
28
|
+
...generateRangeColors('neutral', 'dark', dark?.neutral),
|
|
29
|
+
surface: dark?.surface,
|
|
30
|
+
background: dark?.background,
|
|
31
|
+
foreground: dark?.foreground,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const lightColors = {
|
|
35
|
+
surface: light?.surface || '#fff',
|
|
36
|
+
...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
|
|
37
|
+
...generateRangeColors('error', 'light', light?.error || '#FF0000'),
|
|
38
|
+
...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
|
|
39
|
+
...generateRangeColors('success', 'light', light?.success || '#0070F3'),
|
|
40
|
+
...generateRangeColors('neutral', 'light', neutral),
|
|
44
41
|
background,
|
|
45
42
|
foreground,
|
|
46
|
-
error,
|
|
47
|
-
error100: shadeColor(error, 50),
|
|
48
|
-
error300: shadeColor(error, -10),
|
|
49
|
-
error500: shadeColor(error, -20),
|
|
50
|
-
error700: shadeColor(error, -30),
|
|
51
|
-
warning,
|
|
52
|
-
warning100: shadeColor(warning, 50),
|
|
53
|
-
warning300: shadeColor(warning, -10),
|
|
54
|
-
warning500: shadeColor(warning, -20),
|
|
55
|
-
warning700: shadeColor(warning, -30),
|
|
56
|
-
success,
|
|
57
|
-
success100: shadeColor(success, 50),
|
|
58
|
-
success300: shadeColor(success, -10),
|
|
59
|
-
success500: shadeColor(success, -20),
|
|
60
|
-
success700: shadeColor(success, -30),
|
|
61
43
|
};
|
|
62
44
|
|
|
63
|
-
const
|
|
64
|
-
colors,
|
|
45
|
+
const customLightTheme = createTheme({
|
|
46
|
+
colors: lightColors,
|
|
65
47
|
radii: {
|
|
66
48
|
5: `${borderRadius}px`,
|
|
67
49
|
},
|
|
68
50
|
shadows: {
|
|
69
|
-
s:
|
|
51
|
+
s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${
|
|
52
|
+
light?.neutral || '#f0f2f5'
|
|
53
|
+
}, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`,
|
|
70
54
|
},
|
|
71
55
|
});
|
|
72
56
|
|
|
73
|
-
const
|
|
57
|
+
const customDarkTheme = createTheme({
|
|
74
58
|
colors: {
|
|
75
|
-
...
|
|
76
|
-
|
|
77
|
-
neutrals300: '#333333',
|
|
78
|
-
neutrals400: '#444444',
|
|
79
|
-
neutrals500: '#acacac',
|
|
80
|
-
neutrals600: '#cccccc',
|
|
81
|
-
neutrals700: '#dedede',
|
|
82
|
-
neutrals800: '#f2f2f2',
|
|
83
|
-
neutrals900: '#FAFAFA',
|
|
59
|
+
...lightColors,
|
|
60
|
+
...generateRangeColors('neutral', 'dark', '#111111'),
|
|
84
61
|
foreground: background,
|
|
85
62
|
background: foreground,
|
|
63
|
+
surface: '#000',
|
|
64
|
+
...JSON.parse(JSON.stringify(darkColors)),
|
|
86
65
|
},
|
|
87
66
|
radii: {
|
|
88
67
|
5: `${borderRadius}px`,
|
|
89
68
|
},
|
|
90
69
|
shadows: {
|
|
91
|
-
s:
|
|
70
|
+
s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${
|
|
71
|
+
dark?.neutral || '#222'
|
|
72
|
+
}, 0px 1px 18px 3px ${dark?.neutral || '#222'}`,
|
|
92
73
|
},
|
|
93
74
|
});
|
|
94
|
-
const [OSTheme, setOSTheme] = useState(
|
|
75
|
+
const [OSTheme, setOSTheme] = useState('light');
|
|
76
|
+
|
|
95
77
|
useEffect(() => {
|
|
96
78
|
(async () => {
|
|
97
79
|
await fetchMeta();
|
|
98
80
|
})();
|
|
99
81
|
|
|
100
82
|
const switchTheme = (event: MediaQueryListEvent) => {
|
|
101
|
-
if (event.matches) setOSTheme(
|
|
102
|
-
else setOSTheme(
|
|
83
|
+
if (event.matches) setOSTheme('dark');
|
|
84
|
+
else setOSTheme('light');
|
|
103
85
|
};
|
|
104
86
|
|
|
105
87
|
if (
|
|
106
88
|
window.matchMedia &&
|
|
107
89
|
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
108
90
|
) {
|
|
109
|
-
setOSTheme(
|
|
91
|
+
setOSTheme('dark');
|
|
110
92
|
}
|
|
111
93
|
|
|
112
94
|
window
|
|
@@ -131,8 +113,9 @@ export function useTheme({
|
|
|
131
113
|
}, [fontFamily]);
|
|
132
114
|
|
|
133
115
|
const getActiveTheme = () => {
|
|
134
|
-
if (theme === 'auto')
|
|
135
|
-
|
|
116
|
+
if (theme === 'auto')
|
|
117
|
+
return OSTheme === 'dark' ? customDarkTheme : customLightTheme;
|
|
118
|
+
else return theme === 'dark' ? customDarkTheme : customLightTheme;
|
|
136
119
|
};
|
|
137
120
|
|
|
138
121
|
return { activeTheme: getActiveTheme() };
|
package/src/index.tsx
CHANGED
|
@@ -28,13 +28,7 @@ import { useUiStore } from './store/ui';
|
|
|
28
28
|
import { navigationRoutes } from './constants/navigationRoutes';
|
|
29
29
|
import { initConfig } from './utils/configs';
|
|
30
30
|
|
|
31
|
-
export {
|
|
32
|
-
WidgetConfig,
|
|
33
|
-
WalletType,
|
|
34
|
-
WidgetTheme,
|
|
35
|
-
WidgetColors,
|
|
36
|
-
BlockchainAndTokenConfig,
|
|
37
|
-
};
|
|
31
|
+
export { WidgetConfig, WidgetTheme, WidgetColors, BlockchainAndTokenConfig };
|
|
38
32
|
|
|
39
33
|
export type WidgetProps = {
|
|
40
34
|
config?: WidgetConfig;
|