@rango-dev/widget-embedded 0.28.2 → 0.28.3-next.1

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +1 -2
  3. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
  4. package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -1
  5. package/dist/components/HeaderButtons/NotificationsBadge.d.ts +3 -0
  6. package/dist/components/HeaderButtons/NotificationsBadge.d.ts.map +1 -0
  7. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  8. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +769 -0
  9. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  10. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  11. package/dist/constants/fonts.d.ts +5 -0
  12. package/dist/constants/fonts.d.ts.map +1 -1
  13. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
  14. package/dist/globalStyles.d.ts.map +1 -1
  15. package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
  16. package/dist/hooks/useFontLoader.d.ts +5 -0
  17. package/dist/hooks/useFontLoader.d.ts.map +1 -0
  18. package/dist/hooks/useSyncNotifications/index.d.ts +2 -0
  19. package/dist/hooks/useSyncNotifications/index.d.ts.map +1 -0
  20. package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts +2 -0
  21. package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts.map +1 -0
  22. package/dist/hooks/useTheme.d.ts.map +1 -1
  23. package/dist/index.d.ts +2 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -2
  26. package/dist/index.js.map +4 -4
  27. package/dist/pages/WalletsPage.d.ts.map +1 -1
  28. package/dist/store/notification.d.ts +27 -7
  29. package/dist/store/notification.d.ts.map +1 -1
  30. package/dist/types/config.d.ts +5 -1
  31. package/dist/types/config.d.ts.map +1 -1
  32. package/dist/types/notification.d.ts +0 -1
  33. package/dist/types/notification.d.ts.map +1 -1
  34. package/dist/utils/common.d.ts +3 -0
  35. package/dist/utils/common.d.ts.map +1 -1
  36. package/dist/utils/configs.d.ts +0 -1
  37. package/dist/utils/configs.d.ts.map +1 -1
  38. package/dist/utils/swap.d.ts +2 -0
  39. package/dist/utils/swap.d.ts.map +1 -1
  40. package/dist/utils/wallets.d.ts +2 -0
  41. package/dist/utils/wallets.d.ts.map +1 -1
  42. package/dist/widget-embedded.build.json +1 -0
  43. package/package.json +9 -8
  44. package/src/components/BlockchainList/BlockchainList.helpers.ts +6 -25
  45. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +4 -4
  46. package/src/components/HeaderButtons/HeaderButtons.styles.ts +1 -1
  47. package/src/components/HeaderButtons/HeaderButtons.tsx +3 -2
  48. package/src/components/HeaderButtons/{UnreadNotificationsBadge.tsx → NotificationsBadge.tsx} +3 -3
  49. package/src/components/NotificationContent/NotificationContent.styles.ts +17 -2
  50. package/src/components/NotificationContent/NotificationContent.tsx +28 -3
  51. package/src/components/Quote/Quote.styles.ts +1 -1
  52. package/src/components/Slippage/Slippage.tsx +1 -1
  53. package/src/components/SwapDetails/SwapDetails.tsx +5 -6
  54. package/src/constants/fonts.ts +84 -0
  55. package/src/containers/WidgetInfo/WidgetInfo.tsx +1 -1
  56. package/src/containers/WidgetProvider/WidgetProvider.tsx +20 -2
  57. package/src/globalStyles.ts +1 -3
  58. package/src/hooks/useBootstrap/useBootstrap.ts +3 -1
  59. package/src/hooks/useFontLoader.ts +40 -0
  60. package/src/hooks/useSyncNotifications/index.ts +1 -0
  61. package/src/hooks/useSyncNotifications/useSyncNotifications.ts +25 -0
  62. package/src/hooks/useTheme.ts +1 -1
  63. package/src/index.ts +2 -0
  64. package/src/pages/SelectBlockchainPage.tsx +3 -3
  65. package/src/pages/WalletsPage.tsx +34 -2
  66. package/src/store/notification.ts +62 -17
  67. package/src/types/config.ts +6 -1
  68. package/src/types/notification.ts +0 -1
  69. package/src/utils/common.ts +29 -0
  70. package/src/utils/configs.ts +0 -1
  71. package/src/utils/swap.ts +12 -0
  72. package/src/utils/wallets.ts +53 -2
  73. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts +0 -3
  74. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.28.2",
3
+ "version": "0.28.3-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,14 +24,15 @@
24
24
  "dependencies": {
25
25
  "@lingui/core": "4.2.1",
26
26
  "@lingui/react": "4.2.1",
27
- "@rango-dev/logging-core": "^0.3.0",
28
- "@rango-dev/provider-all": "^0.33.2",
27
+ "@rango-dev/logging-core": "^0.3.1-next.1",
28
+ "@rango-dev/provider-all": "^0.33.3-next.0",
29
29
  "@rango-dev/queue-manager-core": "^0.26.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.33.2",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.33.3-next.0",
31
31
  "@rango-dev/queue-manager-react": "^0.26.0",
32
- "@rango-dev/ui": "^0.34.0",
33
- "@rango-dev/wallets-react": "^0.19.0",
34
- "@rango-dev/wallets-shared": "^0.33.0",
32
+ "@rango-dev/signer-solana": "^0.28.1-next.2",
33
+ "@rango-dev/ui": "^0.34.1-next.3",
34
+ "@rango-dev/wallets-react": "^0.19.1-next.1",
35
+ "@rango-dev/wallets-shared": "^0.33.1-next.1",
35
36
  "bignumber.js": "^9.1.1",
36
37
  "copy-to-clipboard": "^3.3.3",
37
38
  "dayjs": "^1.11.7",
@@ -52,4 +53,4 @@
52
53
  "publishConfig": {
53
54
  "access": "public"
54
55
  }
55
- }
56
+ }
@@ -1,35 +1,16 @@
1
- import { BlockchainCategories } from '@rango-dev/ui';
2
- import { type BlockchainMeta, TransactionType } from 'rango-sdk';
1
+ import { type BlockchainMeta } from 'rango-sdk';
3
2
 
4
- import { containsText } from '../../utils/common';
5
-
6
- export const filterByType = (
7
- blockchain: BlockchainMeta,
8
- type: string
9
- ): boolean => {
10
- switch (type) {
11
- case BlockchainCategories.ALL:
12
- return true;
13
- case BlockchainCategories.UTXO:
14
- return blockchain.type === TransactionType.TRANSFER;
15
- case BlockchainCategories.OTHER:
16
- return (
17
- blockchain.type !== TransactionType.TRANSFER &&
18
- blockchain.type !== TransactionType.COSMOS &&
19
- blockchain.type !== TransactionType.EVM
20
- );
21
- default:
22
- return blockchain.type === type;
23
- }
24
- };
3
+ import { containsText, isBlockchainTypeInCategory } from '../../utils/common';
25
4
 
26
5
  export const filterBlockchains = (
27
6
  list: BlockchainMeta[],
28
7
  searchedFor: string,
29
- blockchainType: string
8
+ blockchainCategory: string
30
9
  ) =>
31
10
  list
32
- .filter((blockchain) => filterByType(blockchain, blockchainType))
11
+ .filter((blockchain) =>
12
+ isBlockchainTypeInCategory(blockchain.type, blockchainCategory)
13
+ )
33
14
  .filter(
34
15
  (blockchain) =>
35
16
  containsText(blockchain.name, searchedFor) ||
@@ -34,7 +34,7 @@ export const WalletButton = styled('button', {
34
34
  position: 'relative',
35
35
 
36
36
  '&:hover': {
37
- $$color: '$colors$info100',
37
+ $$color: '$colors$secondary100',
38
38
  [`.${darkTheme} &`]: {
39
39
  $$color: '$colors$neutral100',
40
40
  },
@@ -42,7 +42,7 @@ export const WalletButton = styled('button', {
42
42
  },
43
43
 
44
44
  '&:focus-visible': {
45
- $$color: '$colors$info100',
45
+ $$color: '$colors$secondary100',
46
46
  [`.${darkTheme} &`]: {
47
47
  $$color: '$colors$info700',
48
48
  },
@@ -138,14 +138,14 @@ export const CustomDestinationButton = styled('div', {
138
138
  borderBottomRightRadius: '0',
139
139
  borderBottomLeftRadius: '0',
140
140
  '&:hover': {
141
- $$color: '$colors$info100',
141
+ $$color: '$colors$secondary100',
142
142
  [`.${darkTheme} &`]: {
143
143
  $$color: '$colors$neutral100',
144
144
  },
145
145
  backgroundColor: '$$color',
146
146
  },
147
147
  '&:focus-visible': {
148
- $$background: '$colors$info100',
148
+ $$background: '$colors$secondary100',
149
149
  [`.${darkTheme} &`]: {
150
150
  $$background: '$colors$info700',
151
151
  },
@@ -6,7 +6,7 @@ export const HeaderButton = styled(IconButton, {
6
6
  padding: '0',
7
7
  overflow: 'unset',
8
8
  '&:hover': {
9
- backgroundColor: '$info100',
9
+ backgroundColor: '$secondary100',
10
10
  [`.${darkTheme} &`]: {
11
11
  backgroundColor: '$neutral',
12
12
  },
@@ -17,8 +17,8 @@ import { NotificationContent } from '../NotificationContent';
17
17
 
18
18
  import { HeaderButton } from './HeaderButtons.styles';
19
19
  import InProgressTransactionBadge from './InProgressTransactionBadge';
20
+ import { NotificationsBadge } from './NotificationsBadge';
20
21
  import { RefreshButton } from './RefreshButton';
21
- import { UnreadNotificationsBadge } from './UnreadNotificationsBadge';
22
22
 
23
23
  export function HeaderButtons(props: HeaderButtonsPropTypes) {
24
24
  const {
@@ -52,6 +52,7 @@ export function HeaderButtons(props: HeaderButtonsPropTypes) {
52
52
  <Popover
53
53
  align="end"
54
54
  alignOffset={-88}
55
+ sideOffset={15}
55
56
  collisionPadding={{ right: 20, left: 20 }}
56
57
  container={getContainer()}
57
58
  content={<NotificationContent />}>
@@ -62,7 +63,7 @@ export function HeaderButtons(props: HeaderButtonsPropTypes) {
62
63
  content={i18n.t('Notifications')}>
63
64
  <HeaderButton size="small" variant="ghost">
64
65
  <NotificationsIcon size={18} color="black" />
65
- <UnreadNotificationsBadge />
66
+ <NotificationsBadge />
66
67
  </HeaderButton>
67
68
  </Tooltip>
68
69
  </div>
@@ -6,10 +6,10 @@ import { useNotificationStore } from '../../store/notification';
6
6
 
7
7
  import { NotificationsBadgeContainer } from './HeaderButtons.styles';
8
8
 
9
- export function UnreadNotificationsBadge() {
10
- const { getUnreadNotifications } = useNotificationStore();
9
+ export function NotificationsBadge() {
10
+ const { getNotifications } = useNotificationStore();
11
11
 
12
- const notificationsList = getUnreadNotifications();
12
+ const notificationsList = getNotifications();
13
13
 
14
14
  const notificationsCount = notificationsList.length;
15
15
 
@@ -1,4 +1,4 @@
1
- import { darkTheme, ListItemButton, styled } from '@rango-dev/ui';
1
+ import { Button, darkTheme, ListItemButton, styled } from '@rango-dev/ui';
2
2
 
3
3
  export const Container = styled('div', {
4
4
  padding: '$10',
@@ -7,6 +7,17 @@ export const Container = styled('div', {
7
7
  minHeight: '150px',
8
8
  });
9
9
 
10
+ export const Header = styled('div', {
11
+ padding: '0 $10',
12
+ display: 'flex',
13
+ justifyContent: 'space-between',
14
+ alignItems: 'center',
15
+ });
16
+
17
+ export const ClearAllButton = styled(Button, {
18
+ padding: '$5 !important',
19
+ });
20
+
10
21
  export const List = styled('ul', {
11
22
  padding: 0,
12
23
  margin: 0,
@@ -32,7 +43,7 @@ export const ListItem = styled(ListItemButton, {
32
43
 
33
44
  export const Images = styled('div', {
34
45
  display: 'flex',
35
- padding: 0,
46
+ padding: '0 0 0 $5',
36
47
  alignItems: 'center',
37
48
  alignSelf: 'stretch',
38
49
  });
@@ -46,3 +57,7 @@ export const NotFoundContainer = styled('div', {
46
57
  width: '100%',
47
58
  height: '150px',
48
59
  });
60
+
61
+ export const IconContainer = styled('span', {
62
+ paddingRight: '$8',
63
+ });
@@ -17,7 +17,10 @@ import { useNotificationStore } from '../../store/notification';
17
17
  import { areTokensEqual } from '../../utils/wallets';
18
18
 
19
19
  import {
20
+ ClearAllButton,
20
21
  Container,
22
+ Header,
23
+ IconContainer,
21
24
  Images,
22
25
  List,
23
26
  ListItem,
@@ -29,9 +32,9 @@ const MAX_NOTIFICATIONS_DISPLAYED = 4;
29
32
  export function NotificationContent() {
30
33
  const navigate = useNavigate();
31
34
 
32
- const { getUnreadNotifications } = useNotificationStore();
35
+ const { getNotifications, clearNotifications } = useNotificationStore();
33
36
 
34
- const notifications: Notification[] = getUnreadNotifications();
37
+ const notifications: Notification[] = getNotifications();
35
38
  const blockchains = useAppStore().blockchains();
36
39
  const tokens = useAppStore().tokens();
37
40
  const sortedNotification = notifications
@@ -44,6 +47,24 @@ export function NotificationContent() {
44
47
 
45
48
  return (
46
49
  <Container>
50
+ {sortedNotification.length > 0 && (
51
+ <>
52
+ <Header>
53
+ <Typography variant="label" size="medium">
54
+ {i18n.t('Notifications')}
55
+ </Typography>
56
+ <ClearAllButton
57
+ variant="ghost"
58
+ size="xsmall"
59
+ onClick={clearNotifications}>
60
+ <Typography variant="body" size="xsmall">
61
+ {i18n.t('Clear all')}
62
+ </Typography>
63
+ </ClearAllButton>
64
+ </Header>
65
+ <Divider direction="vertical" size={4} />
66
+ </>
67
+ )}
47
68
  {sortedNotification.length ? (
48
69
  <List>
49
70
  {sortedNotification.map((notificationItem, index) => {
@@ -103,7 +124,11 @@ export function NotificationContent() {
103
124
  </div>
104
125
  </Images>
105
126
  }
106
- end={<ChevronRightIcon size={12} color="gray" />}
127
+ end={
128
+ <IconContainer>
129
+ <ChevronRightIcon size={12} color="gray" />
130
+ </IconContainer>
131
+ }
107
132
  />
108
133
  </React.Fragment>
109
134
  );
@@ -147,7 +147,7 @@ export const SummaryContainer = styled('div', {
147
147
  listItem: false,
148
148
  selected: true,
149
149
  css: {
150
- $$color: '$colors$info100',
150
+ $$color: '$colors$secondary100',
151
151
  [`.${darkTheme} &`]: {
152
152
  $$color: '$colors$secondary600',
153
153
  },
@@ -67,7 +67,7 @@ export function Slippage() {
67
67
  step="0.01"
68
68
  fullWidth
69
69
  variant="contained"
70
- value={customSlippage || ''}
70
+ value={customSlippage === null ? '' : customSlippage}
71
71
  color="dark"
72
72
  onChange={(event) => {
73
73
  const value = event.target.value;
@@ -96,21 +96,20 @@ export function SwapDetails(props: SwapDetailsProps) {
96
96
  setModalState(null);
97
97
  };
98
98
 
99
- const getUnreadNotifications =
100
- useNotificationStore.use.getUnreadNotifications();
101
- const setAsRead = useNotificationStore.use.setAsRead();
102
- const unreadNotifications = getUnreadNotifications();
99
+ const getNotifications = useNotificationStore.use.getNotifications();
100
+ const removeNotification = useNotificationStore.use.removeNotification();
101
+ const notifications = getNotifications();
103
102
  const currentStep = getCurrentStep(swap);
104
103
  const currentStepNetworkStatus = currentStep?.networkStatus;
105
104
 
106
105
  useEffect(() => {
107
- const existNotification = unreadNotifications.find(
106
+ const existNotification = notifications.find(
108
107
  (n) => n.requestId === swap.requestId
109
108
  );
110
109
  if (existNotification) {
111
110
  if (swap.status === 'success' || swap.status === 'failed') {
112
111
  setShowCompletedModal(swap.status);
113
- setAsRead(swap.requestId);
112
+ removeNotification(swap.requestId);
114
113
  } else if (showCompletedModal) {
115
114
  setShowCompletedModal(null);
116
115
  }
@@ -1 +1,85 @@
1
1
  export const DEFAULT_FONT_FAMILY = 'Roboto';
2
+
3
+ export const SUPPORTED_FONTS = [
4
+ {
5
+ name: 'Roboto',
6
+ value: 'Roboto',
7
+ url: '',
8
+ },
9
+ {
10
+ name: 'Times New Roman',
11
+ value: 'Times New Roman',
12
+ url: 'https://fonts.cdnfonts.com/css/times-new-roman',
13
+ },
14
+ {
15
+ name: 'Arial',
16
+ value: 'Arial',
17
+ url: '',
18
+ },
19
+ {
20
+ name: 'Open Sans',
21
+ value: 'Open Sans',
22
+ url: 'https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap',
23
+ },
24
+ {
25
+ name: 'Noto Sans',
26
+ value: 'Noto Sans',
27
+ url: 'https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap',
28
+ },
29
+ {
30
+ name: 'Montserrat',
31
+ value: 'Montserrat',
32
+ url: 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap',
33
+ },
34
+ {
35
+ name: 'Poppins',
36
+ value: 'Poppins',
37
+ url: 'https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap',
38
+ },
39
+ {
40
+ name: 'Roboto Condensed',
41
+ value: 'Roboto Condensed',
42
+ url: 'https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap',
43
+ },
44
+
45
+ {
46
+ name: 'Roboto Mono',
47
+ value: 'Roboto Mono',
48
+ url: 'https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap',
49
+ },
50
+ {
51
+ name: 'Oswald',
52
+ value: 'Oswald',
53
+ url: 'https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap',
54
+ },
55
+ {
56
+ name: 'Raleway',
57
+ value: 'Raleway',
58
+ url: 'https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap',
59
+ },
60
+ {
61
+ name: 'Sedan',
62
+ value: 'Sedan',
63
+ url: 'https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap',
64
+ },
65
+ {
66
+ name: 'Inter',
67
+ value: 'Inter',
68
+ url: 'https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap',
69
+ },
70
+ {
71
+ name: 'Rubik',
72
+ value: 'Rubik',
73
+ url: 'https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap',
74
+ },
75
+ {
76
+ name: 'Lora',
77
+ value: 'Lora',
78
+ url: 'https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap',
79
+ },
80
+ {
81
+ name: 'Barlow Condensed',
82
+ value: 'Barlow Condensed',
83
+ url: 'https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap',
84
+ },
85
+ ];
@@ -31,7 +31,7 @@ export function WidgetInfo(props: React.PropsWithChildren) {
31
31
  const swappers = useAppStore().swappers();
32
32
  const loadingStatus = useAppStore().fetchStatus;
33
33
  const resetLanguage = useLanguage().resetLanguage;
34
- const notifications = useNotificationStore().getUnreadNotifications();
34
+ const notifications = useNotificationStore().getNotifications();
35
35
 
36
36
  // eslint-disable-next-line react/jsx-no-constructed-context-values
37
37
  const value: WidgetInfoContextInterface = {
@@ -1,9 +1,11 @@
1
1
  import type { PropTypes } from './WidgetProvider.types';
2
2
  import type { PropsWithChildren } from 'react';
3
3
 
4
- import React, { useMemo } from 'react';
4
+ import { setSolanaSignerConfig } from '@rango-dev/signer-solana';
5
+ import React, { useEffect } from 'react';
5
6
 
6
7
  import { DEFAULT_BASE_URL, RANGO_PUBLIC_API_KEY } from '../../constants';
8
+ import useFontLoader from '../../hooks/useFontLoader';
7
9
  import QueueManager from '../../QueueManager';
8
10
  import { initConfig } from '../../utils/configs';
9
11
  import { WidgetWallets } from '../Wallets';
@@ -12,13 +14,29 @@ import { WidgetInfo } from '../WidgetInfo';
12
14
  export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
13
15
  const { onUpdateState, config } = props;
14
16
 
15
- useMemo(() => {
17
+ const fontFamily = props.config?.theme?.fontFamily;
18
+
19
+ const { handleLoadCustomFont } = useFontLoader();
20
+
21
+ useEffect(() => {
22
+ if (fontFamily) {
23
+ handleLoadCustomFont(fontFamily);
24
+ }
25
+ }, [fontFamily]);
26
+
27
+ useEffect(() => {
16
28
  initConfig({
17
29
  API_KEY: config?.apiKey || RANGO_PUBLIC_API_KEY,
18
30
  BASE_URL: config?.apiUrl || DEFAULT_BASE_URL,
19
31
  });
20
32
  }, [config.apiKey, config.apiUrl]);
21
33
 
34
+ useEffect(() => {
35
+ if (props.config?.signers?.customSolanaRPC) {
36
+ setSolanaSignerConfig('customRPC', props.config.signers.customSolanaRPC);
37
+ }
38
+ }, [props.config?.signers?.customSolanaRPC]);
39
+
22
40
  return (
23
41
  <WidgetWallets config={config} onUpdateState={onUpdateState}>
24
42
  <QueueManager apiKey={config.apiKey}>
@@ -2,8 +2,6 @@ import { globalCss } from '@rango-dev/ui';
2
2
 
3
3
  export const globalFont = () =>
4
4
  globalCss({
5
- '@import': [
5
+ '@import':
6
6
  "url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')",
7
- "url('https://fonts.cdnfonts.com/css/times-new-roman')",
8
- ],
9
7
  })();
@@ -14,11 +14,13 @@ import { tabManager } from '../../store/ui';
14
14
  import { useFetchApiConfig } from '../useFetchApiConfig';
15
15
  import { useForceAutoConnect } from '../useForceAutoConnect';
16
16
  import { useSubscribeToWidgetEvents } from '../useSubscribeToWidgetEvents';
17
+ import { useSyncNotifications } from '../useSyncNotifications';
17
18
 
18
19
  export function useBootstrap() {
19
- globalFont();
20
20
  useForceAutoConnect();
21
+ globalFont();
21
22
  useSubscribeToWidgetEvents();
23
+ useSyncNotifications();
22
24
  const blockchains = useAppStore().blockchains();
23
25
  const { canSwitchNetworkTo } = useWallets();
24
26
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
@@ -0,0 +1,40 @@
1
+ import { useState } from 'react';
2
+
3
+ import { getFontUrlByName } from '../utils/common';
4
+ /*
5
+ *TODO:
6
+ * Loading fonts from JS has a downside and it is the bundle needs to be downloaded and executed first which means after sometime font will be added to <head /> and it causes a layoutshift each time.
7
+ * We've added Roboto into <head /> since it's the default font. the downside here is it will load roboto anyway even dApp has set fontFamily other than Roboto which causes an unneccerary downloand (Roboto).
8
+ * We decided to go with the second one and it can be solved in future by split these types of configs into a separate js file and let it to be loaded with a more priority than the main bundle. it should be also cached which imrpove user experience after first load.
9
+ */
10
+ const useFontLoader = () => {
11
+ const [fontLink, setFontLink] = useState<HTMLLinkElement | null>(null);
12
+
13
+ const loadFont = (fontUrl: string) => {
14
+ const link = document.createElement('link');
15
+ link.href = fontUrl;
16
+ link.rel = 'stylesheet';
17
+ document.head.appendChild(link);
18
+ return link;
19
+ };
20
+
21
+ const unloadFont = () => {
22
+ if (fontLink) {
23
+ document.head.removeChild(fontLink);
24
+ setFontLink(null);
25
+ }
26
+ };
27
+
28
+ const handleLoadCustomFont = (fontName: string) => {
29
+ unloadFont(); // Remove previous font
30
+ const fontUrl = getFontUrlByName(fontName);
31
+ if (fontUrl) {
32
+ const newFontLink = loadFont(fontUrl);
33
+ setFontLink(newFontLink);
34
+ }
35
+ };
36
+
37
+ return { handleLoadCustomFont };
38
+ };
39
+
40
+ export default useFontLoader;
@@ -0,0 +1 @@
1
+ export { useSyncNotifications } from './useSyncNotifications';
@@ -0,0 +1,25 @@
1
+ import { useManager } from '@rango-dev/queue-manager-react';
2
+ import { useEffect } from 'react';
3
+
4
+ import { useNotificationStore } from '../../store/notification';
5
+ import { getPendingSwaps } from '../../utils/queue';
6
+
7
+ export function useSyncNotifications() {
8
+ const { isSynced, syncNotifications } = useNotificationStore();
9
+ const { manager, state } = useManager();
10
+
11
+ useEffect(() => {
12
+ const shouldSyncNotifications =
13
+ useNotificationStore.persist.hasHydrated() &&
14
+ state.loadedFromPersistor &&
15
+ !isSynced;
16
+
17
+ if (shouldSyncNotifications) {
18
+ syncNotifications(getPendingSwaps(manager));
19
+ }
20
+ }, [
21
+ useNotificationStore.persist.hasHydrated(),
22
+ state.loadedFromPersistor,
23
+ isSynced,
24
+ ]);
25
+ }
@@ -6,10 +6,10 @@ import {
6
6
  } from '@rango-dev/ui';
7
7
  import { useEffect, useState } from 'react';
8
8
 
9
+ import { DEFAULT_FONT_FAMILY } from '../constants/fonts';
9
10
  import { useAppStore } from '../store/AppStore';
10
11
  import { type WidgetTheme } from '../types';
11
12
  import {
12
- DEFAULT_FONT_FAMILY,
13
13
  DEFAULT_PRIMARY_RADIUS,
14
14
  DEFAULT_SECONDARY_RADIUS,
15
15
  } from '../utils/configs';
package/src/index.ts CHANGED
@@ -59,6 +59,7 @@ import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
59
59
  import { PendingSwapNetworkStatus } from 'rango-types';
60
60
 
61
61
  import { WIDGET_UI_ID as UI_ID } from './constants';
62
+ import { SUPPORTED_FONTS } from './constants/fonts';
62
63
  import { WidgetWallets } from './containers/Wallets';
63
64
  import { Widget } from './containers/Widget';
64
65
  import { useWidget } from './containers/WidgetInfo';
@@ -113,6 +114,7 @@ export {
113
114
  StepExecutionEventStatus,
114
115
  StepExecutionBlockedEventStatus,
115
116
  UI_ID,
117
+ SUPPORTED_FONTS,
116
118
  };
117
119
 
118
120
  // Internal type exports for Rango
@@ -1,7 +1,7 @@
1
1
  import { i18n } from '@lingui/core';
2
2
  import {
3
3
  Divider,
4
- getCountCategories,
4
+ getCategoriesCount,
5
5
  SelectableCategoryList,
6
6
  } from '@rango-dev/ui';
7
7
  import React, { useState } from 'react';
@@ -30,9 +30,9 @@ export function SelectBlockchainPage(props: PropTypes) {
30
30
  type,
31
31
  });
32
32
 
33
- const countActiveCategories = getCountCategories(blockchains);
33
+ const activeCategoriesCount = getCategoriesCount(blockchains);
34
34
 
35
- const showCategory = countActiveCategories !== 1;
35
+ const showCategory = activeCategoriesCount !== 1;
36
36
 
37
37
  return (
38
38
  <Layout