@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.
- package/CHANGELOG.md +4 -0
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +1 -2
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/NotificationsBadge.d.ts +3 -0
- package/dist/components/HeaderButtons/NotificationsBadge.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +769 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/constants/fonts.d.ts +5 -0
- package/dist/constants/fonts.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
- package/dist/hooks/useFontLoader.d.ts +5 -0
- package/dist/hooks/useFontLoader.d.ts.map +1 -0
- package/dist/hooks/useSyncNotifications/index.d.ts +2 -0
- package/dist/hooks/useSyncNotifications/index.d.ts.map +1 -0
- package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts +2 -0
- package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/notification.d.ts +27 -7
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/notification.d.ts +0 -1
- package/dist/types/notification.d.ts.map +1 -1
- package/dist/utils/common.d.ts +3 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +0 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -0
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -0
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -0
- package/package.json +9 -8
- package/src/components/BlockchainList/BlockchainList.helpers.ts +6 -25
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +4 -4
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +1 -1
- package/src/components/HeaderButtons/HeaderButtons.tsx +3 -2
- package/src/components/HeaderButtons/{UnreadNotificationsBadge.tsx → NotificationsBadge.tsx} +3 -3
- package/src/components/NotificationContent/NotificationContent.styles.ts +17 -2
- package/src/components/NotificationContent/NotificationContent.tsx +28 -3
- package/src/components/Quote/Quote.styles.ts +1 -1
- package/src/components/Slippage/Slippage.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +5 -6
- package/src/constants/fonts.ts +84 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +1 -1
- package/src/containers/WidgetProvider/WidgetProvider.tsx +20 -2
- package/src/globalStyles.ts +1 -3
- package/src/hooks/useBootstrap/useBootstrap.ts +3 -1
- package/src/hooks/useFontLoader.ts +40 -0
- package/src/hooks/useSyncNotifications/index.ts +1 -0
- package/src/hooks/useSyncNotifications/useSyncNotifications.ts +25 -0
- package/src/hooks/useTheme.ts +1 -1
- package/src/index.ts +2 -0
- package/src/pages/SelectBlockchainPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +34 -2
- package/src/store/notification.ts +62 -17
- package/src/types/config.ts +6 -1
- package/src/types/notification.ts +0 -1
- package/src/utils/common.ts +29 -0
- package/src/utils/configs.ts +0 -1
- package/src/utils/swap.ts +12 -0
- package/src/utils/wallets.ts +53 -2
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts +0 -3
- 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.
|
|
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.
|
|
28
|
-
"@rango-dev/provider-all": "^0.33.
|
|
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.
|
|
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/
|
|
33
|
-
"@rango-dev/
|
|
34
|
-
"@rango-dev/wallets-
|
|
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 {
|
|
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
|
-
|
|
8
|
+
blockchainCategory: string
|
|
30
9
|
) =>
|
|
31
10
|
list
|
|
32
|
-
.filter((blockchain) =>
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
148
|
+
$$background: '$colors$secondary100',
|
|
149
149
|
[`.${darkTheme} &`]: {
|
|
150
150
|
$$background: '$colors$info700',
|
|
151
151
|
},
|
|
@@ -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
|
-
<
|
|
66
|
+
<NotificationsBadge />
|
|
66
67
|
</HeaderButton>
|
|
67
68
|
</Tooltip>
|
|
68
69
|
</div>
|
package/src/components/HeaderButtons/{UnreadNotificationsBadge.tsx → NotificationsBadge.tsx}
RENAMED
|
@@ -6,10 +6,10 @@ import { useNotificationStore } from '../../store/notification';
|
|
|
6
6
|
|
|
7
7
|
import { NotificationsBadgeContainer } from './HeaderButtons.styles';
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
const {
|
|
9
|
+
export function NotificationsBadge() {
|
|
10
|
+
const { getNotifications } = useNotificationStore();
|
|
11
11
|
|
|
12
|
-
const notificationsList =
|
|
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 {
|
|
35
|
+
const { getNotifications, clearNotifications } = useNotificationStore();
|
|
33
36
|
|
|
34
|
-
const notifications: Notification[] =
|
|
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={
|
|
127
|
+
end={
|
|
128
|
+
<IconContainer>
|
|
129
|
+
<ChevronRightIcon size={12} color="gray" />
|
|
130
|
+
</IconContainer>
|
|
131
|
+
}
|
|
107
132
|
/>
|
|
108
133
|
</React.Fragment>
|
|
109
134
|
);
|
|
@@ -96,21 +96,20 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
96
96
|
setModalState(null);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
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 =
|
|
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
|
-
|
|
112
|
+
removeNotification(swap.requestId);
|
|
114
113
|
} else if (showCompletedModal) {
|
|
115
114
|
setShowCompletedModal(null);
|
|
116
115
|
}
|
package/src/constants/fonts.ts
CHANGED
|
@@ -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().
|
|
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
|
|
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
|
-
|
|
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}>
|
package/src/globalStyles.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
33
|
+
const activeCategoriesCount = getCategoriesCount(blockchains);
|
|
34
34
|
|
|
35
|
-
const showCategory =
|
|
35
|
+
const showCategory = activeCategoriesCount !== 1;
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<Layout
|