@rango-dev/widget-embedded 0.23.1-next.11 → 0.23.1-next.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.23.1-next.11",
3
+ "version": "0.23.1-next.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "@rango-dev/queue-manager-core": "^0.26.0",
26
26
  "@rango-dev/queue-manager-rango-preset": "^0.28.1-next.3",
27
27
  "@rango-dev/queue-manager-react": "^0.26.0",
28
- "@rango-dev/ui": "^0.29.1-next.8",
28
+ "@rango-dev/ui": "^0.29.1-next.9",
29
29
  "@rango-dev/wallets-react": "^0.14.1-next.1",
30
30
  "@rango-dev/wallets-shared": "^0.28.1-next.1",
31
31
  "bignumber.js": "^9.1.1",
@@ -48,4 +48,4 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  }
51
- }
51
+ }
@@ -5,6 +5,12 @@ export const HeaderButton = styled(IconButton, {
5
5
  position: 'relative',
6
6
  padding: '0',
7
7
  overflow: 'unset',
8
+ '&:hover': {
9
+ backgroundColor: '$info100',
10
+ [`.${darkTheme} &`]: {
11
+ backgroundColor: '$neutral',
12
+ },
13
+ },
8
14
  });
9
15
 
10
16
  export const ConnectedIcon = styled('div', {
@@ -31,7 +37,6 @@ export const SuffixContainer = styled('div', {
31
37
 
32
38
  export const NotificationsBadgeContainer = styled('div', {
33
39
  position: 'absolute',
34
- backgroundColor: '$secondary500',
35
40
  width: '14px',
36
41
  height: '14px',
37
42
  display: 'flex',
@@ -40,6 +45,16 @@ export const NotificationsBadgeContainer = styled('div', {
40
45
  borderRadius: '7px',
41
46
  top: '$0',
42
47
  right: '$0',
48
+ variants: {
49
+ isSever: {
50
+ true: {
51
+ backgroundColor: '$error500',
52
+ },
53
+ false: {
54
+ backgroundColor: '$secondary500',
55
+ },
56
+ },
57
+ },
43
58
  });
44
59
 
45
60
  export const ProgressIcon = styled('div', {
@@ -53,3 +68,11 @@ export const ProgressIcon = styled('div', {
53
68
  },
54
69
  },
55
70
  });
71
+
72
+ export const InProgressTransactionBadgeContainer = styled('div', {
73
+ position: 'absolute',
74
+ right: '$4',
75
+ top: '$4',
76
+ backgroundColor: '$background',
77
+ borderRadius: '100%',
78
+ });
@@ -16,6 +16,7 @@ import { isFeatureHidden } from '../../utils/settings';
16
16
  import { NotificationContent } from '../NotificationContent';
17
17
 
18
18
  import { HeaderButton } from './HeaderButtons.styles';
19
+ import InProgressTransactionBadge from './InProgressTransactionBadge';
19
20
  import { RefreshButton } from './RefreshButton';
20
21
  import { UnreadNotificationsBadge } from './UnreadNotificationsBadge';
21
22
 
@@ -83,6 +84,7 @@ export function HeaderButtons(props: HeaderButtonsPropTypes) {
83
84
  content={i18n.t('Transactions History')}>
84
85
  <HeaderButton size="small" variant="ghost" onClick={onClickHistory}>
85
86
  <TransactionIcon size={18} color="black" />
87
+ <InProgressTransactionBadge />
86
88
  </HeaderButton>
87
89
  </Tooltip>
88
90
  )}
@@ -0,0 +1,26 @@
1
+ import type { PendingSwap } from 'rango-types';
2
+
3
+ import { useManager } from '@rango-dev/queue-manager-react';
4
+ import { InProgressIcon } from '@rango-dev/ui';
5
+ import React from 'react';
6
+
7
+ import { getPendingSwaps } from '../../utils/queue';
8
+
9
+ import { InProgressTransactionBadgeContainer } from './HeaderButtons.styles';
10
+
11
+ const InProgressTransactionBadge = () => {
12
+ const { manager } = useManager();
13
+ const list: PendingSwap[] = getPendingSwaps(manager).map(({ swap }) => swap);
14
+
15
+ if (!list.find((swap) => swap.status === 'running')) {
16
+ return null;
17
+ }
18
+
19
+ return (
20
+ <InProgressTransactionBadgeContainer>
21
+ <InProgressIcon color="info" size={6} />
22
+ </InProgressTransactionBadgeContainer>
23
+ );
24
+ };
25
+
26
+ export default InProgressTransactionBadge;
@@ -1,3 +1,4 @@
1
+ import { EventSeverity } from '@rango-dev/queue-manager-rango-preset';
1
2
  import { Typography } from '@rango-dev/ui';
2
3
  import React from 'react';
3
4
 
@@ -8,10 +9,17 @@ import { NotificationsBadgeContainer } from './HeaderButtons.styles';
8
9
  export function UnreadNotificationsBadge() {
9
10
  const { getUnreadNotifications } = useNotificationStore();
10
11
 
11
- const notificationsCount = getUnreadNotifications().length;
12
+ const notificationsList = getUnreadNotifications();
13
+
14
+ const notificationsCount = notificationsList.length;
15
+
16
+ const hasSeverNotification = !!notificationsList.find(
17
+ (notificationItem) =>
18
+ notificationItem.event.messageSeverity === EventSeverity.WARNING
19
+ );
12
20
 
13
21
  return notificationsCount ? (
14
- <NotificationsBadgeContainer>
22
+ <NotificationsBadgeContainer isSever={hasSeverNotification}>
15
23
  <Typography variant="body" size="xsmall" color="$background">
16
24
  {notificationsCount}
17
25
  </Typography>
@@ -1,4 +1,4 @@
1
- import { styled } from '@rango-dev/ui';
1
+ import { darkTheme, ListItemButton, styled } from '@rango-dev/ui';
2
2
 
3
3
  export const Container = styled('div', {
4
4
  padding: '$10',
@@ -17,6 +17,19 @@ export const List = styled('ul', {
17
17
  },
18
18
  });
19
19
 
20
+ export const ListItem = styled(ListItemButton, {
21
+ variants: {
22
+ actionRequired: {
23
+ true: {
24
+ backgroundColor: '$error300',
25
+ [`.${darkTheme} &`]: {
26
+ backgroundColor: '$error600',
27
+ },
28
+ },
29
+ },
30
+ },
31
+ });
32
+
20
33
  export const Images = styled('div', {
21
34
  display: 'flex',
22
35
  padding: 0,
@@ -5,7 +5,7 @@ import { EventSeverity } from '@rango-dev/queue-manager-rango-preset';
5
5
  import {
6
6
  ChainToken,
7
7
  ChevronRightIcon,
8
- ListItemButton,
8
+ Divider,
9
9
  Typography,
10
10
  } from '@rango-dev/ui';
11
11
  import React from 'react';
@@ -16,7 +16,12 @@ import { useAppStore } from '../../store/AppStore';
16
16
  import { useNotificationStore } from '../../store/notification';
17
17
  import { areTokensEqual } from '../../utils/wallets';
18
18
 
19
- import { Container, Images, List } from './NotificationContent.styles';
19
+ import {
20
+ Container,
21
+ Images,
22
+ List,
23
+ ListItem,
24
+ } from './NotificationContent.styles';
20
25
  import { NotificationNotFound } from './NotificationNotFound';
21
26
 
22
27
  const MAX_NOTIFICATIONS_DISPLAYED = 4;
@@ -41,7 +46,7 @@ export function NotificationContent() {
41
46
  <Container>
42
47
  {sortedNotification.length ? (
43
48
  <List>
44
- {sortedNotification.map((notificationItem) => {
49
+ {sortedNotification.map((notificationItem, index) => {
45
50
  const { route, requestId, event } = notificationItem;
46
51
  const fromToken = tokens.find((tokenItem) =>
47
52
  areTokensEqual(tokenItem, route.from)
@@ -60,42 +65,47 @@ export function NotificationContent() {
60
65
  );
61
66
 
62
67
  return (
63
- <ListItemButton
64
- key={requestId}
65
- onClick={() => handleOnClick(requestId)}
66
- title={
67
- <Typography
68
- variant="body"
69
- size="small"
70
- color={
71
- event.messageSeverity === EventSeverity.WARNING
72
- ? '$foreground'
73
- : '$neutral700'
74
- }>
75
- {i18n.t(event.message)}
76
- </Typography>
77
- }
78
- id={requestId}
79
- start={
80
- <Images>
81
- <div className="from-chain-token">
82
- <ChainToken
83
- tokenImage={fromToken ? fromToken.image : ''}
84
- chainImage={fromBlockchain ? fromBlockchain.logo : ''}
85
- size="small"
86
- />
87
- </div>
88
- <div className="to-chain-token">
89
- <ChainToken
90
- tokenImage={toToken ? toToken.image : ''}
91
- chainImage={toBlockchain ? toBlockchain.logo : ''}
92
- size="small"
93
- />
94
- </div>
95
- </Images>
96
- }
97
- end={<ChevronRightIcon size={12} color="gray" />}
98
- />
68
+ <React.Fragment key={requestId}>
69
+ {index > 0 && <Divider size={4} />}
70
+ <ListItem
71
+ onClick={() => handleOnClick(requestId)}
72
+ actionRequired={
73
+ event.messageSeverity === EventSeverity.WARNING
74
+ }
75
+ title={
76
+ <Typography
77
+ variant="body"
78
+ size="small"
79
+ color={
80
+ event.messageSeverity === EventSeverity.WARNING
81
+ ? '$foreground'
82
+ : '$neutral700'
83
+ }>
84
+ {i18n.t(event.message)}
85
+ </Typography>
86
+ }
87
+ id={requestId}
88
+ start={
89
+ <Images>
90
+ <div className="from-chain-token">
91
+ <ChainToken
92
+ tokenImage={fromToken ? fromToken.image : ''}
93
+ chainImage={fromBlockchain ? fromBlockchain.logo : ''}
94
+ size="small"
95
+ />
96
+ </div>
97
+ <div className="to-chain-token">
98
+ <ChainToken
99
+ tokenImage={toToken ? toToken.image : ''}
100
+ chainImage={toBlockchain ? toBlockchain.logo : ''}
101
+ size="small"
102
+ />
103
+ </div>
104
+ </Images>
105
+ }
106
+ end={<ChevronRightIcon size={12} color="gray" />}
107
+ />
108
+ </React.Fragment>
99
109
  );
100
110
  })}
101
111
  </List>