@rango-dev/ui 0.1.10-next.92 → 0.1.11-next.10
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/README.md +1 -181
- package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
- package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Header/Header.d.ts +9 -0
- package/dist/components/Header/index.d.ts +1 -0
- package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Icon/types.d.ts +1 -0
- package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
- package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
- package/dist/components/Modal/Modal.d.ts +0 -1
- package/dist/components/SelectableWalletList/mock.d.ts +1 -1
- package/dist/components/Settings/Settings.d.ts +2 -1
- package/dist/components/StepDetail/StepDetail.d.ts +3 -1
- package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
- package/dist/components/SwapDetail/Token.d.ts +17 -0
- package/dist/components/TextField/TextField.d.ts +1 -1
- package/dist/components/TokenList/TokenList.d.ts +2 -2
- package/dist/components/TokenSelector/TokenSelector.d.ts +4 -3
- package/dist/components/Typography/Typography.d.ts +1 -1
- package/dist/components/common/Image.d.ts +6 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +14 -19
- package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
- package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
- package/dist/containers/History/History.d.ts +5 -7
- package/dist/containers/History/SwapsGroup.d.ts +13 -0
- package/dist/containers/History/index.d.ts +1 -0
- package/dist/containers/History/types.d.ts +3 -24
- package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
- package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
- package/dist/containers/index.d.ts +0 -1
- package/dist/helper/index.d.ts +3 -1
- package/dist/types/meta.d.ts +1 -0
- package/dist/ui.cjs.development.js +1137 -837
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +1134 -839
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/Alert/Alert.tsx +33 -12
- package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
- package/src/components/Alert/NotFoundAlert.tsx +19 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/BestRoute/BestRoute.tsx +2 -5
- package/src/components/BestRoute/mock.ts +10 -0
- package/src/components/BlockchainSelector/BlockchainSelector.tsx +31 -34
- package/src/components/BlockchainsList/BlockchainsList.tsx +8 -6
- package/src/components/Button/Button.tsx +2 -1
- package/src/components/ConnectWalletsModal/mockData.ts +16 -0
- package/src/components/Divider/Divider.tsx +41 -0
- package/src/components/Divider/index.ts +1 -0
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/Header/Header.tsx +39 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Icon/ArrowRightIcon.tsx +31 -0
- package/src/components/Icon/common.ts +10 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/Icon/types.tsx +1 -0
- package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +81 -27
- package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
- package/src/components/Modal/Modal.tsx +1 -6
- package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
- package/src/components/SelectableWalletList/SelectableWalletList.tsx +7 -1
- package/src/components/SelectableWalletList/mock.ts +4 -3
- package/src/components/Settings/Settings.tsx +34 -14
- package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
- package/src/components/StepDetail/StepDetail.tsx +46 -12
- package/src/components/SwapContainer/SwapContainer.tsx +21 -17
- package/src/components/SwapDetail/SwapDetail.tsx +71 -117
- package/src/components/SwapDetail/Token.tsx +73 -0
- package/src/components/SwapDetail/mock.ts +1 -0
- package/src/components/TextField/TextField.tsx +9 -0
- package/src/components/TokenList/TokenItem.tsx +12 -6
- package/src/components/TokenList/TokenList.tsx +18 -21
- package/src/components/TokenSelector/TokenSelector.tsx +38 -25
- package/src/components/Typography/Typography.tsx +8 -0
- package/src/components/Wallet/Wallet.tsx +9 -6
- package/src/components/common/Image.tsx +27 -0
- package/src/components/common/index.ts +1 -0
- package/src/components/index.ts +2 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
- package/src/containers/ConfirmSwap/ConfirmSwap.tsx +111 -125
- package/src/containers/ConfirmSwap/mock.ts +79 -2
- package/src/containers/History/History.tsx +33 -57
- package/src/containers/History/SwapsGroup.tsx +59 -0
- package/src/containers/History/index.ts +1 -0
- package/src/containers/History/mock.ts +1 -0
- package/src/containers/History/types.tsx +2 -30
- package/src/containers/SwapHistory/SwapHistory.tsx +306 -177
- package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
- package/src/containers/SwapHistory/mock.ts +1 -0
- package/src/containers/index.ts +0 -1
- package/src/helper/index.ts +31 -2
- package/src/types/meta.ts +2 -0
- package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
- package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
- package/dist/containers/ConfirmWallets/index.d.ts +0 -1
- package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
- package/dist/helper/swaps.d.ts +0 -5
- package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
- package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
- package/src/containers/ConfirmWallets/index.ts +0 -1
- package/src/containers/ConfirmWallets/mock.ts +0 -222
- package/src/helper/swaps.ts +0 -23
|
@@ -2,88 +2,39 @@ import React, { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { PendingSwap } from '../../containers/History/types';
|
|
3
3
|
import { styled } from '../../theme';
|
|
4
4
|
import { Button } from '../Button';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { ArrowRightIcon } from '../Icon';
|
|
6
|
+
import { Spacer } from '../Spacer';
|
|
7
|
+
import { Spinner } from '../Spinner';
|
|
8
|
+
import { Token } from './Token';
|
|
9
|
+
import { limitDecimalPlaces } from '../../helper';
|
|
7
10
|
|
|
8
11
|
const Container = styled('div', {
|
|
9
12
|
position: 'relative',
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const ButtonContainer = styled('div', {
|
|
13
|
-
paddingTop: '$8',
|
|
14
|
-
});
|
|
15
|
-
const SwapContainer = styled('div', {
|
|
16
13
|
display: 'flex',
|
|
17
14
|
justifyContent: 'space-between',
|
|
18
|
-
'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'&:hover': {
|
|
22
|
-
borderColor: '$primary',
|
|
23
|
-
},
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
padding: '$16 0',
|
|
17
|
+
borderBottom: '1px solid $neutrals300',
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
borderColor: '$error',
|
|
29
|
-
},
|
|
30
|
-
running: {
|
|
31
|
-
borderColor: '$neutrals400',
|
|
32
|
-
},
|
|
33
|
-
success: {
|
|
34
|
-
borderColor: '$success',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
19
|
+
'& > .info': {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
37
22
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
const Line = styled('div', {
|
|
45
|
-
height: '0',
|
|
46
|
-
width: '$20',
|
|
47
|
-
border: '1px dashed $foreground',
|
|
48
|
-
borderRadius: 'inherit',
|
|
49
|
-
'@md': {
|
|
50
|
-
width: '$36',
|
|
23
|
+
|
|
24
|
+
'.status': {
|
|
25
|
+
textTransform: 'uppercase',
|
|
26
|
+
fontWeight: 'bold',
|
|
27
|
+
fontSize: '$12',
|
|
51
28
|
},
|
|
52
|
-
|
|
53
|
-
|
|
29
|
+
|
|
30
|
+
'&.failed .status': {
|
|
31
|
+
color: '$error',
|
|
54
32
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
width: '$6',
|
|
58
|
-
height: '$6',
|
|
59
|
-
backgroundColor: '$foreground',
|
|
60
|
-
borderRadius: '50%',
|
|
61
|
-
'@lg': {
|
|
62
|
-
width: '$8',
|
|
63
|
-
height: '$8',
|
|
33
|
+
'&.success .status': {
|
|
34
|
+
color: '$success',
|
|
64
35
|
},
|
|
65
36
|
});
|
|
66
|
-
const ArrowRight = styled('div', {
|
|
67
|
-
width: '0px',
|
|
68
|
-
height: '0px',
|
|
69
|
-
borderTop: '5px solid transparent',
|
|
70
|
-
borderBottom: '5px solid transparent',
|
|
71
|
-
borderLeft: '5px solid $foreground',
|
|
72
|
-
});
|
|
73
|
-
const StatusContainer = styled('div', {
|
|
74
|
-
position: 'absolute',
|
|
75
|
-
right: '-8px',
|
|
76
|
-
top: '30%',
|
|
77
|
-
background: '$background',
|
|
78
|
-
borderRadius: '50%',
|
|
79
|
-
display: 'flex',
|
|
80
|
-
justifyContent: 'center',
|
|
81
37
|
|
|
82
|
-
'@md': {
|
|
83
|
-
top: '40%',
|
|
84
|
-
right: '-8px',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
38
|
export interface PropTypes {
|
|
88
39
|
swap: PendingSwap;
|
|
89
40
|
status: 'running' | 'failed' | 'success';
|
|
@@ -99,52 +50,55 @@ export function SwapDetail({
|
|
|
99
50
|
const lastStep = swap.steps[swap.steps.length - 1];
|
|
100
51
|
|
|
101
52
|
return (
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
53
|
+
<Button
|
|
54
|
+
variant="ghost"
|
|
55
|
+
size="free"
|
|
56
|
+
fullWidth
|
|
57
|
+
onClick={onClick.bind(null, swap.requestId)}
|
|
58
|
+
>
|
|
59
|
+
<Container className={`${status}`}>
|
|
60
|
+
<div className="info">
|
|
61
|
+
<Token
|
|
62
|
+
data={{
|
|
63
|
+
token: {
|
|
64
|
+
logo: firstStep.fromLogo,
|
|
65
|
+
symbol: firstStep.fromSymbol,
|
|
66
|
+
},
|
|
67
|
+
blockchain: {
|
|
68
|
+
logo: firstStep.fromBlockchainLogo || '',
|
|
69
|
+
name: firstStep.fromBlockchain,
|
|
70
|
+
},
|
|
71
|
+
amount: limitDecimalPlaces(swap.inputAmount),
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
<Spacer size={12} />
|
|
75
|
+
<ArrowRightIcon size={12} />
|
|
76
|
+
<Spacer size={12} />
|
|
77
|
+
<Token
|
|
78
|
+
data={{
|
|
79
|
+
token: {
|
|
80
|
+
logo: lastStep.toLogo,
|
|
81
|
+
symbol: lastStep.toSymbol,
|
|
82
|
+
},
|
|
83
|
+
blockchain: {
|
|
84
|
+
logo: lastStep.toBlockchainLogo || '',
|
|
85
|
+
name: lastStep.toBlockchain,
|
|
86
|
+
},
|
|
87
|
+
amount: limitDecimalPlaces(lastStep.outputAmount || ''),
|
|
88
|
+
estimatedAmount: limitDecimalPlaces(
|
|
89
|
+
lastStep.expectedOutputAmountHumanReadable || ''
|
|
90
|
+
),
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
<div className={`status`}>
|
|
95
|
+
{status === 'running' ? (
|
|
96
|
+
<Spinner size={24} color="primary" />
|
|
97
|
+
) : (
|
|
98
|
+
status
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
</Container>
|
|
102
|
+
</Button>
|
|
149
103
|
);
|
|
150
104
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled } from '../../theme';
|
|
3
|
+
import { Spacer } from '../Spacer';
|
|
4
|
+
import { Image } from '../common';
|
|
5
|
+
|
|
6
|
+
const TokenContainer = styled('div', {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
width: '160px',
|
|
10
|
+
|
|
11
|
+
'& .amount': {
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
},
|
|
14
|
+
'& .estimated': {
|
|
15
|
+
color: '$neutrals600',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const TokenImage = styled('div', {
|
|
20
|
+
position: 'relative',
|
|
21
|
+
|
|
22
|
+
'.overlay': {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
right: -4,
|
|
25
|
+
bottom: -4,
|
|
26
|
+
width: '$16',
|
|
27
|
+
height: '$16',
|
|
28
|
+
padding: '$2',
|
|
29
|
+
borderRadius: '50%',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
backgroundColor: '$background',
|
|
34
|
+
border: '1px solid $neutrals400',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
interface PropTypes {
|
|
39
|
+
data: {
|
|
40
|
+
token: {
|
|
41
|
+
logo: string;
|
|
42
|
+
symbol: string;
|
|
43
|
+
};
|
|
44
|
+
blockchain: {
|
|
45
|
+
logo: string;
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
amount: string;
|
|
49
|
+
estimatedAmount?: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function Token(props: PropTypes) {
|
|
53
|
+
const {
|
|
54
|
+
data: { token, blockchain, amount, estimatedAmount },
|
|
55
|
+
} = props;
|
|
56
|
+
return (
|
|
57
|
+
<TokenContainer>
|
|
58
|
+
<TokenImage>
|
|
59
|
+
<Image src={token.logo} alt="" size={24} />
|
|
60
|
+
<div className="overlay">
|
|
61
|
+
<Image src={blockchain.logo} alt={blockchain.name} size={12} />
|
|
62
|
+
</div>
|
|
63
|
+
</TokenImage>
|
|
64
|
+
<Spacer size={8} />
|
|
65
|
+
{!!amount && <span className="amount">{props.data.amount}</span>}
|
|
66
|
+
{!amount && estimatedAmount && (
|
|
67
|
+
<span className="amount estimated">{props.data.estimatedAmount}</span>
|
|
68
|
+
)}
|
|
69
|
+
<Spacer size={4} />
|
|
70
|
+
{token.symbol}
|
|
71
|
+
</TokenContainer>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -4,6 +4,7 @@ import { styled } from '../../theme';
|
|
|
4
4
|
|
|
5
5
|
const InputContainer = styled('div', {
|
|
6
6
|
backgroundColor: '$background',
|
|
7
|
+
padding: '1px',
|
|
7
8
|
boxSizing: 'border-box',
|
|
8
9
|
border: '1px solid $neutrals400',
|
|
9
10
|
borderRadius: '$5',
|
|
@@ -13,6 +14,7 @@ const InputContainer = styled('div', {
|
|
|
13
14
|
position: 'relative',
|
|
14
15
|
alignItems: 'center',
|
|
15
16
|
color: '$foreground',
|
|
17
|
+
overflowX: 'hidden',
|
|
16
18
|
transition: 'border-color ease .3s',
|
|
17
19
|
'&:focus-within': {
|
|
18
20
|
borderColor: '$success',
|
|
@@ -75,6 +77,13 @@ const Input = styled('input', {
|
|
|
75
77
|
'&:disabled': {
|
|
76
78
|
cursor: 'not-allowed',
|
|
77
79
|
},
|
|
80
|
+
'&::-webkit-outer-spin-button, &::-webkit-inner-spin-button': {
|
|
81
|
+
'-webkit-appearance': 'none',
|
|
82
|
+
margin: 0,
|
|
83
|
+
},
|
|
84
|
+
'&[type="number"]': {
|
|
85
|
+
'-moz-appearance': 'textfield',
|
|
86
|
+
},
|
|
78
87
|
});
|
|
79
88
|
const Label = styled('label', {
|
|
80
89
|
display: 'inline-block',
|
|
@@ -4,11 +4,10 @@ import { styled } from '../../theme';
|
|
|
4
4
|
import { Button } from '../Button';
|
|
5
5
|
import { Typography } from '../Typography';
|
|
6
6
|
import { TokenWithAmount } from './TokenList';
|
|
7
|
+
import { Image } from '../common';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
maxHeight: '$32',
|
|
11
|
-
marginRight: '$16',
|
|
9
|
+
const TokenImageContainer = styled('div', {
|
|
10
|
+
paddingRight: '$16',
|
|
12
11
|
});
|
|
13
12
|
|
|
14
13
|
const TokenNameContainer = styled('div', {
|
|
@@ -40,6 +39,7 @@ export function TokenItem(props: PropTypes) {
|
|
|
40
39
|
...style,
|
|
41
40
|
height: '48px',
|
|
42
41
|
top: `${parseFloat(style?.top as string) + 0}px`,
|
|
42
|
+
padding: '0 4px',
|
|
43
43
|
}}
|
|
44
44
|
>
|
|
45
45
|
<Button
|
|
@@ -48,7 +48,11 @@ export function TokenItem(props: PropTypes) {
|
|
|
48
48
|
align="start"
|
|
49
49
|
onClick={onClick.bind(null, token)}
|
|
50
50
|
type={selected ? 'primary' : undefined}
|
|
51
|
-
prefix={
|
|
51
|
+
prefix={
|
|
52
|
+
<TokenImageContainer>
|
|
53
|
+
<Image src={token.image} size={32} />
|
|
54
|
+
</TokenImageContainer>
|
|
55
|
+
}
|
|
52
56
|
suffix={
|
|
53
57
|
token.balance?.amount && (
|
|
54
58
|
<TokenAmountContainer>
|
|
@@ -62,7 +66,9 @@ export function TokenItem(props: PropTypes) {
|
|
|
62
66
|
>
|
|
63
67
|
<TokenNameContainer>
|
|
64
68
|
<Typography variant="body1">{token.symbol}</Typography>
|
|
65
|
-
<Typography variant="
|
|
69
|
+
<Typography variant="caption" color="neutrals600">
|
|
70
|
+
{token.name}
|
|
71
|
+
</Typography>
|
|
66
72
|
</TokenNameContainer>
|
|
67
73
|
</Button>
|
|
68
74
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
2
2
|
import { CommonProps } from 'react-window';
|
|
3
|
-
import { Token } from 'rango-sdk';
|
|
3
|
+
import { Asset, Token } from 'rango-sdk';
|
|
4
4
|
import { VirtualizedList } from '../VirtualizedList/VirtualizedList';
|
|
5
5
|
import { TokenItem } from './TokenItem';
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ export interface PropTypes {
|
|
|
18
18
|
searchedText: string;
|
|
19
19
|
onChange: (token: TokenWithAmount) => void;
|
|
20
20
|
multiSelect?: boolean;
|
|
21
|
-
selectedList?:
|
|
21
|
+
selectedList?: Asset[];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function TokenList(props: PropTypes) {
|
|
@@ -33,7 +33,6 @@ export function TokenList(props: PropTypes) {
|
|
|
33
33
|
const isSelected = (token: Token) => {
|
|
34
34
|
if (multiSelect && selectedList) {
|
|
35
35
|
return (
|
|
36
|
-
selectedList === 'all' ||
|
|
37
36
|
selectedList
|
|
38
37
|
.map((item) => item.symbol + item.address)
|
|
39
38
|
.indexOf(token.symbol + token.address) > -1
|
|
@@ -53,7 +52,7 @@ export function TokenList(props: PropTypes) {
|
|
|
53
52
|
|
|
54
53
|
useEffect(() => {
|
|
55
54
|
setTokens(list.slice(0, PAGE_SIZE));
|
|
56
|
-
}, [searchedText]);
|
|
55
|
+
}, [searchedText, list]);
|
|
57
56
|
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
setHasNextPage(list.length > tokens.length);
|
|
@@ -76,22 +75,20 @@ export function TokenList(props: PropTypes) {
|
|
|
76
75
|
);
|
|
77
76
|
|
|
78
77
|
return (
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/>
|
|
95
|
-
</div>
|
|
78
|
+
<VirtualizedList
|
|
79
|
+
Item={({ index, style }) => (
|
|
80
|
+
<TokenItem
|
|
81
|
+
token={tokens[index]}
|
|
82
|
+
style={style}
|
|
83
|
+
onClick={changeSelected}
|
|
84
|
+
selected={isSelected(tokens[index])}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
hasNextPage={hasNextPage}
|
|
88
|
+
itemCount={tokens.length}
|
|
89
|
+
loadNextPage={loadNextPage}
|
|
90
|
+
innerElementType={innerElementType}
|
|
91
|
+
size={56}
|
|
92
|
+
/>
|
|
96
93
|
);
|
|
97
94
|
}
|
|
@@ -3,16 +3,27 @@ import { containsText } from '../../helper';
|
|
|
3
3
|
import { SecondaryPage } from '../SecondaryPage/SecondaryPage';
|
|
4
4
|
import { TokenList } from '../TokenList';
|
|
5
5
|
import { TokenWithAmount } from '../TokenList/TokenList';
|
|
6
|
+
import { LoadingStatus } from '../../types/meta';
|
|
7
|
+
import { Spinner } from '../Spinner';
|
|
8
|
+
import { LoadingFailedAlert } from '../Alert/LoadingFailedAlert';
|
|
9
|
+
import { NotFoundAlert } from '../Alert/NotFoundAlert';
|
|
10
|
+
import { styled } from '../../theme';
|
|
6
11
|
|
|
12
|
+
export const LoaderContainer = styled('div', {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
width: '100%',
|
|
16
|
+
paddingTop: '33%',
|
|
17
|
+
flex: 1,
|
|
18
|
+
});
|
|
7
19
|
export interface PropTypes {
|
|
8
20
|
list: TokenWithAmount[];
|
|
9
21
|
type?: 'Source' | 'Destination';
|
|
10
22
|
selected: TokenWithAmount | null;
|
|
11
23
|
onChange: (token: TokenWithAmount) => void;
|
|
12
|
-
hasHeader?: boolean;
|
|
13
|
-
multiSelect?: boolean;
|
|
14
24
|
onBack?: () => void;
|
|
15
|
-
|
|
25
|
+
loadingStatus: LoadingStatus;
|
|
26
|
+
hasHeader?: boolean;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
const filterTokens = (list: TokenWithAmount[], searchedFor: string) =>
|
|
@@ -24,35 +35,37 @@ const filterTokens = (list: TokenWithAmount[], searchedFor: string) =>
|
|
|
24
35
|
);
|
|
25
36
|
|
|
26
37
|
export function TokenSelector(props: PropTypes) {
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
type,
|
|
30
|
-
selected,
|
|
31
|
-
onChange,
|
|
32
|
-
hasHeader,
|
|
33
|
-
multiSelect,
|
|
34
|
-
selectedList,
|
|
35
|
-
onBack,
|
|
36
|
-
} = props;
|
|
38
|
+
const { list, type, selected, hasHeader, onChange, onBack, loadingStatus } =
|
|
39
|
+
props;
|
|
37
40
|
|
|
38
41
|
return (
|
|
39
42
|
<SecondaryPage
|
|
40
43
|
textField={true}
|
|
41
|
-
textFieldPlaceholder="Search Blockchain By Name"
|
|
42
|
-
title={`Select ${type} Token`}
|
|
43
44
|
hasHeader={hasHeader}
|
|
45
|
+
title={`Select ${type} Token`}
|
|
44
46
|
onBack={onBack}
|
|
47
|
+
textFieldPlaceholder="Search Token By Name"
|
|
45
48
|
>
|
|
46
|
-
{(searchedFor) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
{(searchedFor) => {
|
|
50
|
+
const filteredTokens = filterTokens(list, searchedFor);
|
|
51
|
+
|
|
52
|
+
return loadingStatus === 'loading' ? (
|
|
53
|
+
<LoaderContainer>
|
|
54
|
+
<Spinner size={24} />
|
|
55
|
+
</LoaderContainer>
|
|
56
|
+
) : loadingStatus === 'failed' ? (
|
|
57
|
+
<LoadingFailedAlert />
|
|
58
|
+
) : filteredTokens.length ? (
|
|
59
|
+
<TokenList
|
|
60
|
+
searchedText={searchedFor}
|
|
61
|
+
list={filteredTokens}
|
|
62
|
+
selected={selected}
|
|
63
|
+
onChange={onChange}
|
|
64
|
+
/>
|
|
65
|
+
) : (
|
|
66
|
+
<NotFoundAlert catergory="Token" searchedFor={searchedFor} />
|
|
67
|
+
);
|
|
68
|
+
}}
|
|
56
69
|
</SecondaryPage>
|
|
57
70
|
);
|
|
58
71
|
}
|
|
@@ -61,6 +61,13 @@ const TypographyContainer = styled('span', {
|
|
|
61
61
|
fontSize: '$18',
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
+
title: {
|
|
65
|
+
fontSize: '$14',
|
|
66
|
+
fontWeight: '$500',
|
|
67
|
+
'@md': {
|
|
68
|
+
fontSize: '$15',
|
|
69
|
+
}
|
|
70
|
+
},
|
|
64
71
|
body1: {
|
|
65
72
|
fontSize: '$14',
|
|
66
73
|
fontWeight: '$400',
|
|
@@ -173,6 +180,7 @@ export interface PropTypes {
|
|
|
173
180
|
| 'h4'
|
|
174
181
|
| 'h5'
|
|
175
182
|
| 'h6'
|
|
183
|
+
| 'title'
|
|
176
184
|
| 'body1'
|
|
177
185
|
| 'body2'
|
|
178
186
|
| 'body3'
|
|
@@ -6,11 +6,10 @@ import { WalletInfo, WalletState } from '../../types/wallet';
|
|
|
6
6
|
import { Button } from '../Button/Button';
|
|
7
7
|
import { Typography } from '../Typography';
|
|
8
8
|
import { State } from './State';
|
|
9
|
+
import { Image } from '../common';
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
height: '$24',
|
|
13
|
-
marginRight: '$12',
|
|
11
|
+
const WalletImageContainer = styled('div', {
|
|
12
|
+
paddingRight: '$12',
|
|
14
13
|
});
|
|
15
14
|
const Text = styled('div', {
|
|
16
15
|
display: 'flex',
|
|
@@ -42,7 +41,7 @@ export function Wallet(props: PropTypes) {
|
|
|
42
41
|
return (
|
|
43
42
|
<ExtendedButton
|
|
44
43
|
type={state === WalletState.CONNECTED ? 'primary' : undefined}
|
|
45
|
-
disabled={
|
|
44
|
+
disabled={state == WalletState.CONNECTING}
|
|
46
45
|
onClick={() => {
|
|
47
46
|
if (state === WalletState.NOT_INSTALLED) {
|
|
48
47
|
window.open(detectInstallLink(installLink), '_blank');
|
|
@@ -51,7 +50,11 @@ export function Wallet(props: PropTypes) {
|
|
|
51
50
|
align="start"
|
|
52
51
|
variant="outlined"
|
|
53
52
|
size="large"
|
|
54
|
-
prefix={
|
|
53
|
+
prefix={
|
|
54
|
+
<WalletImageContainer>
|
|
55
|
+
<Image src={image} size={24} />
|
|
56
|
+
</WalletImageContainer>
|
|
57
|
+
}
|
|
55
58
|
suffix={<State walletState={state} installLink={installLink} />}
|
|
56
59
|
>
|
|
57
60
|
<Text>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { styled } from '../../theme';
|
|
3
|
+
|
|
4
|
+
const ImageContainer = styled('div', {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
justifyContent: 'center',
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
'.image': {
|
|
9
|
+
width: '100%',
|
|
10
|
+
height: '100%',
|
|
11
|
+
objectFit: 'contain',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
type PropTypes = {
|
|
16
|
+
size: number;
|
|
17
|
+
} & React.ImgHTMLAttributes<HTMLImageElement>;
|
|
18
|
+
|
|
19
|
+
export function Image(props: PropTypes) {
|
|
20
|
+
const { size, ...otherProps } = props;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ImageContainer css={{ width: size + 'px', height: size + 'px' }}>
|
|
24
|
+
<img className="image" {...otherProps} />
|
|
25
|
+
</ImageContainer>
|
|
26
|
+
);
|
|
27
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentMeta } from '@storybook/react';
|
|
3
3
|
import { ConfirmSwap, PropTypes } from './ConfirmSwap';
|
|
4
|
-
import {
|
|
4
|
+
import { exampleFor5Wallets, wallets } from './mock';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Containers/ConfirmSwap',
|
|
8
8
|
component: ConfirmSwap,
|
|
9
|
+
argTypes: {
|
|
10
|
+
requiredWallets: {
|
|
11
|
+
defaultValue: ['BSC', 'OSMOSIS'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
9
14
|
} as ComponentMeta<typeof ConfirmSwap>;
|
|
10
15
|
|
|
11
16
|
export const Main = (props: PropTypes) => (
|
|
12
|
-
<ConfirmSwap {...props}
|
|
17
|
+
<ConfirmSwap {...props} selectableWallets={wallets} />
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const With5Wallets = (props: PropTypes) => (
|
|
21
|
+
<ConfirmSwap {...props} selectableWallets={exampleFor5Wallets} />
|
|
13
22
|
);
|