@rango-dev/widget-embedded 0.23.1-next.2 → 0.23.1-next.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.
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B,wBAAgB,YAAY,sBA6M3B"}
1
+ {"version":3,"file":"SettingsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SettingsPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,wBAAgB,YAAY,sBA+C3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.23.1-next.2",
3
+ "version": "0.23.1-next.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -23,9 +23,9 @@
23
23
  "@lingui/react": "4.2.1",
24
24
  "@rango-dev/provider-all": "^0.28.0",
25
25
  "@rango-dev/queue-manager-core": "^0.26.0",
26
- "@rango-dev/queue-manager-rango-preset": "^0.28.1-next.0",
26
+ "@rango-dev/queue-manager-rango-preset": "^0.28.1-next.1",
27
27
  "@rango-dev/queue-manager-react": "^0.26.0",
28
- "@rango-dev/ui": "^0.29.1-next.1",
28
+ "@rango-dev/ui": "^0.29.1-next.4",
29
29
  "@rango-dev/wallets-react": "^0.14.0",
30
30
  "@rango-dev/wallets-shared": "^0.28.0",
31
31
  "bignumber.js": "^9.1.1",
@@ -14,7 +14,6 @@ import { SelectBlockchainPage } from '../pages/SelectBlockchainPage';
14
14
  import { SelectSwapItemsPage } from '../pages/SelectSwapItemsPage';
15
15
  import { SettingsPage } from '../pages/SettingsPage';
16
16
  import { SwapDetailsPage } from '../pages/SwapDetailsPage';
17
- import { ThemePage } from '../pages/ThemePage';
18
17
  import { WalletsPage } from '../pages/WalletsPage';
19
18
 
20
19
  export function AppRoutes() {
@@ -69,10 +68,6 @@ export function AppRoutes() {
69
68
  index: true,
70
69
  element: <SettingsPage />,
71
70
  },
72
- {
73
- path: navigationRoutes.themes,
74
- element: <ThemePage />,
75
- },
76
71
  {
77
72
  path: navigationRoutes.languages,
78
73
  element: <LanguagePage />,
@@ -5,7 +5,6 @@ export const navigationRoutes = {
5
5
  blockchains: 'blockchains',
6
6
  settings: 'settings',
7
7
  liquiditySources: 'liquidity-sources',
8
- themes: 'themes',
9
8
  bridges: 'bridges',
10
9
  exchanges: 'exchanges',
11
10
  languages: 'languages',
@@ -0,0 +1,5 @@
1
+ export enum ThemeModeEnum {
2
+ DARK = 'dark',
3
+ LIGHT = 'light',
4
+ AUTO = 'auto',
5
+ }
@@ -0,0 +1,265 @@
1
+ import type { ThemeMode } from '../../store/slices/settings';
2
+ import type { ListPropTypes, SvgIconProps } from '@rango-dev/ui';
3
+
4
+ import { i18n } from '@lingui/core';
5
+ import {
6
+ AutoThemeIcon,
7
+ BridgeIcon,
8
+ ChevronRightIcon,
9
+ DarkModeIcon,
10
+ Divider,
11
+ DoneIcon,
12
+ ExchangeIcon,
13
+ InfoIcon,
14
+ LanguageIcon,
15
+ LightModeIcon,
16
+ List,
17
+ ListItem,
18
+ ListItemButton,
19
+ Skeleton,
20
+ styled,
21
+ Switch,
22
+ Tabs,
23
+ Tooltip,
24
+ Typography,
25
+ } from '@rango-dev/ui';
26
+ import React from 'react';
27
+ import { useNavigate } from 'react-router-dom';
28
+
29
+ import { SlippageTooltipContainer as TooltipContainer } from '../../components/Slippage/Slippage.styles';
30
+ import { navigationRoutes } from '../../constants/navigationRoutes';
31
+ import { ThemeModeEnum } from '../../constants/settings';
32
+ import { useAppStore } from '../../store/AppStore';
33
+ import { getContainer } from '../../utils/common';
34
+ import { getUniqueSwappersGroups, isFeatureHidden } from '../../utils/settings';
35
+
36
+ const ThemeSection = styled('div', {
37
+ width: '202px',
38
+ height: '$40',
39
+ });
40
+
41
+ const themesList = [
42
+ {
43
+ id: ThemeModeEnum.LIGHT,
44
+ icon: <LightModeIcon color="black" size={16} />,
45
+ tooltip: (
46
+ <Typography size="xsmall" variant="body">
47
+ {i18n.t('Light')}
48
+ </Typography>
49
+ ),
50
+ },
51
+ {
52
+ id: ThemeModeEnum.DARK,
53
+ icon: <DarkModeIcon color="black" size={16} />,
54
+ tooltip: (
55
+ <Typography size="xsmall" variant="body">
56
+ {i18n.t('Dark')}
57
+ </Typography>
58
+ ),
59
+ },
60
+ {
61
+ id: ThemeModeEnum.AUTO,
62
+ icon: <AutoThemeIcon color="black" size={16} />,
63
+ tooltip: (
64
+ <Typography size="xsmall" variant="body">
65
+ {i18n.t('Auto')}
66
+ </Typography>
67
+ ),
68
+ },
69
+ ];
70
+
71
+ const getThemeIcon = (theme: ThemeMode) => {
72
+ const iconProps: SvgIconProps = { color: 'gray', size: 12 };
73
+
74
+ switch (theme) {
75
+ case 'auto':
76
+ return <AutoThemeIcon {...iconProps} />;
77
+ case 'dark':
78
+ return <DarkModeIcon {...iconProps} />;
79
+ default:
80
+ return <LightModeIcon {...iconProps} />;
81
+ }
82
+ };
83
+
84
+ export function SettingsLists() {
85
+ const navigate = useNavigate();
86
+ const { theme: themeConfig } = useAppStore().config;
87
+ const { setTheme, theme } = useAppStore();
88
+
89
+ const fetchStatus = useAppStore().fetchStatus;
90
+ const swappers = useAppStore().swappers();
91
+ const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
92
+ const {
93
+ config: { features },
94
+ } = useAppStore();
95
+ const isThemeHidden = isFeatureHidden('theme', features);
96
+ const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
97
+ const isLanguageHidden = isFeatureHidden('language', features);
98
+
99
+ const infiniteApprove = useAppStore().infiniteApprove;
100
+ const toggleInfiniteApprove = useAppStore().toggleInfiniteApprove;
101
+
102
+ const supportedUniqueSwappersGroups = getUniqueSwappersGroups(
103
+ swappers,
104
+ disabledLiquiditySources
105
+ );
106
+
107
+ const bridgeSources = supportedUniqueSwappersGroups.filter(
108
+ (uniqueItem) =>
109
+ uniqueItem.type === 'BRIDGE' || uniqueItem.type === 'AGGREGATOR'
110
+ );
111
+
112
+ const totalBridgeSources = bridgeSources.length;
113
+ const totalSelectedBridgeSources = bridgeSources.filter(
114
+ (uniqueItem) => uniqueItem.selected
115
+ ).length;
116
+
117
+ const exchangeSources = supportedUniqueSwappersGroups.filter(
118
+ (uniqueItem) => uniqueItem.type === 'DEX'
119
+ );
120
+
121
+ const totalExchangeSources = exchangeSources.length;
122
+ const totalSelectedExchangeSources = exchangeSources.filter(
123
+ (uniqueItem) => uniqueItem.selected
124
+ ).length;
125
+
126
+ const handleEndItem = (totalSelected: number, total: number) => {
127
+ switch (fetchStatus) {
128
+ case 'loading':
129
+ return <Skeleton variant="text" size="medium" width={50} />;
130
+ case 'failed':
131
+ return (
132
+ <Typography variant="body" size="medium" color="$error500">
133
+ {i18n.t('Loading failed')}
134
+ </Typography>
135
+ );
136
+ default:
137
+ return (
138
+ <Typography variant="body" size="medium">
139
+ {`${totalSelected} / ${total}`}
140
+ </Typography>
141
+ );
142
+ }
143
+ };
144
+
145
+ const bridgeItem = {
146
+ id: 'bridge-item',
147
+ title: (
148
+ <Typography variant="title" size="xmedium">
149
+ {i18n.t('Enabled bridges')}
150
+ </Typography>
151
+ ),
152
+ end: (
153
+ <>
154
+ {handleEndItem(totalSelectedBridgeSources, totalBridgeSources)}
155
+ <Divider direction="horizontal" size={8} />
156
+ <ChevronRightIcon color="black" />
157
+ </>
158
+ ),
159
+ onClick: () => navigate(navigationRoutes.bridges),
160
+ start: <BridgeIcon color="gray" size={12} />,
161
+ };
162
+
163
+ const exchangeItem = {
164
+ id: 'exchange-item',
165
+ title: (
166
+ <Typography variant="title" size="xmedium">
167
+ {i18n.t('Enabled exchanges')}
168
+ </Typography>
169
+ ),
170
+ end: (
171
+ <>
172
+ {handleEndItem(totalSelectedExchangeSources, totalExchangeSources)}
173
+ <Divider direction="horizontal" size={8} />
174
+ <ChevronRightIcon color="gray" />
175
+ </>
176
+ ),
177
+ start: <ExchangeIcon color="gray" size={12} />,
178
+ onClick: () => navigate(navigationRoutes.exchanges),
179
+ };
180
+
181
+ const languageItem = {
182
+ id: 'language-item',
183
+ title: (
184
+ <Typography variant="title" size="xmedium">
185
+ {i18n.t('Language')}
186
+ </Typography>
187
+ ),
188
+ start: <LanguageIcon color="gray" size={12} />,
189
+ end: <ChevronRightIcon color="gray" />,
190
+ onClick: () => navigate(navigationRoutes.languages),
191
+ };
192
+
193
+ const infiniteApprovalItem = {
194
+ id: 'infinite-approval-item',
195
+ title: (
196
+ <>
197
+ <Typography variant="title" size="xmedium">
198
+ {i18n.t('Infinite approval')}
199
+ </Typography>
200
+ <Divider direction="horizontal" size={4} />
201
+ <Tooltip
202
+ side="top"
203
+ sideOffset={4}
204
+ container={getContainer()}
205
+ content={
206
+ <TooltipContainer>
207
+ <Typography variant="label" size="medium" color="neutral700">
208
+ {i18n.t(
209
+ "Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations."
210
+ )}
211
+ </Typography>
212
+ </TooltipContainer>
213
+ }>
214
+ <InfoIcon color="gray" />
215
+ </Tooltip>
216
+ </>
217
+ ),
218
+ start: <DoneIcon color="gray" size={12} />,
219
+ end: <Switch checked={infiniteApprove} />,
220
+ onClick: toggleInfiniteApprove,
221
+ };
222
+
223
+ const themeItem = {
224
+ id: 'theme-item',
225
+ type: <ListItem />,
226
+ title: (
227
+ <Typography variant="title" size="xmedium">
228
+ {i18n.t('Theme')}
229
+ </Typography>
230
+ ),
231
+ end: (
232
+ <ThemeSection>
233
+ <Tabs
234
+ container={getContainer()}
235
+ items={themesList}
236
+ value={theme}
237
+ onChange={(item) => setTheme(item.id as ThemeMode)}
238
+ type="primary"
239
+ borderRadius="small"
240
+ />
241
+ </ThemeSection>
242
+ ),
243
+ start: getThemeIcon(theme),
244
+ };
245
+
246
+ const settingItems: ListPropTypes['items'] = isLiquidityHidden
247
+ ? []
248
+ : [bridgeItem, exchangeItem];
249
+
250
+ if (!isLanguageHidden) {
251
+ settingItems.push(languageItem);
252
+ }
253
+ settingItems.push(infiniteApprovalItem);
254
+
255
+ if (!themeConfig?.singleTheme && !isThemeHidden) {
256
+ settingItems.push(themeItem);
257
+ }
258
+
259
+ return (
260
+ <List
261
+ type={<ListItemButton hasDivider id="_" onClick={() => console.log()} />}
262
+ items={settingItems}
263
+ />
264
+ );
265
+ }
@@ -1,194 +1,21 @@
1
1
  import { i18n } from '@lingui/core';
2
- import {
3
- Alert,
4
- Button,
5
- ChevronRightIcon,
6
- Divider,
7
- InfoIcon,
8
- List,
9
- ListItemButton,
10
- Skeleton,
11
- styled,
12
- Switch,
13
- Tooltip,
14
- Typography,
15
- } from '@rango-dev/ui';
2
+ import { Alert, Button, styled } from '@rango-dev/ui';
16
3
  import React from 'react';
17
- import {
18
- useInRouterContext,
19
- useNavigate,
20
- useSearchParams,
21
- } from 'react-router-dom';
4
+ import { useInRouterContext, useSearchParams } from 'react-router-dom';
22
5
 
23
6
  import { Layout, PageContainer } from '../components/Layout';
24
7
  import { Slippage } from '../components/Slippage';
25
- import { SlippageTooltipContainer as TooltipContainer } from '../components/Slippage/Slippage.styles';
26
- import { navigationRoutes } from '../constants/navigationRoutes';
27
8
  import { SearchParams } from '../constants/searchParams';
9
+ import { SettingsLists } from '../containers/Settings/Lists';
28
10
  import { useAppStore } from '../store/AppStore';
29
- import { getContainer } from '../utils/common';
30
- import { getUniqueSwappersGroups, isFeatureHidden } from '../utils/settings';
31
11
 
32
12
  const ResetAction = styled('div', {
33
13
  paddingLeft: '$8',
34
14
  });
35
15
 
36
16
  export function SettingsPage() {
37
- const navigate = useNavigate();
38
- const { theme } = useAppStore().config;
39
- const fetchStatus = useAppStore().fetchStatus;
40
- const swappers = useAppStore().swappers();
41
- const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
42
- const {
43
- config: { features },
44
- isInCampaignMode,
45
- updateCampaignMode,
46
- } = useAppStore();
17
+ const { isInCampaignMode, updateCampaignMode } = useAppStore();
47
18
  const campaignMode = isInCampaignMode();
48
- const isThemeHidden = isFeatureHidden('theme', features);
49
-
50
- const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
51
-
52
- const isLanguageHidden = isFeatureHidden('language', features);
53
-
54
- const infiniteApprove = useAppStore().infiniteApprove;
55
- const toggleInfiniteApprove = useAppStore().toggleInfiniteApprove;
56
-
57
- const supportedUniqueSwappersGroups = getUniqueSwappersGroups(
58
- swappers,
59
- disabledLiquiditySources
60
- );
61
-
62
- const bridgeSources = supportedUniqueSwappersGroups.filter(
63
- (uniqueItem) =>
64
- uniqueItem.type === 'BRIDGE' || uniqueItem.type === 'AGGREGATOR'
65
- );
66
- const totalBridgeSources = bridgeSources.length;
67
- const totalSelectedBridgeSources = bridgeSources.filter(
68
- (uniqueItem) => uniqueItem.selected
69
- ).length;
70
-
71
- const exchangeSources = supportedUniqueSwappersGroups.filter(
72
- (uniqueItem) => uniqueItem.type === 'DEX'
73
- );
74
- const totalExchangeSources = exchangeSources.length;
75
- const totalSelectedExchangeSources = exchangeSources.filter(
76
- (uniqueItem) => uniqueItem.selected
77
- ).length;
78
-
79
- const handleEndItem = (totalSelected: number, total: number) => {
80
- switch (fetchStatus) {
81
- case 'loading':
82
- return <Skeleton variant="text" size="medium" width={50} />;
83
- case 'failed':
84
- return (
85
- <Typography variant="body" size="medium" color="$error500">
86
- {i18n.t('Loading failed')}
87
- </Typography>
88
- );
89
- default:
90
- return (
91
- <Typography variant="body" size="medium">
92
- {`${totalSelected} / ${total}`}
93
- </Typography>
94
- );
95
- }
96
- };
97
-
98
- const bridgeItem = {
99
- id: 'bridge-item',
100
- title: (
101
- <Typography variant="title" size="xmedium">
102
- {i18n.t('Enabled bridges')}
103
- </Typography>
104
- ),
105
- end: (
106
- <>
107
- {handleEndItem(totalSelectedBridgeSources, totalBridgeSources)}
108
- <Divider direction="horizontal" size={8} />
109
- <ChevronRightIcon color="black" />
110
- </>
111
- ),
112
- onClick: () => navigate(navigationRoutes.bridges),
113
- };
114
-
115
- const exchangeItem = {
116
- id: 'exchange-item',
117
- title: (
118
- <Typography variant="title" size="xmedium">
119
- {i18n.t('Enabled exchanges')}
120
- </Typography>
121
- ),
122
- end: (
123
- <>
124
- {handleEndItem(totalSelectedExchangeSources, totalExchangeSources)}
125
- <Divider direction="horizontal" size={8} />
126
- <ChevronRightIcon color="gray" />
127
- </>
128
- ),
129
- onClick: () => navigate(navigationRoutes.exchanges),
130
- };
131
-
132
- const languageItem = {
133
- id: 'language-item',
134
- title: (
135
- <Typography variant="title" size="xmedium">
136
- {i18n.t('Language')}
137
- </Typography>
138
- ),
139
- end: <ChevronRightIcon color="gray" />,
140
- onClick: () => navigate(navigationRoutes.languages),
141
- };
142
-
143
- const themeItem = {
144
- id: 'theme-item',
145
- title: (
146
- <Typography variant="title" size="xmedium">
147
- {i18n.t('Theme')}
148
- </Typography>
149
- ),
150
- end: <ChevronRightIcon color="gray" />,
151
- onClick: () => navigate(navigationRoutes.themes),
152
- };
153
-
154
- const infiniteApprovalItem = {
155
- id: 'infinite-approval-item',
156
- title: (
157
- <>
158
- <Typography variant="title" size="xmedium">
159
- {i18n.t('Infinite approval')}
160
- </Typography>
161
- <Divider direction="horizontal" size={4} />
162
- <Tooltip
163
- side="top"
164
- sideOffset={4}
165
- container={getContainer()}
166
- content={
167
- <TooltipContainer>
168
- <Typography variant="label" size="medium" color="neutral700">
169
- {i18n.t(
170
- "Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations."
171
- )}
172
- </Typography>
173
- </TooltipContainer>
174
- }>
175
- <InfoIcon color="gray" />
176
- </Tooltip>
177
- </>
178
- ),
179
- end: <Switch checked={infiniteApprove} />,
180
- onClick: toggleInfiniteApprove,
181
- };
182
-
183
- const settingItems = isLiquidityHidden ? [] : [bridgeItem, exchangeItem];
184
-
185
- if (!isLanguageHidden) {
186
- settingItems.push(languageItem);
187
- }
188
- if (!theme?.singleTheme && !isThemeHidden) {
189
- settingItems.push(themeItem);
190
- }
191
- settingItems.push(infiniteApprovalItem);
192
19
 
193
20
  const [, setSearchParams] = useSearchParams();
194
21
  const isRouterInContext = useInRouterContext();
@@ -222,19 +49,14 @@ export function SettingsPage() {
222
49
  action={
223
50
  <ResetAction>
224
51
  <Button type="secondary" size="small" onClick={onClick}>
225
- Reset
52
+ {i18n.t('Reset')}
226
53
  </Button>
227
54
  </ResetAction>
228
55
  }
229
56
  />
230
57
  )}
231
58
  <Slippage />
232
- <List
233
- type={
234
- <ListItemButton title="_" id="_" onClick={() => console.log()} />
235
- }
236
- items={settingItems}
237
- />
59
+ <SettingsLists />
238
60
  </PageContainer>
239
61
  </Layout>
240
62
  );
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare function ThemePage(): React.JSX.Element;
3
- //# sourceMappingURL=ThemePage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemePage.d.ts","sourceRoot":"","sources":["../../src/pages/ThemePage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,wBAAgB,SAAS,sBAiExB"}
@@ -1,90 +0,0 @@
1
- import { i18n } from '@lingui/core';
2
- import {
3
- AutoThemeIcon,
4
- DarkModeIcon,
5
- LightModeIcon,
6
- List,
7
- ListItemButton,
8
- Radio,
9
- RadioRoot,
10
- Typography,
11
- } from '@rango-dev/ui';
12
- import React from 'react';
13
-
14
- import { Layout, PageContainer } from '../components/Layout';
15
- import { useAppStore } from '../store/AppStore';
16
-
17
- type Theme = 'dark' | 'light' | 'auto';
18
-
19
- enum Mode {
20
- DARK = 'dark',
21
- LIGHT = 'light',
22
- AUTO = 'auto',
23
- }
24
-
25
- export function ThemePage() {
26
- const { setTheme, theme } = useAppStore();
27
-
28
- const themesList = [
29
- {
30
- id: Mode.LIGHT,
31
- value: Mode.LIGHT,
32
- title: (
33
- <Typography variant="title" size="xmedium">
34
- {i18n.t('Light')}
35
- </Typography>
36
- ),
37
- onClick: () => setTheme(Mode.LIGHT as Theme),
38
- start: <LightModeIcon color="gray" />,
39
- end: <Radio value={Mode.LIGHT} />,
40
- },
41
- {
42
- id: Mode.DARK,
43
- value: Mode.DARK,
44
- title: (
45
- <Typography variant="title" size="xmedium">
46
- {i18n.t('Dark')}
47
- </Typography>
48
- ),
49
- onClick: () => setTheme(Mode.DARK as Theme),
50
- start: <DarkModeIcon color="gray" />,
51
- end: <Radio value={Mode.DARK} />,
52
- },
53
- {
54
- id: Mode.AUTO,
55
- value: Mode.AUTO,
56
- title: (
57
- <Typography variant="title" size="xmedium">
58
- {i18n.t('Auto')}
59
- </Typography>
60
- ),
61
- onClick: () => setTheme(Mode.AUTO as Theme),
62
- start: <AutoThemeIcon color="gray" />,
63
- end: <Radio value={Mode.AUTO} />,
64
- },
65
- ];
66
-
67
- return (
68
- <Layout
69
- header={{
70
- title: i18n.t('Theme'),
71
- }}>
72
- <PageContainer>
73
- <RadioRoot
74
- onValueChange={(value) => setTheme(value as Theme)}
75
- value={theme}>
76
- <List
77
- type={
78
- <ListItemButton
79
- title={i18n.t('Theme')}
80
- id="_"
81
- onClick={() => console.log()}
82
- />
83
- }
84
- items={themesList}
85
- />
86
- </RadioRoot>
87
- </PageContainer>
88
- </Layout>
89
- );
90
- }