@rango-dev/ui 0.13.1-next.0 → 0.14.0

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 (61) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.js +6 -6
  3. package/dist/index.js.map +4 -4
  4. package/dist/widget/ui/src/components/index.d.ts +0 -5
  5. package/dist/widget/ui/src/components/index.d.ts.map +1 -1
  6. package/dist/widget/ui/src/containers/ConfirmSwap/ConfirmSwap.stories.d.ts.map +1 -1
  7. package/dist/widget/ui/src/containers/index.d.ts +0 -2
  8. package/dist/widget/ui/src/containers/index.d.ts.map +1 -1
  9. package/dist/widget/ui/src/types/meta.d.ts +0 -7
  10. package/dist/widget/ui/src/types/meta.d.ts.map +1 -1
  11. package/dist/widget/ui/src/types/wallet.d.ts +0 -23
  12. package/dist/widget/ui/src/types/wallet.d.ts.map +1 -1
  13. package/package.json +2 -2
  14. package/src/components/index.ts +0 -5
  15. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +174 -5
  16. package/src/containers/index.ts +0 -2
  17. package/src/helper/index.ts +1 -1
  18. package/src/types/meta.ts +0 -9
  19. package/src/types/wallet.ts +0 -25
  20. package/dist/widget/ui/src/components/HeaderLayout/HeaderLayout.d.ts +0 -14
  21. package/dist/widget/ui/src/components/HeaderLayout/HeaderLayout.d.ts.map +0 -1
  22. package/dist/widget/ui/src/components/HeaderLayout/index.d.ts +0 -2
  23. package/dist/widget/ui/src/components/HeaderLayout/index.d.ts.map +0 -1
  24. package/dist/widget/ui/src/components/PercentageChange/PercentageChange.d.ts +0 -8
  25. package/dist/widget/ui/src/components/PercentageChange/PercentageChange.d.ts.map +0 -1
  26. package/dist/widget/ui/src/components/PercentageChange/index.d.ts +0 -2
  27. package/dist/widget/ui/src/components/PercentageChange/index.d.ts.map +0 -1
  28. package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts +0 -120
  29. package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts.map +0 -1
  30. package/dist/widget/ui/src/components/RoutesOverview/index.d.ts +0 -2
  31. package/dist/widget/ui/src/components/RoutesOverview/index.d.ts.map +0 -1
  32. package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts +0 -120
  33. package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts.map +0 -1
  34. package/dist/widget/ui/src/components/SwapDetailsPlaceholder/index.d.ts +0 -2
  35. package/dist/widget/ui/src/components/SwapDetailsPlaceholder/index.d.ts.map +0 -1
  36. package/dist/widget/ui/src/components/TokenPreview/TokenPreview.d.ts +0 -20
  37. package/dist/widget/ui/src/components/TokenPreview/TokenPreview.d.ts.map +0 -1
  38. package/dist/widget/ui/src/components/TokenPreview/index.d.ts +0 -2
  39. package/dist/widget/ui/src/components/TokenPreview/index.d.ts.map +0 -1
  40. package/dist/widget/ui/src/containers/HomePanel/HomePanel.d.ts +0 -47
  41. package/dist/widget/ui/src/containers/HomePanel/HomePanel.d.ts.map +0 -1
  42. package/dist/widget/ui/src/containers/HomePanel/index.d.ts +0 -2
  43. package/dist/widget/ui/src/containers/HomePanel/index.d.ts.map +0 -1
  44. package/dist/widget/ui/src/containers/TokenInfo/TokenInfo.d.ts +0 -34
  45. package/dist/widget/ui/src/containers/TokenInfo/TokenInfo.d.ts.map +0 -1
  46. package/dist/widget/ui/src/containers/TokenInfo/index.d.ts +0 -2
  47. package/dist/widget/ui/src/containers/TokenInfo/index.d.ts.map +0 -1
  48. package/src/components/HeaderLayout/HeaderLayout.tsx +0 -88
  49. package/src/components/HeaderLayout/index.ts +0 -1
  50. package/src/components/PercentageChange/PercentageChange.tsx +0 -21
  51. package/src/components/PercentageChange/index.ts +0 -1
  52. package/src/components/RoutesOverview/RoutesOverview.tsx +0 -56
  53. package/src/components/RoutesOverview/index.ts +0 -1
  54. package/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.tsx +0 -47
  55. package/src/components/SwapDetailsPlaceholder/index.ts +0 -1
  56. package/src/components/TokenPreview/TokenPreview.tsx +0 -183
  57. package/src/components/TokenPreview/index.ts +0 -1
  58. package/src/containers/HomePanel/HomePanel.tsx +0 -228
  59. package/src/containers/HomePanel/index.ts +0 -1
  60. package/src/containers/TokenInfo/TokenInfo.tsx +0 -308
  61. package/src/containers/TokenInfo/index.ts +0 -1
@@ -1,308 +0,0 @@
1
- import React from 'react';
2
- import {
3
- AngleDownIcon,
4
- Button,
5
- InfoCircleIcon,
6
- styled,
7
- TextField,
8
- Typography,
9
- Image,
10
- Divider,
11
- PercentageChange,
12
- ConnectedWallet,
13
- } from '../..';
14
- import { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
15
- import { Trans } from '@lingui/react';
16
- import { i18n } from '@lingui/core';
17
- import { TokenWithBalance } from '../../types/meta';
18
-
19
- type PropTypes = (
20
- | {
21
- type: 'From';
22
- onAmountChange: (amount: string) => void;
23
- }
24
- | {
25
- type: 'To';
26
- outputAmount: string;
27
- outputUsdValue: string;
28
- percentageChange: string;
29
- showPercentageChange: boolean;
30
- }
31
- ) & {
32
- chain: BlockchainMeta | null;
33
- token: Token | null;
34
- loadingStatus: 'loading' | 'success' | 'failed';
35
- fromChain: BlockchainMeta | null;
36
- toChain: BlockchainMeta | null;
37
- inputUsdValue: string;
38
- fromToken: TokenWithBalance | null;
39
- setInputAmount: (amount: string) => void;
40
- connectedWallets: ConnectedWallet[];
41
- inputAmount: string;
42
- bestRoute: BestRouteResponse | null;
43
- fetchingBestRoute: boolean;
44
- onChainClick: () => void;
45
- onTokenClick: () => void;
46
- tokenBalanceReal: string;
47
- tokenBalance: string;
48
- };
49
-
50
- const Box = styled('div', {
51
- display: 'flex',
52
- flexDirection: 'column',
53
- width: '100%',
54
- overflow: 'hidden',
55
- });
56
-
57
- const Container = styled('div', {
58
- boxSizing: 'border-box',
59
- borderRadius: '$5',
60
- padding: '$8 $16 $16 $16',
61
-
62
- variants: {
63
- type: {
64
- filled: {
65
- backgroundColor: '$neutral100',
66
- },
67
- outlined: {
68
- border: '1px solid $neutral100',
69
- backgroundColor: '$surface',
70
- },
71
- },
72
- },
73
-
74
- defaultVariants: {
75
- type: 'filled',
76
- },
77
-
78
- '.head': {
79
- display: 'flex',
80
- justifyContent: 'space-between',
81
- alignItems: 'center',
82
- minHeight: '32px',
83
- },
84
- '.form': {
85
- display: 'flex',
86
- width: '100%',
87
- padding: '$2 0',
88
- '.selectors': {
89
- width: '35%',
90
-
91
- '._text': {
92
- whiteSpace: 'nowrap',
93
- overflow: 'hidden',
94
- textOverflow: 'ellipsis',
95
- },
96
- },
97
- '.amount': {
98
- width: '30%',
99
- },
100
- },
101
- '.output-usd': {
102
- display: 'flex',
103
- div: {
104
- display: 'flex',
105
- paddingLeft: '$8',
106
- },
107
- },
108
- });
109
-
110
- const Options = styled('div', {
111
- display: 'flex',
112
- justifyContent: 'flex-end',
113
-
114
- '.balance': {
115
- display: 'flex',
116
- alignItems: 'center',
117
- },
118
- });
119
-
120
- const ImagePlaceholder = styled('span', {
121
- width: '24px',
122
- height: '24px',
123
- backgroundColor: '$neutral100',
124
- borderRadius: '99999px',
125
- });
126
-
127
- const OutputContainer = styled('div', {
128
- windth: '100%',
129
- height: '$48',
130
- borderRadius: '$5',
131
- backgroundColor: '$surface',
132
- border: '1px solid transparent',
133
- position: 'relative',
134
- display: 'flex',
135
- alignItems: 'center',
136
- paddingLeft: '$8',
137
- paddingRight: '$8',
138
- });
139
-
140
- export function TokenInfo(props: PropTypes) {
141
- const {
142
- type,
143
- chain,
144
- token,
145
- loadingStatus,
146
- fromChain,
147
- toChain,
148
- fromToken,
149
- setInputAmount,
150
- inputUsdValue,
151
- inputAmount,
152
- bestRoute,
153
- fetchingBestRoute,
154
- onChainClick,
155
- onTokenClick,
156
- tokenBalanceReal,
157
- tokenBalance,
158
- } = props;
159
-
160
- const ItemSuffix = (
161
- <div
162
- style={{
163
- display: 'flex',
164
- justifyContent: 'center',
165
- alignItems: 'center',
166
- }}>
167
- {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
168
- <AngleDownIcon />
169
- </div>
170
- );
171
-
172
- return (
173
- <Box>
174
- <Container type={type === 'From' ? 'filled' : 'outlined'}>
175
- <div className="head">
176
- <Typography variant="body2" color="neutral800">
177
- {type === 'From' ? (
178
- <Trans id="swap from" message="From" />
179
- ) : (
180
- <Trans id="swap to" message="To" />
181
- )}
182
- </Typography>
183
- {type === 'From' ? (
184
- <Options>
185
- <div
186
- className="balance"
187
- onClick={() => {
188
- if (tokenBalance !== '0')
189
- setInputAmount(tokenBalanceReal.split(',').join(''));
190
- }}>
191
- <Typography variant="body3" color="neutral600">
192
- {i18n.t('Balance')}: {tokenBalance} {fromToken?.symbol || ''}
193
- </Typography>
194
- <Divider size={4} />
195
- <Button type="primary" variant="ghost" size="compact">
196
- <Trans id="maximum amount of asset" message="Max" />
197
- </Button>
198
- </div>
199
- </Options>
200
- ) : (
201
- <div className="output-usd">
202
- <PercentageChange
203
- percentageChange={props.percentageChange}
204
- showPercentageChange={props.showPercentageChange}
205
- />
206
- <div>
207
- <Typography
208
- variant="caption"
209
- color="neutral600">{`$${props.outputUsdValue}`}</Typography>
210
- </div>
211
- </div>
212
- )}
213
- </div>
214
- <div className="form">
215
- <Button
216
- className="selectors"
217
- onClick={onChainClick}
218
- variant="outlined"
219
- disabled={loadingStatus === 'failed'}
220
- loading={loadingStatus === 'loading'}
221
- prefix={
222
- loadingStatus === 'success' && chain ? (
223
- <Image src={chain.logo} size={24} />
224
- ) : (
225
- <ImagePlaceholder />
226
- )
227
- }
228
- suffix={ItemSuffix}
229
- align="start"
230
- size="large">
231
- {loadingStatus === 'success' && chain
232
- ? chain.displayName
233
- : i18n.t('Chain')}
234
- </Button>
235
- <Divider size={12} direction="horizontal" />
236
- <Button
237
- className="selectors"
238
- onClick={onTokenClick}
239
- variant="outlined"
240
- disabled={
241
- loadingStatus === 'failed' ||
242
- (type === 'From' && !fromChain) ||
243
- (type === 'To' && !toChain)
244
- }
245
- loading={loadingStatus === 'loading'}
246
- prefix={
247
- loadingStatus === 'success' && token ? (
248
- <Image src={token.image} size={24} />
249
- ) : (
250
- <ImagePlaceholder />
251
- )
252
- }
253
- suffix={ItemSuffix}
254
- size="large"
255
- align="start">
256
- {loadingStatus === 'success' && token
257
- ? token.symbol
258
- : i18n.t('Token')}
259
- </Button>
260
- <Divider size={12} direction="horizontal" />
261
- <div className="amount">
262
- {type === 'From' ? (
263
- <TextField
264
- type="number"
265
- size="large"
266
- autoFocus
267
- placeholder="0"
268
- style={{
269
- position: 'relative',
270
- backgroundColor: '$background !important',
271
- }}
272
- suffix={
273
- <span
274
- style={{
275
- position: 'absolute',
276
- right: '4px',
277
- bottom: '2px',
278
- }}>
279
- <Typography
280
- variant="caption"
281
- color="neutral800">{`$${inputUsdValue}`}</Typography>
282
- </span>
283
- }
284
- value={inputAmount || ''}
285
- min={0}
286
- onChange={
287
- type === 'From'
288
- ? (event) => {
289
- props.onAmountChange(event.target.value);
290
- }
291
- : undefined
292
- }
293
- />
294
- ) : (
295
- <OutputContainer>
296
- <Typography variant="h4">
297
- {fetchingBestRoute && '?'}
298
- {!!bestRoute?.result && `≈ ${props.outputAmount}`}
299
- {(!inputAmount || inputAmount === '0') && '0'}
300
- </Typography>
301
- </OutputContainer>
302
- )}
303
- </div>
304
- </div>
305
- </Container>
306
- </Box>
307
- );
308
- }
@@ -1 +0,0 @@
1
- export { TokenInfo } from './TokenInfo';