@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,183 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import {
3
- Button,
4
- InfoCircleIcon,
5
- styled,
6
- Typography,
7
- Divider,
8
- Image,
9
- } from '../..';
10
- import { i18n } from '@lingui/core';
11
- import { LoadingStatus } from '../../types/meta';
12
-
13
- const Box = styled('div', {
14
- display: 'flex',
15
- flexDirection: 'column',
16
- width: '100%',
17
- overflow: 'hidden',
18
- });
19
-
20
- const Container = styled('div', {
21
- boxSizing: 'border-box',
22
- borderRadius: '$5',
23
- padding: '$8 $16 $16 $16',
24
-
25
- variants: {
26
- type: {
27
- filled: {
28
- backgroundColor: '$neutral100',
29
- },
30
- outlined: {
31
- border: '1px solid $neutral100',
32
- },
33
- },
34
- },
35
-
36
- defaultVariants: {
37
- type: 'filled',
38
- },
39
-
40
- '.head': {
41
- display: 'flex',
42
- justifyContent: 'space-between',
43
- alignItems: 'center',
44
- minHeight: '32px',
45
- '.usd-value': {
46
- paddingLeft: '$8',
47
- },
48
- },
49
- '.form': {
50
- display: 'flex',
51
- width: '100%',
52
- padding: '$2 0',
53
- '.selectors': {
54
- width: '35%',
55
-
56
- '._text': {
57
- whiteSpace: 'nowrap',
58
- overflow: 'hidden',
59
- textOverflow: 'ellipsis',
60
- },
61
- },
62
- '.amount': {
63
- width: '30%',
64
- },
65
- },
66
- });
67
-
68
- const ImagePlaceholder = styled('span', {
69
- width: '24px',
70
- height: '24px',
71
- backgroundColor: '$neutral100',
72
- borderRadius: '99999px',
73
- });
74
-
75
- const OutputContainer = styled('div', {
76
- windth: '100%',
77
- height: '$48',
78
- borderRadius: '$5',
79
- backgroundColor: '$surface',
80
- border: '1px solid transparent',
81
- position: 'relative',
82
- display: 'flex',
83
- alignItems: 'center',
84
- paddingLeft: '$8',
85
- paddingRight: '$8',
86
- });
87
-
88
- interface PropTypes {
89
- label: string;
90
- amount: string;
91
- usdValue: string | null;
92
- loadingStatus: LoadingStatus;
93
- chain: {
94
- displayName: string;
95
- logo: string;
96
- };
97
- token: {
98
- symbol: string;
99
- image: string;
100
- };
101
- percentageChange?: ReactNode;
102
- }
103
-
104
- export function TokenPreview(props: PropTypes) {
105
- const { chain, token, loadingStatus, percentageChange } = props;
106
-
107
- const ItemSuffix = (
108
- <div
109
- style={{
110
- display: 'flex',
111
- justifyContent: 'center',
112
- alignItems: 'center',
113
- }}>
114
- {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
115
- </div>
116
- );
117
-
118
- return (
119
- <Box>
120
- <Container type={'outlined'}>
121
- <div className="head">
122
- <Typography variant="body2" color="neutral800">
123
- {props.label}
124
- </Typography>
125
- <div>
126
- {percentageChange}
127
- {props.usdValue && (
128
- <Typography
129
- variant="caption"
130
- color="neutral600"
131
- className="usd-value">{`$${props.usdValue}`}</Typography>
132
- )}
133
- </div>
134
- </div>
135
- <div className="form">
136
- <Button
137
- className="selectors"
138
- variant="outlined"
139
- loading={loadingStatus === 'loading'}
140
- prefix={
141
- loadingStatus === 'success' && chain ? (
142
- <Image src={chain.logo} size={24} />
143
- ) : (
144
- <ImagePlaceholder />
145
- )
146
- }
147
- suffix={ItemSuffix}
148
- align="start"
149
- size="large">
150
- {loadingStatus === 'success' && chain
151
- ? chain.displayName
152
- : i18n.t('Chain')}
153
- </Button>
154
- <Divider size={12} direction="horizontal" />
155
- <Button
156
- className="selectors"
157
- variant="outlined"
158
- loading={loadingStatus === 'loading'}
159
- prefix={
160
- loadingStatus === 'success' && token ? (
161
- <Image src={token.image} size={24} />
162
- ) : (
163
- <ImagePlaceholder />
164
- )
165
- }
166
- suffix={ItemSuffix}
167
- size="large"
168
- align="start">
169
- {loadingStatus === 'success' && token
170
- ? token.symbol
171
- : i18n.t('Token')}
172
- </Button>
173
- <Divider size={12} direction="horizontal" />
174
- <div className="amount">
175
- <OutputContainer>
176
- <Typography variant="h4">{props.amount}</Typography>
177
- </OutputContainer>
178
- </div>
179
- </div>
180
- </Container>
181
- </Box>
182
- );
183
- }
@@ -1 +0,0 @@
1
- export { TokenPreview } from './TokenPreview';
@@ -1,228 +0,0 @@
1
- import {
2
- Alert,
3
- BestRoute,
4
- BottomLogo,
5
- Button,
6
- styled,
7
- Typography,
8
- Header,
9
- HeaderButtons,
10
- TokenInfo,
11
- ConnectedWallet,
12
- } from '../..';
13
- import React from 'react';
14
- import { i18n } from '@lingui/core';
15
- import { BestRouteResponse, BlockchainMeta, SwapResult } from 'rango-sdk';
16
- import { LoadingStatus, TokenWithBalance } from '../../types/meta';
17
-
18
- const Container = styled('div', {
19
- display: 'flex',
20
- flexDirection: 'column',
21
- });
22
-
23
- const FromContainer = styled('div', {
24
- position: 'relative',
25
- paddingBottom: '$12',
26
- });
27
-
28
- const BestRouteContainer = styled('div', {
29
- width: '100%',
30
- paddingTop: '$16',
31
- });
32
-
33
- const Alerts = styled('div', {
34
- width: '100%',
35
- paddingTop: '$16',
36
- });
37
-
38
- const Footer = styled('div', {
39
- display: 'flex',
40
- flexDirection: 'column',
41
- width: '100%',
42
- paddingTop: '$16',
43
- });
44
-
45
- interface HomePanelProps {
46
- bestRoute: BestRouteResponse | null;
47
- bestRouteError: string;
48
- fetchBestRoute: () => void;
49
- onClickHistory: () => void;
50
- onClickSettings: () => void;
51
- fromChain: BlockchainMeta | null;
52
- toChain: BlockchainMeta | null;
53
- fromToken: TokenWithBalance | null;
54
- toToken: TokenWithBalance | null;
55
- setInputAmount: (amount: string) => void;
56
- outputAmount: string;
57
- outputUsdValue: string;
58
- inputUsdValue: string;
59
- inputAmount: string;
60
- loadingStatus: LoadingStatus;
61
- showBestRoute: boolean;
62
- fetchingBestRoute: boolean;
63
- swapButtonTitle: string;
64
- swapButtonDisabled: boolean;
65
- swapButtonClick: () => void;
66
- onChainClick: (route: 'from-chain' | 'to-chain') => void;
67
- onTokenClick: (route: 'from-token' | 'to-token') => void;
68
- connectedWallets: ConnectedWallet[];
69
- highFee: boolean;
70
- errorMessage: string;
71
- hasLimitError: (bestRoute: BestRouteResponse | null) => boolean;
72
- swap: SwapResult | null;
73
- swapFromAmount: string | null;
74
- fromAmountRangeError: string;
75
- recommendation: string;
76
- totalFeeInUsd: string;
77
- swithFromAndToComponent: React.ReactNode;
78
- percentageChange: string;
79
- tokenBalanceReal: string;
80
- tokenBalance: string;
81
- totalTime: string;
82
- bestRouteData: BestRouteResponse | null;
83
- showPercentageChange: boolean;
84
- }
85
-
86
- export function HomePanel({
87
- bestRoute,
88
- bestRouteError,
89
- fetchBestRoute,
90
- onClickHistory,
91
- onClickSettings,
92
- fromChain,
93
- toChain,
94
- fromToken,
95
- toToken,
96
- setInputAmount,
97
- outputAmount,
98
- inputAmount,
99
- loadingStatus,
100
- showBestRoute,
101
- fetchingBestRoute,
102
- outputUsdValue,
103
- inputUsdValue,
104
- swapButtonTitle,
105
- swapButtonDisabled,
106
- swapButtonClick,
107
- onChainClick,
108
- onTokenClick,
109
- connectedWallets,
110
- highFee,
111
- errorMessage,
112
- hasLimitError,
113
- swap,
114
- fromAmountRangeError,
115
- recommendation,
116
- totalFeeInUsd,
117
- swithFromAndToComponent,
118
- percentageChange,
119
- tokenBalanceReal,
120
- tokenBalance,
121
- totalTime,
122
- bestRouteData,
123
- swapFromAmount,
124
- showPercentageChange,
125
- }: HomePanelProps) {
126
- return (
127
- <Container>
128
- <Header
129
- title={i18n.t('SWAP')}
130
- suffix={
131
- <HeaderButtons
132
- onClickRefresh={
133
- !!bestRoute || bestRouteError ? fetchBestRoute : undefined
134
- }
135
- onClickHistory={onClickHistory}
136
- onClickSettings={onClickSettings}
137
- />
138
- }
139
- />
140
- <FromContainer>
141
- <>
142
- <TokenInfo
143
- type="From"
144
- chain={fromChain}
145
- token={fromToken}
146
- onAmountChange={setInputAmount}
147
- inputAmount={inputAmount}
148
- fromChain={fromChain}
149
- toChain={toChain}
150
- loadingStatus={loadingStatus}
151
- inputUsdValue={inputUsdValue}
152
- fromToken={fromToken}
153
- setInputAmount={setInputAmount}
154
- connectedWallets={connectedWallets}
155
- bestRoute={bestRoute}
156
- fetchingBestRoute={fetchingBestRoute}
157
- onChainClick={() => onChainClick('from-chain')}
158
- onTokenClick={() => onTokenClick('from-token')}
159
- tokenBalanceReal={tokenBalanceReal}
160
- tokenBalance={tokenBalance}
161
- />
162
- {swithFromAndToComponent}
163
- </>
164
- </FromContainer>
165
- <TokenInfo
166
- type="To"
167
- chain={toChain}
168
- token={toToken}
169
- outputAmount={outputAmount}
170
- percentageChange={percentageChange}
171
- outputUsdValue={outputUsdValue}
172
- fromChain={fromChain}
173
- toChain={toChain}
174
- loadingStatus={loadingStatus}
175
- inputUsdValue={inputUsdValue}
176
- fromToken={fromToken}
177
- setInputAmount={setInputAmount}
178
- connectedWallets={connectedWallets}
179
- inputAmount={inputAmount}
180
- bestRoute={bestRoute}
181
- fetchingBestRoute={fetchingBestRoute}
182
- onChainClick={() => onChainClick('to-chain')}
183
- onTokenClick={() => onTokenClick('to-token')}
184
- tokenBalanceReal={tokenBalanceReal}
185
- tokenBalance={tokenBalance}
186
- showPercentageChange={showPercentageChange}
187
- />
188
- {showBestRoute && (
189
- <BestRouteContainer>
190
- <BestRoute
191
- error={bestRouteError}
192
- loading={fetchingBestRoute}
193
- data={bestRouteData}
194
- totalFee={totalFeeInUsd}
195
- feeWarning={highFee}
196
- totalTime={totalTime}
197
- />
198
- </BestRouteContainer>
199
- )}
200
- {(errorMessage || hasLimitError(bestRoute)) && (
201
- <Alerts>
202
- {errorMessage && <Alert type="error">{errorMessage}</Alert>}
203
- {hasLimitError(bestRoute) && (
204
- <Alert type="error" title={`${swap?.swapperId} Limit`}>
205
- <>
206
- <Typography variant="body2">
207
- {`${fromAmountRangeError}, Yours: ${swapFromAmount} ${swap?.from.symbol}`}
208
- </Typography>
209
- <Typography variant="body2">{recommendation}</Typography>
210
- </>
211
- </Alert>
212
- )}
213
- </Alerts>
214
- )}
215
- <Footer>
216
- <Button
217
- type="primary"
218
- align="grow"
219
- size="large"
220
- disabled={swapButtonDisabled}
221
- onClick={swapButtonClick}>
222
- {swapButtonTitle}
223
- </Button>
224
- <BottomLogo />
225
- </Footer>
226
- </Container>
227
- );
228
- }
@@ -1 +0,0 @@
1
- export { HomePanel } from './HomePanel';