@rango-dev/ui 0.1.11-next.4 → 0.1.11-next.6

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/ui",
3
- "version": "0.1.11-next.4",
3
+ "version": "0.1.11-next.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -13,6 +13,7 @@ import { LoaderContainer } from '../TokenSelector/TokenSelector';
13
13
 
14
14
  const ListContainer = styled('div', {
15
15
  overflowY: 'auto',
16
+ padding: '0 $4',
16
17
  });
17
18
 
18
19
  const filterBlockchains = (list: BlockchainMeta[], searchedFor: string) =>
@@ -28,6 +28,7 @@ const MainContainer = styled('div', {
28
28
  loaded: {
29
29
  true: {
30
30
  overflowY: 'auto',
31
+ padding: '0 $4',
31
32
  },
32
33
  },
33
34
  },
@@ -1,7 +1,6 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
2
  import { styled } from '../../theme';
3
3
  import { Typography } from '../Typography';
4
- import { Image } from '../common';
5
4
 
6
5
  const StepLogoContainer = styled('div', {
7
6
  position: 'relative',
@@ -16,6 +15,11 @@ const StepLogoContainer = styled('div', {
16
15
  },
17
16
  },
18
17
  });
18
+ const Logo = styled('img', {
19
+ width: '$28',
20
+ height: '$28',
21
+ borderRadius: '50%',
22
+ });
19
23
 
20
24
  const ChainLogo = styled('div', {
21
25
  position: 'absolute',
@@ -23,12 +27,15 @@ const ChainLogo = styled('div', {
23
27
  bottom: -4,
24
28
  width: '$16',
25
29
  height: '$16',
30
+ padding: '$2',
26
31
  borderRadius: '50%',
27
- display: 'flex',
28
- justifyContent: 'center',
29
- alignItems: 'center',
30
32
  backgroundColor: '$background',
31
33
  border: '1px solid $neutrals400',
34
+
35
+ img: {
36
+ width: '100%',
37
+ display: 'block',
38
+ },
32
39
  });
33
40
  const StepContainer = styled('div', {
34
41
  display: 'flex',
@@ -43,6 +50,12 @@ const StepContainer = styled('div', {
43
50
  justifyContent: 'center',
44
51
  },
45
52
  },
53
+ success: {
54
+ true: { filter: 'none' },
55
+ false: {
56
+ filter: 'grayscale(100%)',
57
+ },
58
+ },
46
59
  },
47
60
  });
48
61
  const Detail = styled('div', {
@@ -63,6 +76,7 @@ const Detail = styled('div', {
63
76
  const SubTitle = styled(Typography, {
64
77
  color: '$neutrals600',
65
78
  display: 'block',
79
+ paddingLeft: '$8',
66
80
  });
67
81
  export interface PropTypes {
68
82
  logo: string;
@@ -70,30 +84,53 @@ export interface PropTypes {
70
84
  amount: string;
71
85
  symbol: string;
72
86
  blockchain: string;
87
+ estimatedAmount?: string;
73
88
  direction?: 'horizontal' | 'vertical';
89
+ success?: boolean;
74
90
  }
75
91
 
76
- export function StepDetail({
77
- logo,
78
- chainLogo,
79
- amount,
80
- symbol,
81
- blockchain,
82
- direction = 'horizontal',
83
- }: PropsWithChildren<PropTypes>) {
92
+ export function StepDetail(props: PropsWithChildren<PropTypes>) {
93
+ const {
94
+ logo,
95
+ chainLogo,
96
+ amount,
97
+ symbol,
98
+ blockchain,
99
+ estimatedAmount,
100
+ success = true,
101
+ direction = 'horizontal',
102
+ } = props;
84
103
  return (
85
- <StepContainer direction={direction}>
104
+ <StepContainer direction={direction} success={success}>
86
105
  <StepLogoContainer direction={direction}>
87
- <Image src={logo} alt={symbol} size={28} />
106
+ <Logo src={logo} alt={symbol} />
88
107
  <ChainLogo>
89
- <Image src={chainLogo} alt={blockchain} size={12} />
108
+ <img src={chainLogo} alt={blockchain} />
90
109
  </ChainLogo>
91
110
  </StepLogoContainer>
92
111
  <Detail pl={direction === 'horizontal'}>
93
- <Typography noWrap variant={direction === 'vertical' ? 'body2' : 'h6'}>
94
- {amount ? parseFloat(amount).toFixed(2) : '?'} {symbol}
112
+ {amount && (
113
+ <Typography
114
+ noWrap
115
+ variant={direction === 'vertical' ? 'body2' : 'h6'}
116
+ >
117
+ {amount}
118
+ </Typography>
119
+ )}
120
+ {!amount && estimatedAmount && (
121
+ <Typography
122
+ noWrap
123
+ variant={direction === 'vertical' ? 'body2' : 'h6'}
124
+ color={'$neutrals500'}
125
+ >
126
+ {estimatedAmount}
127
+ </Typography>
128
+ )}
129
+ &nbsp;
130
+ <Typography variant={direction === 'vertical' ? 'body2' : 'h6'} noWrap>
131
+ {symbol}
95
132
  </Typography>
96
- <SubTitle noWrap variant="caption" color="neutrals800">
133
+ <SubTitle noWrap variant="caption" color="$neutrals800">
97
134
  on {blockchain}
98
135
  </SubTitle>
99
136
  </Detail>
@@ -25,7 +25,19 @@ import {
25
25
  export const SwapperContainer = styled('div', {
26
26
  display: 'flex',
27
27
  alignItems: 'center',
28
- marginLeft: '6px',
28
+ paddingLeft: '$4',
29
+ variants: {
30
+ created: {
31
+ true: {
32
+ filter: 'grayscale(100%)',
33
+ },
34
+ },
35
+ running: {
36
+ true: {
37
+ animation: `${pulse} 2s ease-in-out infinite`,
38
+ },
39
+ },
40
+ },
29
41
  });
30
42
 
31
43
  export const BodyError = styled('div', {
@@ -39,6 +51,10 @@ export const ErrorMsg = styled(Typography, {
39
51
  color: '$error',
40
52
  });
41
53
 
54
+ export const FeeContainer = styled('div', {
55
+ paddingLeft: '$4',
56
+ });
57
+
42
58
  export const Fee = styled('div', {
43
59
  display: 'flex',
44
60
  alignItems: 'center',
@@ -58,7 +74,7 @@ export const Dot = styled('div', {
58
74
  height: '$8',
59
75
  backgroundColor: '$foreground',
60
76
  borderRadius: '4px',
61
- marginLeft: '$8',
77
+ marginLeft: '11px',
62
78
  });
63
79
 
64
80
  export const ArrowDown = styled('div', {
@@ -67,7 +83,7 @@ export const ArrowDown = styled('div', {
67
83
  borderLeft: '5px solid transparent',
68
84
  borderRight: '5px solid transparent',
69
85
  borderTop: '5px solid $foreground',
70
- marginLeft: '$8',
86
+ marginLeft: '$10',
71
87
  });
72
88
 
73
89
  const StyledAnchor = styled('a', {
@@ -102,14 +118,10 @@ const Description = styled(Typography, {
102
118
  marginLeft: '$8',
103
119
  });
104
120
 
105
- const Error = styled(Description, {
106
- color: '$error',
107
- });
108
-
109
121
  export const Line = styled('div', {
110
122
  width: '0',
111
123
  minHeight: '$16',
112
- marginLeft: '$12',
124
+ marginLeft: '14px',
113
125
  border: '1px dashed $foreground',
114
126
  borderRadius: 'inherit',
115
127
  });
@@ -157,23 +169,9 @@ const ExtraDetails = styled('div', {
157
169
  fontSize: '$12',
158
170
  });
159
171
 
160
- const StepContainer = styled('div', {
161
- variants: {
162
- hasNotStarted: {
163
- true: {
164
- filter: 'grayscale(100%)',
165
- },
166
- },
167
- isRunning: {
168
- true: {
169
- animation: `${pulse} 2s ease-in-out infinite`,
170
- },
171
- },
172
- },
173
- });
174
-
175
172
  const SwapFlowContainer = styled('div', {
176
173
  overflowY: 'auto',
174
+ paddingTop: '$8',
177
175
  });
178
176
 
179
177
  export type PropTypes = {
@@ -271,21 +269,12 @@ export function SwapHistory(props: PropTypes) {
271
269
  <Divider size={32} />
272
270
 
273
271
  {pendingSwap?.steps.map((step, index) => (
274
- <StepContainer
275
- key={index}
276
- hasNotStarted={step.status === 'created'}
277
- isRunning={
278
- step.status != 'failed' &&
279
- step.status != 'success' &&
280
- step.status != 'created'
281
- }
282
- >
272
+ <div key={index}>
283
273
  {index === 0 && (
284
274
  <RelativeContainer>
285
275
  <StepDetail
286
276
  logo={step.fromLogo}
287
277
  symbol={step.fromSymbol}
288
- // @ts-ignore
289
278
  chainLogo={step.fromBlockchainLogo || ''}
290
279
  blockchain={step.fromBlockchain}
291
280
  amount={pendingSwap.inputAmount}
@@ -294,35 +283,28 @@ export function SwapHistory(props: PropTypes) {
294
283
  </RelativeContainer>
295
284
  )}
296
285
  <Line />
297
- <SwapperContainer>
286
+ <SwapperContainer
287
+ created={step.status === 'created'}
288
+ running={!['created', 'success', 'failed'].includes(step.status)}
289
+ >
298
290
  <Image
299
- // @ts-ignore
300
- src={step.swapperLogo}
291
+ src={step.swapperLogo || ''}
301
292
  alt={step.swapperId}
302
- size={16}
293
+ size={20}
303
294
  />
304
- <div>
305
- <Typography ml={4} variant="caption">
306
- {
307
- // @ts-ignore
308
- step.swapperType
309
- }{' '}
310
- from {step.fromSymbol} to {step.toSymbol}
311
- via {step.swapperId}
295
+
296
+ <FeeContainer>
297
+ <Typography variant="caption">
298
+ {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
299
+ &nbsp; via {step.swapperId}
312
300
  </Typography>
313
301
  <Fee>
314
302
  <GasIcon />
315
- <Typography ml={4} variant="caption">
316
- $
317
- {
318
- // @ts-ignore
319
-
320
- step.feeInUsd
321
- }{' '}
322
- estimated gas fee
303
+ <Typography variant="caption">
304
+ &nbsp; ${step.feeInUsd} estimated gas fee
323
305
  </Typography>
324
306
  </Fee>
325
- </div>
307
+ </FeeContainer>
326
308
  </SwapperContainer>
327
309
  <div
328
310
  style={{
@@ -331,56 +313,62 @@ export function SwapHistory(props: PropTypes) {
331
313
  >
332
314
  <InternalDetailsContainer>
333
315
  <Line />
334
- {!!step.explorerUrl && (
335
- <div>
336
- {step.explorerUrl.map((item, index) => (
337
- <InternalDetail key={index}>
338
- <DescriptionContainer>
339
- <CheckCircleIcon color="success" />
340
- <Description variant="body2">
341
- {!item.description ? (
342
- <b>View transaction</b>
343
- ) : (
344
- <b>
345
- {item.description.substring(0, 1).toUpperCase()}
346
- {item.description.substring(1)}
347
- </b>
348
- )}
349
- </Description>
350
- </DescriptionContainer>
351
- <StyledAnchor
352
- href={item.url}
353
- target="_blank"
354
- rel="noreferrer"
355
- key={index}
356
- >
357
- TX-Link
358
- </StyledAnchor>
359
- </InternalDetail>
360
- ))}
361
- {step.status === 'failed' && (
362
- <InternalDetail>
363
- <DescriptionContainer>
364
- <InfoCircleIcon color="error" />
365
- <Error variant="body2">Step failed</Error>
366
- </DescriptionContainer>
367
- </InternalDetail>
368
- )}
369
- </div>
370
- )}
316
+ <div>
317
+ {!!step.explorerUrl && (
318
+ <div>
319
+ {step.explorerUrl.map((item, index) => (
320
+ <InternalDetail key={index}>
321
+ <DescriptionContainer>
322
+ <CheckCircleIcon color="success" />
323
+ <Description variant="body2">
324
+ {!item.description ? (
325
+ <b>View transaction</b>
326
+ ) : (
327
+ <b>
328
+ {item.description
329
+ .substring(0, 1)
330
+ .toUpperCase()}
331
+ {item.description.substring(1)}
332
+ </b>
333
+ )}
334
+ </Description>
335
+ </DescriptionContainer>
336
+ <StyledAnchor
337
+ href={item.url}
338
+ target="_blank"
339
+ rel="noreferrer"
340
+ key={index}
341
+ >
342
+ TX-Link
343
+ </StyledAnchor>
344
+ </InternalDetail>
345
+ ))}
346
+ </div>
347
+ )}
348
+ {step.status === 'failed' && (
349
+ <InternalDetail>
350
+ <DescriptionContainer>
351
+ <InfoCircleIcon color="error" />
352
+ <Description variant="body2" color="$error500">
353
+ Step failed
354
+ </Description>
355
+ </DescriptionContainer>
356
+ </InternalDetail>
357
+ )}
358
+ </div>
371
359
  </InternalDetailsContainer>
372
360
  </div>
373
361
  {index + 1 === pendingSwap.steps.length && <ArrowDown />}
374
362
  <StepDetail
375
363
  logo={step.toLogo}
376
364
  symbol={step.toSymbol}
377
- // @ts-ignore
378
-
379
365
  chainLogo={step.toBlockchainLogo || ''}
380
366
  blockchain={step.toBlockchain}
381
367
  amount={step.outputAmount || ''}
368
+ estimatedAmount={step.expectedOutputAmountHumanReadable || ''}
369
+ success={step.status === 'success'}
382
370
  />
383
- </StepContainer>
371
+ </div>
384
372
  ))}
385
373
 
386
374
  <Divider size={32} />