@rango-dev/ui 0.22.1-next.2 → 0.22.1-next.21

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 (148) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/index.js.map +4 -4
  3. package/dist/translations/en.d.ts.map +1 -1
  4. package/dist/translations/es.d.ts.map +1 -1
  5. package/dist/translations/fr.d.ts.map +1 -1
  6. package/dist/translations/ja.d.ts.map +1 -1
  7. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +157 -0
  8. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
  9. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +1 -1
  10. package/dist/widget/ui/src/components/Button/Button.d.ts +54 -54
  11. package/dist/widget/ui/src/components/Button/Button.styles.d.ts.map +1 -1
  12. package/dist/widget/ui/src/components/Checkbox/Checkbox.styles.d.ts.map +1 -1
  13. package/dist/widget/ui/src/components/ListItem/ListItem.styles.d.ts.map +1 -1
  14. package/dist/widget/ui/src/components/ListItemButton/ListItemButton.styles.d.ts.map +1 -1
  15. package/dist/widget/ui/src/components/PriceImpact/PriceImpact.styles.d.ts +158 -0
  16. package/dist/widget/ui/src/components/PriceImpact/PriceImpact.styles.d.ts.map +1 -1
  17. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.d.ts.map +1 -1
  18. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.styles.d.ts +314 -0
  19. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.styles.d.ts.map +1 -1
  20. package/dist/widget/ui/src/components/Radio/Radio.styles.d.ts.map +1 -1
  21. package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts.map +1 -1
  22. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +1 -1
  23. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +16 -2
  24. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +1 -1
  25. package/dist/widget/ui/src/components/SelectableCategoryList/index.d.ts +1 -0
  26. package/dist/widget/ui/src/components/SelectableCategoryList/index.d.ts.map +1 -1
  27. package/dist/widget/ui/src/components/Skeleton/Skeleton.d.ts.map +1 -1
  28. package/dist/widget/ui/src/components/Skeleton/Skeleton.types.d.ts +1 -1
  29. package/dist/widget/ui/src/components/Skeleton/Skeleton.types.d.ts.map +1 -1
  30. package/dist/widget/ui/src/components/StepDetails/StepDetails.d.ts.map +1 -1
  31. package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts +6 -0
  32. package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts.map +1 -1
  33. package/dist/widget/ui/src/components/SwapListItem/mock.d.ts +1 -1
  34. package/dist/widget/ui/src/components/SwapListItem/mock.d.ts.map +1 -1
  35. package/dist/widget/ui/src/components/Switch/Switch.styles.d.ts.map +1 -1
  36. package/dist/widget/ui/src/components/TextField/TextField.d.ts.map +1 -1
  37. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.d.ts.map +1 -1
  38. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts +471 -1
  39. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts.map +1 -1
  40. package/dist/widget/ui/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  41. package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts +2 -2
  42. package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts.map +1 -1
  43. package/dist/widget/ui/src/components/Wallet/Wallet.types.d.ts +3 -17
  44. package/dist/widget/ui/src/components/Wallet/Wallet.types.d.ts.map +1 -1
  45. package/dist/widget/ui/src/components/common/Image.d.ts +157 -0
  46. package/dist/widget/ui/src/components/common/Image.d.ts.map +1 -1
  47. package/dist/widget/ui/src/components/common/index.d.ts +1 -1
  48. package/dist/widget/ui/src/components/common/index.d.ts.map +1 -1
  49. package/dist/widget/ui/src/containers/BlockchainSelector/BlockchainSelector.d.ts +3 -3
  50. package/dist/widget/ui/src/containers/BlockchainSelector/BlockchainSelector.d.ts.map +1 -1
  51. package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.d.ts +1 -1
  52. package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.d.ts.map +1 -1
  53. package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.stories.d.ts +2 -2
  54. package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.stories.d.ts.map +1 -1
  55. package/dist/widget/ui/src/containers/SwapHistory/mock.d.ts +1 -1
  56. package/dist/widget/ui/src/containers/SwapHistory/mock.d.ts.map +1 -1
  57. package/dist/widget/ui/src/containers/SwapInput/SwapInput.d.ts.map +1 -1
  58. package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +1313 -54
  59. package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts.map +1 -1
  60. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts +2 -0
  61. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts.map +1 -1
  62. package/dist/widget/ui/src/containers/SwapInput/TokenSection.d.ts.map +1 -1
  63. package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +525 -54
  64. package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts.map +1 -1
  65. package/dist/widget/ui/src/containers/TokenSelector/TokenSelector.d.ts +2 -2
  66. package/dist/widget/ui/src/containers/TokenSelector/TokenSelector.d.ts.map +1 -1
  67. package/dist/widget/ui/src/icons/CosmosCategory.d.ts +5 -0
  68. package/dist/widget/ui/src/icons/CosmosCategory.d.ts.map +1 -0
  69. package/dist/widget/ui/src/icons/EvmCategory.d.ts +5 -0
  70. package/dist/widget/ui/src/icons/EvmCategory.d.ts.map +1 -0
  71. package/dist/widget/ui/src/icons/Icons.stories.d.ts +1 -1
  72. package/dist/widget/ui/src/icons/Language.d.ts +5 -0
  73. package/dist/widget/ui/src/icons/Language.d.ts.map +1 -0
  74. package/dist/widget/ui/src/icons/OtherCategory.d.ts +5 -0
  75. package/dist/widget/ui/src/icons/OtherCategory.d.ts.map +1 -0
  76. package/dist/widget/ui/src/icons/UtxoCategory.d.ts +5 -0
  77. package/dist/widget/ui/src/icons/UtxoCategory.d.ts.map +1 -0
  78. package/dist/widget/ui/src/icons/index.d.ts +5 -0
  79. package/dist/widget/ui/src/icons/index.d.ts.map +1 -1
  80. package/dist/widget/ui/src/index.d.ts +0 -1
  81. package/dist/widget/ui/src/index.d.ts.map +1 -1
  82. package/dist/widget/ui/src/types/index.d.ts +0 -1
  83. package/dist/widget/ui/src/types/index.d.ts.map +1 -1
  84. package/dist/widget/ui/src/types/swaps.d.ts +1 -27
  85. package/dist/widget/ui/src/types/swaps.d.ts.map +1 -1
  86. package/dist/widget/ui/src/{helper → utils}/index.d.ts +0 -3
  87. package/dist/widget/ui/src/utils/index.d.ts.map +1 -0
  88. package/package.json +6 -5
  89. package/src/components/Alert/Alert.styles.ts +9 -12
  90. package/src/components/Alert/Alert.tsx +2 -2
  91. package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +2 -1
  92. package/src/components/Button/Button.styles.tsx +1 -0
  93. package/src/components/Checkbox/Checkbox.styles.ts +5 -1
  94. package/src/components/ListItem/ListItem.styles.ts +9 -0
  95. package/src/components/ListItem/ListItem.tsx +1 -1
  96. package/src/components/ListItemButton/ListItemButton.styles.ts +1 -0
  97. package/src/components/PriceImpact/PriceImpact.styles.ts +9 -1
  98. package/src/components/PriceImpact/PriceImpact.tsx +3 -3
  99. package/src/components/QuoteCost/QuoteCost.styles.ts +14 -12
  100. package/src/components/QuoteCost/QuoteCost.tsx +12 -7
  101. package/src/components/Radio/Radio.styles.tsx +5 -2
  102. package/src/components/RoutesOverview/RoutesOverview.tsx +6 -2
  103. package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +40 -13
  104. package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +47 -46
  105. package/src/components/SelectableCategoryList/index.ts +1 -0
  106. package/src/components/SelectableWalletList/SelectableWalletList.tsx +1 -1
  107. package/src/components/Skeleton/Skeleton.tsx +3 -2
  108. package/src/components/Skeleton/Skeleton.types.ts +1 -1
  109. package/src/components/StepDetails/StepDetails.styles.ts +34 -26
  110. package/src/components/StepDetails/StepDetails.tsx +8 -4
  111. package/src/components/SvgIcon/SvgIcon.style.ts +1 -1
  112. package/src/components/SwapListItem/mock.ts +21 -6
  113. package/src/components/Switch/Switch.styles.tsx +8 -6
  114. package/src/components/TextField/TextField.tsx +3 -5
  115. package/src/components/TokenAmount/TokenAmount.styles.ts +12 -10
  116. package/src/components/TokenAmount/TokenAmount.tsx +23 -17
  117. package/src/components/Tooltip/Tooltip.styles.ts +8 -5
  118. package/src/components/Tooltip/Tooltip.tsx +2 -3
  119. package/src/components/Wallet/Wallet.styles.ts +1 -1
  120. package/src/components/Wallet/Wallet.types.ts +3 -23
  121. package/src/components/common/Image.tsx +1 -2
  122. package/src/components/common/index.ts +1 -1
  123. package/src/containers/BlockchainSelector/BlockchainSelector.tsx +9 -8
  124. package/src/containers/SwapHistory/SwapHistory.stories.tsx +5 -2
  125. package/src/containers/SwapHistory/SwapHistory.tsx +1 -1
  126. package/src/containers/SwapHistory/mock.ts +24 -8
  127. package/src/containers/SwapInput/SwapInput.styles.ts +78 -27
  128. package/src/containers/SwapInput/SwapInput.tsx +37 -29
  129. package/src/containers/SwapInput/SwapInput.types.ts +2 -0
  130. package/src/containers/SwapInput/TokenSection.styles.ts +27 -12
  131. package/src/containers/SwapInput/TokenSection.tsx +15 -6
  132. package/src/containers/TokenSelector/TokenSelector.tsx +8 -10
  133. package/src/icons/CosmosCategory.tsx +137 -0
  134. package/src/icons/EvmCategory.tsx +74 -0
  135. package/src/icons/Language.tsx +55 -0
  136. package/src/icons/OtherCategory.tsx +72 -0
  137. package/src/icons/UtxoCategory.tsx +44 -0
  138. package/src/icons/index.ts +5 -0
  139. package/src/index.ts +0 -1
  140. package/src/theme.ts +4 -4
  141. package/src/types/index.ts +0 -1
  142. package/src/types/swaps.ts +0 -38
  143. package/src/utils/index.ts +23 -0
  144. package/dist/widget/ui/src/containers/History/types.d.ts +0 -2
  145. package/dist/widget/ui/src/containers/History/types.d.ts.map +0 -1
  146. package/dist/widget/ui/src/helper/index.d.ts.map +0 -1
  147. package/src/containers/History/types.tsx +0 -1
  148. package/src/helper/index.ts +0 -99
@@ -1,14 +1,16 @@
1
+ import type { LoadingStatus } from '../../types/meta';
2
+ import type { CSSProperties } from '@stitches/react';
3
+ import type { BlockchainMeta } from 'rango-sdk';
4
+
1
5
  import React from 'react';
2
- import { BlockchainMeta } from 'rango-sdk';
6
+
7
+ import { LoadingFailedAlert } from '../../components/Alert/LoadingFailedAlert';
8
+ import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
3
9
  import { BlockchainsList } from '../../components/BlockchainsList';
4
10
  import { SecondaryPage } from '../../components/SecondaryPage/SecondaryPage';
5
11
  import { Spinner } from '../../components/Spinner';
6
12
  import { styled } from '../../theme';
7
- import { CSSProperties } from '@stitches/react';
8
- import { containsText } from '../../helper';
9
- import { LoadingStatus } from '../../types/meta';
10
- import { LoadingFailedAlert } from '../../components/Alert/LoadingFailedAlert';
11
- import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
13
+ import { containsText } from '../../utils';
12
14
  import { LoaderContainer } from '../TokenSelector/TokenSelector';
13
15
 
14
16
  const ListContainer = styled('div', {
@@ -56,8 +58,7 @@ export function BlockchainSelector(props: PropTypes) {
56
58
  hasHeader={hasHeader}
57
59
  textFieldPlaceholder="Search blockchains by name"
58
60
  title={`Select ${type} Blockchain`}
59
- onBack={onBack}
60
- >
61
+ onBack={onBack}>
61
62
  {(searchedFor) => {
62
63
  const filteredBlockchains = filterBlockchains(list, searchedFor);
63
64
  return (
@@ -1,7 +1,10 @@
1
+ import type { PropTypes } from './SwapHistory';
2
+ import type { Meta } from '@storybook/react';
3
+
1
4
  import React from 'react';
2
- import { Meta } from '@storybook/react';
3
- import { PropTypes, SwapHistory } from './SwapHistory';
5
+
4
6
  import { pendingSwap } from './mock';
7
+ import { SwapHistory } from './SwapHistory';
5
8
 
6
9
  export default {
7
10
  title: 'Containers/Swap History',
@@ -1,5 +1,5 @@
1
1
  import type { PropTypes as SwapMessagesPropTypes } from './SwapMessages';
2
- import type { PendingSwap } from '../History/types';
2
+ import type { PendingSwap } from 'rango-types';
3
3
 
4
4
  import React, { useState } from 'react';
5
5
 
@@ -1,6 +1,8 @@
1
- // @ts-nocheck
1
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2
+ import type { PendingSwap } from 'rango-types';
3
+
2
4
  import { RoutingResultType, TransactionType } from 'rango-sdk';
3
- import { PendingSwap } from '../History/types';
5
+ import { MessageSeverity } from 'rango-types';
4
6
 
5
7
  export const pendingSwap: PendingSwap = {
6
8
  creationTime: '1673164511955',
@@ -16,7 +18,7 @@ export const pendingSwap: PendingSwap = {
16
18
  status: 'running',
17
19
  isPaused: false,
18
20
  extraMessage: null,
19
- extraMessageSeverity: 'info',
21
+ extraMessageSeverity: MessageSeverity.info,
20
22
  extraMessageDetail: '',
21
23
  extraMessageErrorCode: null,
22
24
  networkStatusExtraMessage: null,
@@ -34,14 +36,14 @@ export const pendingSwap: PendingSwap = {
34
36
  {
35
37
  swapperId: 'Osmosis',
36
38
  swapperType: 'DEX',
37
- swapperLogo: 'https://api.rango.exchange/swappers/osmosis.png',
39
+ swapperLogo: '',
38
40
  from: {
39
41
  symbol: 'JUNO',
40
42
  logo: 'https://api.rango.exchange/tokens/COSMOS/JUNO.png',
41
43
  address:
42
44
  'ibc/46b44899322f3cd854d2d46deef881958467cdd4b3b10086da49296bbed94bed',
43
45
  blockchain: 'OSMOSIS',
44
- blockchainLogo: '',
46
+ blockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
45
47
  decimals: 6,
46
48
  usdPrice: 1.1091996179668873,
47
49
  },
@@ -51,7 +53,7 @@ export const pendingSwap: PendingSwap = {
51
53
  address: null,
52
54
  blockchain: 'OSMOSIS',
53
55
  decimals: 6,
54
- blockchainLogo: '',
56
+ blockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
55
57
  usdPrice: 0.7192435454440882,
56
58
  },
57
59
  fromAmount: '1.000000',
@@ -68,8 +70,9 @@ export const pendingSwap: PendingSwap = {
68
70
  address: null,
69
71
  },
70
72
  expenseType: 'FROM_SOURCE_WALLET',
71
- amount: '0',
72
73
  name: 'Network Fee',
74
+ amount: '0',
75
+ price: null,
73
76
  },
74
77
  ],
75
78
  estimatedTimeInSeconds: 45,
@@ -145,6 +148,7 @@ export const pendingSwap: PendingSwap = {
145
148
  includesDestinationTx: false,
146
149
  maxRequiredSign: 1,
147
150
  warnings: [],
151
+ internalSwaps: null,
148
152
  },
149
153
  ],
150
154
  },
@@ -154,21 +158,25 @@ export const pendingSwap: PendingSwap = {
154
158
  id: 1,
155
159
  fromBlockchain: 'OSMOSIS',
156
160
  fromSymbol: 'JUNO',
161
+ swapperType: 'test',
157
162
  fromSymbolAddress:
158
163
  'ibc/46b44899322f3cd854d2d46deef881958467cdd4b3b10086da49296bbed94bed',
159
164
  fromDecimals: 6,
160
165
  fromAmountPrecision: null,
166
+ fromAmountRestrictionType: 'EXCLUSIVE',
167
+ estimatedTimeInSeconds: 5,
161
168
  fromAmountMinValue: null,
162
169
  fromAmountMaxValue: null,
170
+ fromUsdPrice: null,
163
171
  toBlockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
164
172
  fromBlockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
165
173
  toBlockchain: 'OSMOSIS',
166
174
  fromLogo: 'https://api.rango.exchange/tokens/COSMOS/JUNO.png',
167
175
  toSymbol: 'OSMO',
168
176
  toSymbolAddress: null,
169
- swapperType: 'DEX',
170
177
  toDecimals: 6,
171
178
  toLogo: 'https://api.rango.exchange/i/mJQPS2',
179
+ toUsdPrice: null,
172
180
  startTransactionTime: 1673164519916,
173
181
  swapperId: 'Osmosis',
174
182
  swapperLogo: 'https://api.rango.exchange/swappers/osmosis.png',
@@ -184,6 +192,13 @@ export const pendingSwap: PendingSwap = {
184
192
  description: null,
185
193
  },
186
194
  ],
195
+ starknetApprovalTransaction: null,
196
+ starknetTransaction: null,
197
+ tronApprovalTransaction: null,
198
+ tonTransaction: null,
199
+ tronTransaction: null,
200
+ feeInUsd: null,
201
+ executedTransactionTime: null,
187
202
  cosmosTransaction: {
188
203
  type: TransactionType.COSMOS,
189
204
  fromWalletAddress: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
@@ -271,6 +286,7 @@ export const pendingSwap: PendingSwap = {
271
286
  transferTransaction: null,
272
287
  diagnosisUrl: null,
273
288
  internalSteps: null,
289
+ internalSwaps: null,
274
290
  },
275
291
  ],
276
292
  };
@@ -1,5 +1,7 @@
1
- import { Button, TextField } from '../../components';
2
- import { darkTheme, styled } from '../../theme';
1
+ import { Button, TextField, Typography } from '../../components';
2
+ import { css, darkTheme, styled } from '../../theme';
3
+
4
+ export const textStyles = css();
3
5
 
4
6
  export const Container = styled('div', {
5
7
  $$color: '$colors$neutral100',
@@ -17,40 +19,22 @@ export const Container = styled('div', {
17
19
  },
18
20
  },
19
21
  },
20
- '& .label__container': {
21
- paddingBottom: '$5',
22
- },
23
- '& .label': {
24
- display: 'flex',
25
- justifyContent: 'space-between',
26
- alignItems: 'center',
27
- },
28
- '& .balance': {
29
- display: 'flex',
30
- justifyContent: 'center',
31
- alignItems: 'center',
32
- },
33
- '& .form': {
34
- display: 'flex',
35
- justifyContent: 'space-between',
36
- alignItems: 'center',
37
- },
38
- '& .amount': {
39
- display: 'flex',
40
- flexDirection: 'column',
41
- justifyContent: 'center',
42
- alignItems: 'end',
43
- flexGrow: 1,
22
+ [`& .${textStyles}`]: {
23
+ $$color: '$colors$neutral600',
24
+ [`.${darkTheme} &`]: {
25
+ $$color: '$colors$neutral700',
26
+ },
27
+ color: '$$color',
44
28
  },
45
29
  });
46
30
 
47
31
  export const InputAmount = styled(TextField, {
32
+ width: '100%',
48
33
  padding: '0',
49
34
  fontSize: '$18',
50
35
  lineHeight: '$26',
51
36
  fontWeight: '$medium',
52
37
  textAlign: 'right',
53
- width: 140,
54
38
  '&:disabled': {
55
39
  cursor: 'unset',
56
40
  },
@@ -62,3 +46,70 @@ export const MaxButton = styled(Button, {
62
46
  },
63
47
  backgroundColor: '$$color',
64
48
  });
49
+
50
+ export const ValueTypography = styled('div', {
51
+ display: 'flex',
52
+ width: '100%',
53
+ textAlign: 'right',
54
+ whiteSpace: 'nowrap',
55
+ overflow: 'hidden',
56
+ textOverflow: 'ellipsis',
57
+ variants: {
58
+ hasWarning: {
59
+ true: {
60
+ '& ._typography': {
61
+ color: '$warning500',
62
+ },
63
+ },
64
+ false: {
65
+ '& ._typography': {
66
+ $$color: '$colors$neutral600',
67
+ [`.${darkTheme} &`]: {
68
+ $$color: '$colors$neutral700',
69
+ },
70
+ color: '$$color',
71
+ },
72
+ },
73
+ },
74
+ },
75
+ });
76
+
77
+ export const formStyles = css({
78
+ display: 'flex',
79
+ justifyContent: 'space-between',
80
+ alignItems: 'center',
81
+ });
82
+
83
+ export const labelStyles = css({
84
+ display: 'flex',
85
+ justifyContent: 'space-between',
86
+ alignItems: 'center',
87
+ });
88
+
89
+ export const balanceStyles = css({
90
+ display: 'flex',
91
+ justifyContent: 'center',
92
+ alignItems: 'center',
93
+ });
94
+
95
+ export const amountStyles = css({
96
+ width: '45%',
97
+ maxWidth: '170px',
98
+ display: 'flex',
99
+ flexDirection: 'column',
100
+ justifyContent: 'center',
101
+ alignItems: 'end',
102
+ flexGrow: 1,
103
+ });
104
+
105
+ export const labelContainerStyles = css({
106
+ paddingBottom: '$5',
107
+ });
108
+
109
+ export const UsdPrice = styled(Typography, {
110
+ width: '100%',
111
+ textAlign: 'right',
112
+ whiteSpace: 'nowrap',
113
+ overflow: 'hidden',
114
+ textOverflow: 'ellipsis',
115
+ });
@@ -5,21 +5,37 @@ import React from 'react';
5
5
 
6
6
  import { Divider, PriceImpact, Skeleton, Typography } from '../../components';
7
7
 
8
- import { Container, InputAmount, MaxButton } from './SwapInput.styles';
8
+ import {
9
+ amountStyles,
10
+ balanceStyles,
11
+ Container,
12
+ formStyles,
13
+ InputAmount,
14
+ labelContainerStyles,
15
+ labelStyles,
16
+ MaxButton,
17
+ textStyles,
18
+ UsdPrice,
19
+ ValueTypography,
20
+ } from './SwapInput.styles';
9
21
  import { TokenSection } from './TokenSection';
10
22
 
11
23
  export function SwapInput(props: SwapInputProps) {
24
+ const showBalance =
25
+ 'balance' in props && !props.loading && !props.loadingBalance;
26
+ const showBalanceSkeleton =
27
+ 'balance' in props && (props.loading || props.loadingBalance);
12
28
  return (
13
29
  <Container sharpBottomStyle={props.sharpBottomStyle}>
14
- <div className="label__container">
15
- <div className="label">
16
- <Typography variant="body" size="small" color="$neutral600">
30
+ <div className={labelContainerStyles()}>
31
+ <div className={labelStyles()}>
32
+ <Typography variant="body" size="small" className={textStyles()}>
17
33
  {props.label}
18
34
  </Typography>
19
- {'balance' in props && !props.loading && (
20
- <div className="balance">
35
+ {showBalance && (
36
+ <div className={balanceStyles()}>
21
37
  <Typography
22
- color="$neutral600"
38
+ className={textStyles()}
23
39
  mr={4}
24
40
  variant="body"
25
41
  size="xsmall">
@@ -35,14 +51,14 @@ export function SwapInput(props: SwapInputProps) {
35
51
  </MaxButton>
36
52
  </div>
37
53
  )}
38
- {props.loading && (
39
- <div className="balance">
54
+ {showBalanceSkeleton && (
55
+ <div className={balanceStyles()}>
40
56
  <Skeleton variant="text" size="large" width={105} />
41
57
  </div>
42
58
  )}
43
59
  </div>
44
60
  </div>
45
- <div className="form">
61
+ <div className={formStyles()}>
46
62
  <TokenSection
47
63
  chain={props.chain.displayName}
48
64
  tokenSymbol={props.token.displayName}
@@ -52,12 +68,12 @@ export function SwapInput(props: SwapInputProps) {
52
68
  onClick={props.onClickToken}
53
69
  loading={props.loading}
54
70
  />
55
- <div className="amount">
56
- {props.loading ? (
71
+ <div className={amountStyles()}>
72
+ {props.loading || (props.mode === 'To' && props.fetchingQuote) ? (
57
73
  <>
58
- <Skeleton variant="text" size="large" width={92} />
74
+ <Skeleton variant="text" size="large" />
59
75
  <Divider size={8} />
60
- <Skeleton variant="text" size="medium" width={92} />
76
+ <Skeleton variant="text" size="medium" />
61
77
  </>
62
78
  ) : (
63
79
  <>
@@ -84,21 +100,13 @@ export function SwapInput(props: SwapInputProps) {
84
100
  warningLevel={props.warningLevel}
85
101
  />
86
102
  ) : (
87
- <Typography
88
- variant="body"
89
- size="medium"
90
- color={!props.price.error ? '$neutral600' : '$warning500'}
91
- style={{
92
- width: 140,
93
- textAlign: 'right',
94
- whiteSpace: 'nowrap',
95
- overflow: 'hidden',
96
- textOverflow: 'ellipsis',
97
- }}>
98
- {props.price.usdValue
99
- ? `~$${props.price.usdValue}`
100
- : props.price.error}
101
- </Typography>
103
+ <ValueTypography hasWarning={!!props.price.error}>
104
+ <UsdPrice variant="body" size="medium">
105
+ {props.price.usdValue
106
+ ? `~$${props.price.usdValue}`
107
+ : props.price.error}
108
+ </UsdPrice>
109
+ </ValueTypography>
102
110
  )}
103
111
  </>
104
112
  )}
@@ -25,12 +25,14 @@ export type BaseProps = {
25
25
  type FromProps = {
26
26
  mode: 'From';
27
27
  balance?: string;
28
+ loadingBalance: boolean;
28
29
  onSelectMaxBalance: () => void;
29
30
  onInputChange: (inputAmount: string) => void;
30
31
  };
31
32
 
32
33
  type ToProps = {
33
34
  mode: 'To';
35
+ fetchingQuote?: boolean;
34
36
  percentageChange: string | null;
35
37
  warningLevel: PriceImpactWarningLevel;
36
38
  };
@@ -1,7 +1,10 @@
1
1
  import { Button } from '../../components';
2
- import { darkTheme, styled } from '../../theme';
2
+ import { css, darkTheme, styled } from '../../theme';
3
3
 
4
4
  export const Container = styled(Button, {
5
+ maxWidth: '180px',
6
+ minWidth: '130px',
7
+ flexGrow: 1,
5
8
  backgroundColor: 'transparent',
6
9
  color: '$neutral700',
7
10
  '&:disabled': {
@@ -27,23 +30,35 @@ export const Container = styled(Button, {
27
30
  },
28
31
  });
29
32
 
33
+ export const chainNameStyles = css();
34
+
30
35
  export const TokenSectionContainer = styled('div', {
31
- width: '10.625rem',
36
+ maxWidth: '170px',
32
37
  padding: '$2 $5',
33
38
  display: 'flex',
34
39
  borderRadius: '$xs',
35
40
  justifyContent: 'start',
36
41
  boxSizing: 'border-box',
37
42
  alignItems: 'center',
38
-
39
- '& .token-chain-name': {
40
- display: 'flex',
41
- flexDirection: 'column',
42
- justifyContent: 'center',
43
- alignItems: 'start',
44
- paddingLeft: '$10',
45
- },
46
- '& .token-chain-name__skeleton': {
47
- padding: '$5 $0',
43
+ [`& .${chainNameStyles}`]: {
44
+ $$color: '$colors$neutral600',
45
+ [`.${darkTheme} &`]: {
46
+ $$color: '$colors$neutral700',
47
+ },
48
+ color: '$$color',
48
49
  },
49
50
  });
51
+
52
+ export const tokenChainStyles = css({
53
+ display: 'flex',
54
+ flexDirection: 'column',
55
+ justifyContent: 'center',
56
+ alignItems: 'start',
57
+ paddingLeft: '$10',
58
+ flexGrow: 1,
59
+ });
60
+
61
+ export const skeletonStyles = css({
62
+ width: '100%',
63
+ padding: '$5 $0',
64
+ });
@@ -5,7 +5,13 @@ import React from 'react';
5
5
 
6
6
  import { ChainToken, Divider, Skeleton, Typography } from '../../components';
7
7
 
8
- import { Container, TokenSectionContainer } from './TokenSection.styles';
8
+ import {
9
+ chainNameStyles,
10
+ Container,
11
+ skeletonStyles,
12
+ tokenChainStyles,
13
+ TokenSectionContainer,
14
+ } from './TokenSection.styles';
9
15
 
10
16
  export function TokenSection(props: TokenSectionProps) {
11
17
  const {
@@ -27,12 +33,12 @@ export function TokenSection(props: TokenSectionProps) {
27
33
  tokenImage={tokenImage}
28
34
  loading={loading}
29
35
  />
30
- <div className="token-chain-name">
36
+ <div className={tokenChainStyles()}>
31
37
  {loading ? (
32
- <div className="token-chain-name__skeleton">
33
- <Skeleton variant="text" size="large" width={92} />
38
+ <div className={skeletonStyles()}>
39
+ <Skeleton variant="text" size="large" />
34
40
  <Divider size={8} />
35
- <Skeleton variant="text" size="medium" width={92} />
41
+ <Skeleton variant="text" size="medium" />
36
42
  </div>
37
43
  ) : (
38
44
  <>
@@ -41,7 +47,10 @@ export function TokenSection(props: TokenSectionProps) {
41
47
  ? i18n.t('Token')
42
48
  : tokenSymbol}
43
49
  </Typography>
44
- <Typography variant="body" size="medium" color="$neutral600">
50
+ <Typography
51
+ variant="body"
52
+ size="medium"
53
+ className={chainNameStyles()}>
45
54
  {error || (!loading && !chain) ? i18n.t('Chain') : chain}
46
55
  </Typography>
47
56
  </>
@@ -1,14 +1,13 @@
1
+ import type { TokenWithAmount } from '../../components/TokenList/TokenList';
2
+ import type { LoadingStatus } from '../../types/meta';
3
+
1
4
  import React from 'react';
2
- import { containsText } from '../../helper';
3
5
 
4
- import { LoadingStatus } from '../../types/meta';
5
- import { styled } from '../../theme';
6
- import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
7
6
  import { LoadingFailedAlert, SecondaryPage, Spinner } from '../../components';
8
- import {
9
- TokenList,
10
- TokenWithAmount,
11
- } from '../../components/TokenList/TokenList';
7
+ import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
8
+ import { TokenList } from '../../components/TokenList/TokenList';
9
+ import { styled } from '../../theme';
10
+ import { containsText } from '../../utils';
12
11
 
13
12
  export const LoaderContainer = styled('div', {
14
13
  display: 'flex',
@@ -45,8 +44,7 @@ export function TokenSelector(props: PropTypes) {
45
44
  hasHeader={hasHeader}
46
45
  title={`Select ${type} token`}
47
46
  onBack={onBack}
48
- textFieldPlaceholder="Search tokens by name"
49
- >
47
+ textFieldPlaceholder="Search tokens by name">
50
48
  {(searchedFor) => {
51
49
  const filteredTokens = filterTokens(list, searchedFor);
52
50