@rango-dev/ui 0.1.11-next.3 → 0.1.11-next.5

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.3",
3
+ "version": "0.1.11-next.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -7,6 +7,7 @@ import { Skeleton } from '../Skeleton';
7
7
  import { Spinner } from '../Spinner';
8
8
  import { BestRouteResponse } from 'rango-sdk';
9
9
  import { Tooltip } from '../Tooltip';
10
+ import { Image } from '../common';
10
11
 
11
12
  const Container = styled('div', {
12
13
  borderRadius: '$5',
@@ -48,10 +49,6 @@ const HR = styled('hr', {
48
49
  margin: '$8 0',
49
50
  });
50
51
 
51
- const SwapperLogo = styled('img', {
52
- width: '$16',
53
- height: '$16',
54
- });
55
52
  const RelativeContainer = styled('div', {
56
53
  position: 'relative',
57
54
  });
@@ -208,7 +205,7 @@ export function BestRoute(props: PropsWithChildren<PropTypes>) {
208
205
  )}
209
206
  <SwapperContainer>
210
207
  <Line />
211
- <SwapperLogo src={swap.swapperLogo} alt={swap.swapperId} />
208
+ <Image src={swap.swapperLogo} alt={swap.swapperId} size={20} />
212
209
  <Line />
213
210
  </SwapperContainer>
214
211
 
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import { styled } from '../../theme';
3
3
  import { BlockchainMeta } from 'rango-sdk';
4
4
  import { Button } from '../Button/Button';
5
- import { FilledCircle } from '../common';
5
+ import { FilledCircle, Image } from '../common';
6
6
  import { Typography } from '../Typography';
7
7
 
8
8
  export interface PropTypes {
@@ -22,10 +22,8 @@ const ListContainer = styled('div', {
22
22
  height: '100%',
23
23
  });
24
24
 
25
- const Image = styled('img', {
26
- width: '1.5rem',
27
- maxHeight: '1.5rem',
28
- marginRight: '$4',
25
+ const ImageContainer = styled('div', {
26
+ paddingRight: '$4',
29
27
  });
30
28
 
31
29
  export function BlockchainsList(props: PropTypes) {
@@ -55,7 +53,11 @@ export function BlockchainsList(props: PropTypes) {
55
53
  type={isSelect(blockchain.name) ? 'primary' : undefined}
56
54
  variant="outlined"
57
55
  size="large"
58
- prefix={<Image src={blockchain.logo} />}
56
+ prefix={
57
+ <ImageContainer>
58
+ <Image size={24} src={blockchain.logo} />
59
+ </ImageContainer>
60
+ }
59
61
  suffix={isSelect(blockchain.name) ? <FilledCircle /> : undefined}
60
62
  align="start"
61
63
  onClick={changeSelectedBlockchain.bind(null, blockchain)}
@@ -31,6 +31,11 @@ export const SvgWithStrokeColor = styled('svg', {
31
31
  stroke: '$$color',
32
32
  },
33
33
  },
34
+ disabled: {
35
+ true: {
36
+ stroke: '$neutrals400',
37
+ },
38
+ },
34
39
  },
35
40
  });
36
41
 
@@ -65,5 +70,10 @@ export const SvgWithFillColor = styled('svg', {
65
70
  fill: '$$color',
66
71
  },
67
72
  },
73
+ disabled: {
74
+ true: {
75
+ stroke: '$neutrals400',
76
+ },
77
+ },
68
78
  },
69
79
  });
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  export interface IconProps extends React.SVGAttributes<SVGElement> {
4
4
  size?: 12 | 16 | 18 | 20 | 24 | 28 | 32 | 36 | 40;
5
5
  color?: 'primary' | 'error' | 'warning' | 'success' | 'black' | 'white';
6
+ disabled?: boolean;
6
7
  }
7
8
 
8
9
  export type Icon =
@@ -9,6 +9,7 @@ import { Typography } from '../Typography';
9
9
  import { Spinner } from '../Spinner';
10
10
  import { LoadingFailedAlert } from '../Alert/LoadingFailedAlert';
11
11
  import { NotFoundAlert } from '../Alert/NotFoundAlert';
12
+ import { Image } from '../common';
12
13
 
13
14
  const groupLiquiditySources = (
14
15
  liquiditySources: LiquiditySource[]
@@ -44,10 +45,8 @@ const LiquiditySourceType = styled('div', {
44
45
  paddingBottom: '$8',
45
46
  });
46
47
 
47
- const LiquidityImage = styled('img', {
48
- width: '$20',
49
- maxHeight: '$20',
50
- marginRight: '$16',
48
+ const LiquidityImageContainer = styled('div', {
49
+ paddingRight: '$16',
51
50
  });
52
51
 
53
52
  const LoaderContainer = styled('div', {
@@ -185,7 +184,11 @@ const LiquiditySourceItem = ({
185
184
  size="large"
186
185
  align="start"
187
186
  variant="outlined"
188
- prefix={<LiquidityImage src={liquiditySource.logo} />}
187
+ prefix={
188
+ <LiquidityImageContainer>
189
+ <Image src={liquiditySource.logo} size={20} />
190
+ </LiquidityImageContainer>
191
+ }
189
192
  suffix={<Switch checked={selected} />}
190
193
  style={{ marginBottom: '12px' }}
191
194
  onClick={onChange.bind(null, liquiditySource)}
@@ -3,6 +3,7 @@ import { styled } from '../../theme';
3
3
  import { SelectableWallet } from '../../types';
4
4
  import { Typography } from '../Typography';
5
5
  import { getConciseAddress } from '../../helper';
6
+ import { Image } from '../common';
6
7
 
7
8
  const Row = styled('div', {
8
9
  display: 'flex',
@@ -102,7 +103,7 @@ export function SelectableWalletList({
102
103
  onClick={onClick.bind(null, w)}
103
104
  key={index}
104
105
  >
105
- <img src={w.image} alt={w.walletType} width={24} height={24} />
106
+ <Image src={w.image} alt={w.walletType} size={24} />
106
107
  <Typography variant="body2">{w.name}</Typography>
107
108
  <Typography variant="caption">
108
109
  {getConciseAddress(w.address)}
@@ -50,6 +50,12 @@ const StepContainer = styled('div', {
50
50
  justifyContent: 'center',
51
51
  },
52
52
  },
53
+ success: {
54
+ true: { filter: 'none' },
55
+ false: {
56
+ filter: 'grayscale(100%)',
57
+ },
58
+ },
53
59
  },
54
60
  });
55
61
  const Detail = styled('div', {
@@ -70,6 +76,7 @@ const Detail = styled('div', {
70
76
  const SubTitle = styled(Typography, {
71
77
  color: '$neutrals600',
72
78
  display: 'block',
79
+ paddingLeft: '$8',
73
80
  });
74
81
  export interface PropTypes {
75
82
  logo: string;
@@ -77,19 +84,24 @@ export interface PropTypes {
77
84
  amount: string;
78
85
  symbol: string;
79
86
  blockchain: string;
87
+ estimatedAmount?: string;
80
88
  direction?: 'horizontal' | 'vertical';
89
+ success?: boolean;
81
90
  }
82
91
 
83
- export function StepDetail({
84
- logo,
85
- chainLogo,
86
- amount,
87
- symbol,
88
- blockchain,
89
- direction = 'horizontal',
90
- }: 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;
91
103
  return (
92
- <StepContainer direction={direction}>
104
+ <StepContainer direction={direction} success={success}>
93
105
  <StepLogoContainer direction={direction}>
94
106
  <Logo src={logo} alt={symbol} />
95
107
  <ChainLogo>
@@ -97,10 +109,28 @@ export function StepDetail({
97
109
  </ChainLogo>
98
110
  </StepLogoContainer>
99
111
  <Detail pl={direction === 'horizontal'}>
100
- <Typography noWrap variant={direction === 'vertical' ? 'body2' : 'h6'}>
101
- {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}
102
132
  </Typography>
103
- <SubTitle noWrap variant="caption" color="neutrals800">
133
+ <SubTitle noWrap variant="caption" color="$neutrals800">
104
134
  on {blockchain}
105
135
  </SubTitle>
106
136
  </Detail>
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { styled } from '../../theme';
3
3
  import { Spacer } from '../Spacer';
4
+ import { Image } from '../common';
4
5
 
5
6
  const TokenContainer = styled('div', {
6
7
  display: 'flex',
@@ -14,13 +15,6 @@ const TokenContainer = styled('div', {
14
15
 
15
16
  const TokenImage = styled('div', {
16
17
  position: 'relative',
17
- width: '$24',
18
- height: '$24',
19
-
20
- img: {
21
- width: '100%',
22
- display: 'block',
23
- },
24
18
 
25
19
  '.overlay': {
26
20
  position: 'absolute',
@@ -30,6 +24,9 @@ const TokenImage = styled('div', {
30
24
  height: '$16',
31
25
  padding: '$2',
32
26
  borderRadius: '50%',
27
+ display: 'flex',
28
+ justifyContent: 'center',
29
+ alignItems: 'center',
33
30
  backgroundColor: '$background',
34
31
  border: '1px solid $neutrals400',
35
32
  },
@@ -52,11 +49,12 @@ export function Token(props: PropTypes) {
52
49
  return (
53
50
  <TokenContainer>
54
51
  <TokenImage>
55
- <img src={props.data.token.logo} alt="" />
52
+ <Image src={props.data.token.logo} alt="" size={24} />
56
53
  <div className="overlay">
57
- <img
54
+ <Image
58
55
  src={props.data.blockchain.logo}
59
56
  alt={props.data.blockchain.name}
57
+ size={12}
60
58
  />
61
59
  </div>
62
60
  </TokenImage>
@@ -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 TokenImage = styled('img', {
9
- width: '$32',
10
- maxHeight: '$32',
11
- marginRight: '$16',
9
+ const TokenImageContainer = styled('div', {
10
+ paddingRight: '$16',
12
11
  });
13
12
 
14
13
  const TokenNameContainer = styled('div', {
@@ -49,7 +48,11 @@ export function TokenItem(props: PropTypes) {
49
48
  align="start"
50
49
  onClick={onClick.bind(null, token)}
51
50
  type={selected ? 'primary' : undefined}
52
- prefix={<TokenImage src={token.image} />}
51
+ prefix={
52
+ <TokenImageContainer>
53
+ <Image src={token.image} size={32} />
54
+ </TokenImageContainer>
55
+ }
53
56
  suffix={
54
57
  token.balance?.amount && (
55
58
  <TokenAmountContainer>
@@ -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 WalletImage = styled('img', {
11
- width: '$24',
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',
@@ -51,7 +50,11 @@ export function Wallet(props: PropTypes) {
51
50
  align="start"
52
51
  variant="outlined"
53
52
  size="large"
54
- prefix={<WalletImage src={image} />}
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
+ }
@@ -1 +1,2 @@
1
1
  export { FilledCircle } from './FilledCircle';
2
+ export { Image } from './Image';
@@ -91,7 +91,7 @@ export function History({
91
91
  <SecondaryPage
92
92
  onBack={onBack}
93
93
  textField={true}
94
- textFieldPlaceholder="Search By Blockchain Or Token Or Request ID"
94
+ textFieldPlaceholder="Search by Blockchain/Token/Request Id"
95
95
  title="Swaps"
96
96
  >
97
97
  {(searchedFor) => {
@@ -12,6 +12,7 @@ import {
12
12
  Drawer,
13
13
  Spinner,
14
14
  Divider,
15
+ Image,
15
16
  } from '../../components';
16
17
  import { styled } from '../../theme';
17
18
  import { PendingSwap } from '../History/types';
@@ -24,7 +25,19 @@ import {
24
25
  export const SwapperContainer = styled('div', {
25
26
  display: 'flex',
26
27
  alignItems: 'center',
27
- 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
+ },
28
41
  });
29
42
 
30
43
  export const BodyError = styled('div', {
@@ -38,16 +51,15 @@ export const ErrorMsg = styled(Typography, {
38
51
  color: '$error',
39
52
  });
40
53
 
54
+ export const FeeContainer = styled('div', {
55
+ paddingLeft: '$4',
56
+ });
57
+
41
58
  export const Fee = styled('div', {
42
59
  display: 'flex',
43
60
  alignItems: 'center',
44
61
  });
45
62
 
46
- export const SwapperLogo = styled('img', {
47
- width: '$16',
48
- height: '$16',
49
- });
50
-
51
63
  export const RelativeContainer = styled('div', {
52
64
  position: 'relative',
53
65
  });
@@ -62,7 +74,7 @@ export const Dot = styled('div', {
62
74
  height: '$8',
63
75
  backgroundColor: '$foreground',
64
76
  borderRadius: '4px',
65
- marginLeft: '$8',
77
+ marginLeft: '11px',
66
78
  });
67
79
 
68
80
  export const ArrowDown = styled('div', {
@@ -71,7 +83,7 @@ export const ArrowDown = styled('div', {
71
83
  borderLeft: '5px solid transparent',
72
84
  borderRight: '5px solid transparent',
73
85
  borderTop: '5px solid $foreground',
74
- marginLeft: '$8',
86
+ marginLeft: '$10',
75
87
  });
76
88
 
77
89
  const StyledAnchor = styled('a', {
@@ -106,14 +118,10 @@ const Description = styled(Typography, {
106
118
  marginLeft: '$8',
107
119
  });
108
120
 
109
- const Error = styled(Description, {
110
- color: '$error',
111
- });
112
-
113
121
  export const Line = styled('div', {
114
122
  width: '0',
115
123
  minHeight: '$16',
116
- marginLeft: '$12',
124
+ marginLeft: '14px',
117
125
  border: '1px dashed $foreground',
118
126
  borderRadius: 'inherit',
119
127
  });
@@ -161,23 +169,9 @@ const ExtraDetails = styled('div', {
161
169
  fontSize: '$12',
162
170
  });
163
171
 
164
- const StepContainer = styled('div', {
165
- variants: {
166
- hasNotStarted: {
167
- true: {
168
- filter: 'grayscale(100%)',
169
- },
170
- },
171
- isRunning: {
172
- true: {
173
- animation: `${pulse} 2s ease-in-out infinite`,
174
- },
175
- },
176
- },
177
- });
178
-
179
172
  const SwapFlowContainer = styled('div', {
180
173
  overflowY: 'auto',
174
+ paddingTop: '$8',
181
175
  });
182
176
 
183
177
  export type PropTypes = {
@@ -275,21 +269,12 @@ export function SwapHistory(props: PropTypes) {
275
269
  <Divider size={32} />
276
270
 
277
271
  {pendingSwap?.steps.map((step, index) => (
278
- <StepContainer
279
- key={index}
280
- hasNotStarted={step.status === 'created'}
281
- isRunning={
282
- step.status != 'failed' &&
283
- step.status != 'success' &&
284
- step.status != 'created'
285
- }
286
- >
272
+ <div key={index}>
287
273
  {index === 0 && (
288
274
  <RelativeContainer>
289
275
  <StepDetail
290
276
  logo={step.fromLogo}
291
277
  symbol={step.fromSymbol}
292
- // @ts-ignore
293
278
  chainLogo={step.fromBlockchainLogo || ''}
294
279
  blockchain={step.fromBlockchain}
295
280
  amount={pendingSwap.inputAmount}
@@ -298,36 +283,28 @@ export function SwapHistory(props: PropTypes) {
298
283
  </RelativeContainer>
299
284
  )}
300
285
  <Line />
301
- <SwapperContainer>
302
- <SwapperLogo
303
- src={
304
- // @ts-ignore
305
- step.swapperLogo || ''
306
- }
286
+ <SwapperContainer
287
+ created={step.status === 'created'}
288
+ running={!['created', 'success', 'failed'].includes(step.status)}
289
+ >
290
+ <Image
291
+ src={step.swapperLogo || ''}
307
292
  alt={step.swapperId}
293
+ size={20}
308
294
  />
309
- <div>
310
- <Typography ml={4} variant="caption">
311
- {
312
- // @ts-ignore
313
- step.swapperType
314
- }{' '}
315
- from {step.fromSymbol} to {step.toSymbol}
316
- via {step.swapperId}
295
+
296
+ <FeeContainer>
297
+ <Typography variant="caption">
298
+ {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
299
+ &nbsp; via {step.swapperId}
317
300
  </Typography>
318
301
  <Fee>
319
302
  <GasIcon />
320
- <Typography ml={4} variant="caption">
321
- $
322
- {
323
- // @ts-ignore
324
-
325
- step.feeInUsd
326
- }{' '}
327
- estimated gas fee
303
+ <Typography variant="caption">
304
+ &nbsp; ${step.feeInUsd} estimated gas fee
328
305
  </Typography>
329
306
  </Fee>
330
- </div>
307
+ </FeeContainer>
331
308
  </SwapperContainer>
332
309
  <div
333
310
  style={{
@@ -336,56 +313,62 @@ export function SwapHistory(props: PropTypes) {
336
313
  >
337
314
  <InternalDetailsContainer>
338
315
  <Line />
339
- {!!step.explorerUrl && (
340
- <div>
341
- {step.explorerUrl.map((item, index) => (
342
- <InternalDetail key={index}>
343
- <DescriptionContainer>
344
- <CheckCircleIcon color="success" />
345
- <Description variant="body2">
346
- {!item.description ? (
347
- <b>View transaction</b>
348
- ) : (
349
- <b>
350
- {item.description.substring(0, 1).toUpperCase()}
351
- {item.description.substring(1)}
352
- </b>
353
- )}
354
- </Description>
355
- </DescriptionContainer>
356
- <StyledAnchor
357
- href={item.url}
358
- target="_blank"
359
- rel="noreferrer"
360
- key={index}
361
- >
362
- TX-Link
363
- </StyledAnchor>
364
- </InternalDetail>
365
- ))}
366
- {step.status === 'failed' && (
367
- <InternalDetail>
368
- <DescriptionContainer>
369
- <InfoCircleIcon color="error" />
370
- <Error variant="body2">Step failed</Error>
371
- </DescriptionContainer>
372
- </InternalDetail>
373
- )}
374
- </div>
375
- )}
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>
376
359
  </InternalDetailsContainer>
377
360
  </div>
378
361
  {index + 1 === pendingSwap.steps.length && <ArrowDown />}
379
362
  <StepDetail
380
363
  logo={step.toLogo}
381
364
  symbol={step.toSymbol}
382
- // @ts-ignore
383
-
384
365
  chainLogo={step.toBlockchainLogo || ''}
385
366
  blockchain={step.toBlockchain}
386
367
  amount={step.outputAmount || ''}
368
+ estimatedAmount={step.expectedOutputAmountHumanReadable || ''}
369
+ success={step.status === 'success'}
387
370
  />
388
- </StepContainer>
371
+ </div>
389
372
  ))}
390
373
 
391
374
  <Divider size={32} />