@rango-dev/ui 0.53.1-next.3 → 0.53.1-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/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/ui.build.json +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/FullExpandedQuote/FullExpandedQuote.TokenSection.d.ts.map +1 -1
- package/dist/widget/ui/src/components/FullExpandedQuote/FullExpandedQuote.d.ts.map +1 -1
- package/dist/widget/ui/src/components/FullExpandedQuote/FullExpandedQuote.styles.d.ts +213 -49
- package/dist/widget/ui/src/components/FullExpandedQuote/FullExpandedQuote.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.d.ts.map +1 -1
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.types.d.ts +2 -0
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.types.d.ts.map +1 -1
- package/dist/widget/ui/src/components/StepDetails/StepDetails.d.ts.map +1 -1
- package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts +324 -0
- package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SwapListItem/SwapToken.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SwapListItem/SwapToken.styles.d.ts +484 -0
- package/dist/widget/ui/src/components/SwapListItem/SwapToken.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +3 -2
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.d.ts.map +1 -1
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts +1285 -1
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts +3 -2
- package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts +3 -2
- package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Typography/Typography.d.ts +3 -2
- package/dist/widget/ui/src/components/Typography/Typography.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Wallet/Wallet.styles.d.ts +3 -2
- package/dist/widget/ui/src/components/Wallet/Wallet.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Wallet/index.d.ts +1 -1
- package/dist/widget/ui/src/components/Wallet/index.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +3 -2
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +169 -3
- package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/hooks/index.d.ts +1 -0
- package/dist/widget/ui/src/hooks/index.d.ts.map +1 -1
- package/dist/widget/ui/src/hooks/useIsTruncated.d.ts +3 -0
- package/dist/widget/ui/src/hooks/useIsTruncated.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/Alert/Alert.styles.ts +3 -0
- package/src/components/FullExpandedQuote/FullExpandedQuote.TokenSection.tsx +18 -5
- package/src/components/FullExpandedQuote/FullExpandedQuote.styles.ts +11 -3
- package/src/components/FullExpandedQuote/FullExpandedQuote.tsx +13 -3
- package/src/components/PriceImpact/PriceImpact.styles.ts +8 -3
- package/src/components/PriceImpact/PriceImpact.tsx +27 -17
- package/src/components/PriceImpact/PriceImpact.types.ts +2 -0
- package/src/components/StepDetails/StepDetails.styles.ts +15 -0
- package/src/components/StepDetails/StepDetails.tsx +33 -8
- package/src/components/SwapListItem/SwapToken.styles.ts +16 -1
- package/src/components/SwapListItem/SwapToken.tsx +97 -25
- package/src/components/Toast/Toast.styles.ts +2 -0
- package/src/components/TokenAmount/TokenAmount.styles.ts +60 -2
- package/src/components/TokenAmount/TokenAmount.tsx +98 -38
- package/src/components/Typography/Typography.tsx +15 -15
- package/src/components/Wallet/index.ts +4 -1
- package/src/containers/SwapInput/SwapInput.styles.ts +2 -1
- package/src/containers/SwapInput/SwapInput.tsx +18 -35
- package/src/containers/SwapInput/TokenSection.styles.ts +7 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useIsTruncated.tsx +27 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from '@stitches/react';
|
|
2
2
|
|
|
3
3
|
import { darkTheme, styled } from '../../theme.js';
|
|
4
|
+
import { Typography } from '../Typography/Typography.js';
|
|
4
5
|
|
|
5
6
|
export const Container = styled('div', {
|
|
6
7
|
width: '100%',
|
|
@@ -127,6 +128,20 @@ export const StepSeparator = styled('div', {
|
|
|
127
128
|
},
|
|
128
129
|
});
|
|
129
130
|
|
|
131
|
+
export const TokenNameText = styled(Typography, {
|
|
132
|
+
overflow: 'hidden',
|
|
133
|
+
textOverflow: 'ellipsis',
|
|
134
|
+
whiteSpace: 'nowrap',
|
|
135
|
+
maxWidth: '38px',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const ValueTypography = styled(Typography, {
|
|
139
|
+
overflow: 'hidden',
|
|
140
|
+
textOverflow: 'ellipsis',
|
|
141
|
+
whiteSpace: 'nowrap',
|
|
142
|
+
maxWidth: '60px',
|
|
143
|
+
});
|
|
144
|
+
|
|
130
145
|
export const tokensContainerStyles = css({
|
|
131
146
|
width: '100%',
|
|
132
147
|
overflow: 'hidden',
|
|
@@ -4,7 +4,7 @@ import { i18n } from '@lingui/core';
|
|
|
4
4
|
import React, { forwardRef, Fragment, memo, useEffect, useRef } from 'react';
|
|
5
5
|
|
|
6
6
|
import { ChainToken } from '../../components/ChainToken/index.js';
|
|
7
|
-
import { NextIcon } from '../../icons/index.js';
|
|
7
|
+
import { InfoIcon, NextIcon } from '../../icons/index.js';
|
|
8
8
|
import { Image } from '../common/index.js';
|
|
9
9
|
import { Divider } from '../Divider/index.js';
|
|
10
10
|
import { NumericTooltip } from '../Tooltip/index.js';
|
|
@@ -20,11 +20,14 @@ import {
|
|
|
20
20
|
swapperItemStyles,
|
|
21
21
|
SwapperSeparator,
|
|
22
22
|
swappersStyles,
|
|
23
|
+
TokenNameText,
|
|
23
24
|
tokensContainerStyles,
|
|
24
25
|
tokensStyles,
|
|
26
|
+
ValueTypography,
|
|
25
27
|
} from './StepDetails.styles.js';
|
|
26
28
|
|
|
27
29
|
const HIGHT_OF_STICKY_HEADER = 45;
|
|
30
|
+
const VALUE_LENGTH_THRESHOLD = 9;
|
|
28
31
|
|
|
29
32
|
const StepDetailsComponent = forwardRef<HTMLDivElement, StepDetailsProps>(
|
|
30
33
|
(props, parentRef) => {
|
|
@@ -149,11 +152,25 @@ const StepDetailsComponent = forwardRef<HTMLDivElement, StepDetailsProps>(
|
|
|
149
152
|
content={step.from.price.realValue}
|
|
150
153
|
container={tooltipContainer}>
|
|
151
154
|
<Divider direction="horizontal" size={4} />
|
|
152
|
-
<
|
|
155
|
+
<ValueTypography
|
|
153
156
|
size="small"
|
|
154
157
|
color="$neutral700"
|
|
155
|
-
variant="body">{`${step.from.price.
|
|
158
|
+
variant="body">{`${step.from.price.realValue}`}</ValueTypography>
|
|
159
|
+
|
|
160
|
+
{step.from.price.realValue &&
|
|
161
|
+
step.from.price.realValue.length > VALUE_LENGTH_THRESHOLD && (
|
|
162
|
+
<>
|
|
163
|
+
<Divider direction="horizontal" size={2} />
|
|
164
|
+
<InfoIcon size={12} color="gray" />
|
|
165
|
+
</>
|
|
166
|
+
)}
|
|
167
|
+
<Divider direction="horizontal" size={2} />
|
|
168
|
+
|
|
169
|
+
<TokenNameText size="small" color="$neutral700" variant="body">
|
|
170
|
+
{step.from.token.displayName}
|
|
171
|
+
</TokenNameText>
|
|
156
172
|
</NumericTooltip>
|
|
173
|
+
|
|
157
174
|
<Divider direction="horizontal" size={4} />
|
|
158
175
|
|
|
159
176
|
<NextIcon color="gray" />
|
|
@@ -168,11 +185,19 @@ const StepDetailsComponent = forwardRef<HTMLDivElement, StepDetailsProps>(
|
|
|
168
185
|
container={tooltipContainer}>
|
|
169
186
|
<Divider direction="horizontal" size={4} />
|
|
170
187
|
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
<ValueTypography
|
|
189
|
+
size="small"
|
|
190
|
+
color="$neutral700"
|
|
191
|
+
variant="body">{`${isCompleted ? '' : '~'}${
|
|
192
|
+
step.to.price.value
|
|
193
|
+
}`}</ValueTypography>
|
|
194
|
+
<Divider direction="horizontal" size={2} />
|
|
195
|
+
{step.to.price.value.length + (isCompleted ? 0 : 1) >
|
|
196
|
+
VALUE_LENGTH_THRESHOLD && <InfoIcon size={12} color="gray" />}
|
|
197
|
+
<Divider direction="horizontal" size={2} />
|
|
198
|
+
<TokenNameText size="small" color="$neutral700" variant="body">
|
|
199
|
+
{step.to.token.displayName}
|
|
200
|
+
</TokenNameText>
|
|
176
201
|
</NumericTooltip>
|
|
177
202
|
</div>
|
|
178
203
|
<Alerts pb={hasSeparator && type === 'quote-details'}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styled } from '../../theme.js';
|
|
2
|
+
import { Typography } from '../Typography/Typography.js';
|
|
2
3
|
|
|
3
4
|
export const TokenContainer = styled('div', {
|
|
4
5
|
display: 'flex',
|
|
@@ -61,9 +62,9 @@ export const LayoutLoading = styled('div', {
|
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
export const IconLoading = styled('div', {
|
|
64
|
-
display: 'flex',
|
|
65
65
|
width: '$24',
|
|
66
66
|
height: '$24',
|
|
67
|
+
display: 'flex',
|
|
67
68
|
justifyContent: 'center',
|
|
68
69
|
alignItems: 'center',
|
|
69
70
|
});
|
|
@@ -74,3 +75,17 @@ export const LoadingContainer = styled('div', {
|
|
|
74
75
|
alignItems: 'center',
|
|
75
76
|
gap: 25,
|
|
76
77
|
});
|
|
78
|
+
|
|
79
|
+
export const TokenNameText = styled(Typography, {
|
|
80
|
+
maxWidth: '97px',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const AmountText = styled(Typography, {
|
|
84
|
+
maxWidth: '$48',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const FlexCenteredContainer = styled('div', {
|
|
88
|
+
display: 'flex',
|
|
89
|
+
justifyContent: 'center',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
});
|
|
@@ -3,14 +3,17 @@ import type { PropTypes } from './SwapToken.types.js';
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
-
import { NextIcon } from '../../icons/index.js';
|
|
6
|
+
import { InfoIcon, NextIcon } from '../../icons/index.js';
|
|
7
7
|
import { ChainToken } from '../ChainToken/index.js';
|
|
8
8
|
import { Divider } from '../Divider/index.js';
|
|
9
9
|
import { Skeleton } from '../Skeleton/index.js';
|
|
10
|
-
import {
|
|
10
|
+
import { textTruncate } from '../TokenAmount/TokenAmount.styles.js';
|
|
11
|
+
import { NumericTooltip, Tooltip } from '../Tooltip/index.js';
|
|
11
12
|
import { Typography } from '../Typography/index.js';
|
|
12
13
|
|
|
13
14
|
import {
|
|
15
|
+
AmountText,
|
|
16
|
+
FlexCenteredContainer,
|
|
14
17
|
Icon,
|
|
15
18
|
IconLoading,
|
|
16
19
|
Images,
|
|
@@ -18,9 +21,13 @@ import {
|
|
|
18
21
|
LayoutLoading,
|
|
19
22
|
TokenContainer,
|
|
20
23
|
TokenInfo,
|
|
24
|
+
TokenNameText,
|
|
21
25
|
TopSection,
|
|
22
26
|
} from './SwapToken.styles.js';
|
|
23
27
|
|
|
28
|
+
const TOKEN_NAME_TOOLTIP_THRESHOLD = 10;
|
|
29
|
+
const TOKEN_AMOUNT_TOOLTIP_THRESHOLD = 6;
|
|
30
|
+
|
|
24
31
|
export function SwapToken(props: PropTypes) {
|
|
25
32
|
if ('isLoading' in props) {
|
|
26
33
|
return (
|
|
@@ -65,7 +72,6 @@ export function SwapToken(props: PropTypes) {
|
|
|
65
72
|
},
|
|
66
73
|
to: {
|
|
67
74
|
token: toToken,
|
|
68
|
-
amount: toAmount,
|
|
69
75
|
blockchain: toBlockchain,
|
|
70
76
|
realAmount: toRealAmount,
|
|
71
77
|
},
|
|
@@ -99,15 +105,35 @@ export function SwapToken(props: PropTypes) {
|
|
|
99
105
|
{status === 'running' ? (
|
|
100
106
|
<Layout direction="column">
|
|
101
107
|
<TopSection>
|
|
102
|
-
<
|
|
108
|
+
<TokenNameText
|
|
109
|
+
className={textTruncate()}
|
|
110
|
+
size="medium"
|
|
111
|
+
variant="title">
|
|
103
112
|
{fromToken.displayName}
|
|
104
|
-
</
|
|
113
|
+
</TokenNameText>
|
|
114
|
+
{fromToken.displayName.length > TOKEN_NAME_TOOLTIP_THRESHOLD && (
|
|
115
|
+
<Tooltip
|
|
116
|
+
content={fromToken.displayName}
|
|
117
|
+
container={tooltipContainer}>
|
|
118
|
+
<InfoIcon size={12} color="gray" />
|
|
119
|
+
</Tooltip>
|
|
120
|
+
)}
|
|
105
121
|
<Icon>
|
|
106
122
|
<NextIcon size={24} color="black" />
|
|
107
123
|
</Icon>
|
|
108
|
-
<
|
|
124
|
+
<TokenNameText
|
|
125
|
+
className={textTruncate()}
|
|
126
|
+
size="medium"
|
|
127
|
+
variant="title">
|
|
109
128
|
{toToken.displayName}
|
|
110
|
-
</
|
|
129
|
+
</TokenNameText>
|
|
130
|
+
{toToken.displayName.length > TOKEN_NAME_TOOLTIP_THRESHOLD && (
|
|
131
|
+
<Tooltip
|
|
132
|
+
content={toToken.displayName}
|
|
133
|
+
container={tooltipContainer}>
|
|
134
|
+
<InfoIcon size={12} color="gray" />
|
|
135
|
+
</Tooltip>
|
|
136
|
+
)}
|
|
111
137
|
</TopSection>
|
|
112
138
|
<Typography size="small" variant="body" color="neutral700">
|
|
113
139
|
{currentStep?.fromBlockchain === currentStep?.toBlockchain
|
|
@@ -118,31 +144,77 @@ export function SwapToken(props: PropTypes) {
|
|
|
118
144
|
) : (
|
|
119
145
|
<Layout direction="row">
|
|
120
146
|
<TokenInfo>
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
147
|
+
<FlexCenteredContainer>
|
|
148
|
+
<TokenNameText
|
|
149
|
+
className={textTruncate()}
|
|
150
|
+
size="medium"
|
|
151
|
+
variant="title">
|
|
152
|
+
{fromToken.displayName}
|
|
153
|
+
</TokenNameText>
|
|
154
|
+
{fromToken.displayName.length > TOKEN_NAME_TOOLTIP_THRESHOLD && (
|
|
155
|
+
<Tooltip
|
|
156
|
+
content={fromToken.displayName}
|
|
157
|
+
container={tooltipContainer}>
|
|
158
|
+
<InfoIcon size={12} color="gray" />
|
|
159
|
+
</Tooltip>
|
|
160
|
+
)}
|
|
161
|
+
</FlexCenteredContainer>
|
|
162
|
+
|
|
124
163
|
{!!fromAmount && (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
164
|
+
<FlexCenteredContainer>
|
|
165
|
+
<AmountText
|
|
166
|
+
className={textTruncate()}
|
|
167
|
+
size="small"
|
|
168
|
+
variant="body"
|
|
169
|
+
color="neutral700">
|
|
170
|
+
{fromRealAmount}
|
|
171
|
+
</AmountText>
|
|
172
|
+
|
|
173
|
+
{fromRealAmount.length > TOKEN_AMOUNT_TOOLTIP_THRESHOLD && (
|
|
174
|
+
<NumericTooltip
|
|
175
|
+
content={fromRealAmount}
|
|
176
|
+
container={tooltipContainer}>
|
|
177
|
+
<InfoIcon size={12} color="gray" />
|
|
178
|
+
</NumericTooltip>
|
|
179
|
+
)}
|
|
180
|
+
</FlexCenteredContainer>
|
|
132
181
|
)}
|
|
133
182
|
</TokenInfo>
|
|
134
183
|
<Icon>
|
|
135
184
|
<NextIcon size={24} color="black" />
|
|
136
185
|
</Icon>
|
|
137
186
|
<TokenInfo>
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{
|
|
144
|
-
</
|
|
145
|
-
|
|
187
|
+
<FlexCenteredContainer>
|
|
188
|
+
<TokenNameText
|
|
189
|
+
className={textTruncate()}
|
|
190
|
+
size="medium"
|
|
191
|
+
variant="title">
|
|
192
|
+
{toToken.displayName}
|
|
193
|
+
</TokenNameText>
|
|
194
|
+
{toToken.displayName.length > TOKEN_NAME_TOOLTIP_THRESHOLD && (
|
|
195
|
+
<Tooltip
|
|
196
|
+
content={toToken.displayName}
|
|
197
|
+
container={tooltipContainer}>
|
|
198
|
+
<InfoIcon size={12} color="gray" />
|
|
199
|
+
</Tooltip>
|
|
200
|
+
)}
|
|
201
|
+
</FlexCenteredContainer>
|
|
202
|
+
<FlexCenteredContainer>
|
|
203
|
+
<AmountText
|
|
204
|
+
className={textTruncate()}
|
|
205
|
+
size="small"
|
|
206
|
+
variant="body"
|
|
207
|
+
color="neutral700">
|
|
208
|
+
{toRealAmount}
|
|
209
|
+
</AmountText>
|
|
210
|
+
{toRealAmount.length > TOKEN_AMOUNT_TOOLTIP_THRESHOLD && (
|
|
211
|
+
<NumericTooltip
|
|
212
|
+
content={toRealAmount}
|
|
213
|
+
container={tooltipContainer}>
|
|
214
|
+
<InfoIcon size={12} color="gray" />
|
|
215
|
+
</NumericTooltip>
|
|
216
|
+
)}
|
|
217
|
+
</FlexCenteredContainer>
|
|
146
218
|
</TokenInfo>
|
|
147
219
|
</Layout>
|
|
148
220
|
)}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { css, styled } from '../../theme.js';
|
|
2
|
+
import { Typography } from '../Typography/Typography.js';
|
|
2
3
|
|
|
3
4
|
export const Container = styled('div', {
|
|
4
5
|
display: 'flex',
|
|
5
6
|
justifyContent: 'space-between',
|
|
7
|
+
gap: '$8',
|
|
6
8
|
variants: {
|
|
7
9
|
direction: {
|
|
8
10
|
vertical: {
|
|
@@ -17,17 +19,73 @@ export const Container = styled('div', {
|
|
|
17
19
|
},
|
|
18
20
|
});
|
|
19
21
|
|
|
20
|
-
export const
|
|
22
|
+
export const centeredFlexBox = css({
|
|
21
23
|
display: 'flex',
|
|
22
24
|
justifyContent: 'center',
|
|
23
25
|
alignItems: 'center',
|
|
24
26
|
});
|
|
25
27
|
|
|
28
|
+
export const TokenAmountWrapper = styled('div', {
|
|
29
|
+
flex: '1 1 0',
|
|
30
|
+
minWidth: 0,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'flex-start',
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
variants: {
|
|
36
|
+
direction: {
|
|
37
|
+
vertical: {
|
|
38
|
+
maxWidth: 320,
|
|
39
|
+
},
|
|
40
|
+
horizontal: { maxWidth: 254 },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
26
45
|
export const usdValueStyles = css({
|
|
27
46
|
display: 'flex',
|
|
28
|
-
|
|
47
|
+
paddingBottom: '$5',
|
|
48
|
+
minWidth: 0,
|
|
49
|
+
flex: '0 1 auto',
|
|
29
50
|
});
|
|
30
51
|
|
|
31
52
|
export const tooltipRootStyle = {
|
|
32
53
|
width: 'fit-content',
|
|
33
54
|
};
|
|
55
|
+
|
|
56
|
+
export const TokenNameText = styled(Typography, {
|
|
57
|
+
maxWidth: '64px',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const textTruncate = css({
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
textOverflow: 'ellipsis',
|
|
63
|
+
whiteSpace: 'nowrap',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const flexShrinkFix = css({
|
|
67
|
+
minWidth: 0,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const usdValueText = css({
|
|
71
|
+
'& .output-usd-value': {
|
|
72
|
+
maxWidth: 77,
|
|
73
|
+
},
|
|
74
|
+
maxWidth: 88,
|
|
75
|
+
});
|
|
76
|
+
export const verticalUsdValueText = css({
|
|
77
|
+
'& .output-usd-value': {
|
|
78
|
+
maxWidth: 300,
|
|
79
|
+
},
|
|
80
|
+
maxWidth: 320,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const flexShrink = css({
|
|
84
|
+
flexShrink: 1,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const TokenInfoRow = styled('div', {
|
|
88
|
+
display: 'flex',
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
});
|
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
import type { PropTypes } from './TokenAmount.types.js';
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { useIsTruncated } from 'src/hooks/useIsTruncated.js';
|
|
5
|
+
import { InfoIcon } from 'src/icons/index.js';
|
|
4
6
|
|
|
5
7
|
import { ChainToken } from '../ChainToken/index.js';
|
|
6
8
|
import { Divider } from '../Divider/index.js';
|
|
7
9
|
import { PriceImpact } from '../PriceImpact/index.js';
|
|
8
10
|
import { ValueTypography } from '../PriceImpact/PriceImpact.styles.js';
|
|
9
|
-
import { NumericTooltip } from '../Tooltip/index.js';
|
|
11
|
+
import { NumericTooltip, Tooltip } from '../Tooltip/index.js';
|
|
10
12
|
import { Typography } from '../Typography/index.js';
|
|
11
13
|
|
|
12
14
|
import {
|
|
13
15
|
Container,
|
|
14
|
-
|
|
16
|
+
flexShrink,
|
|
17
|
+
flexShrinkFix,
|
|
18
|
+
textTruncate,
|
|
19
|
+
TokenAmountWrapper,
|
|
20
|
+
TokenInfoRow,
|
|
21
|
+
TokenNameText,
|
|
15
22
|
tooltipRootStyle,
|
|
16
23
|
usdValueStyles,
|
|
24
|
+
usdValueText,
|
|
25
|
+
verticalUsdValueText,
|
|
17
26
|
} from './TokenAmount.styles.js';
|
|
18
27
|
|
|
19
28
|
export function TokenAmount(props: PropTypes) {
|
|
29
|
+
const realValueRef = useRef<HTMLSpanElement | null>(null);
|
|
30
|
+
const isRealValueTruncated = useIsTruncated(
|
|
31
|
+
props.price?.realValue || '',
|
|
32
|
+
realValueRef
|
|
33
|
+
);
|
|
34
|
+
const realUSdValueRef = useRef<HTMLSpanElement | null>(null);
|
|
35
|
+
const isRealUsedValueTruncated = useIsTruncated(
|
|
36
|
+
props.price?.realUsdValue || '',
|
|
37
|
+
realUSdValueRef
|
|
38
|
+
);
|
|
39
|
+
const displayNameRef = useRef<HTMLSpanElement | null>(null);
|
|
40
|
+
const isDisplayNameTruncated = useIsTruncated(
|
|
41
|
+
props.token.displayName,
|
|
42
|
+
displayNameRef
|
|
43
|
+
);
|
|
20
44
|
return (
|
|
21
45
|
<Container
|
|
22
46
|
direction={props.direction}
|
|
23
47
|
centerAlign={props.centerAlign}
|
|
24
48
|
id={props.id}>
|
|
25
|
-
<
|
|
49
|
+
<TokenAmountWrapper direction={props.direction}>
|
|
26
50
|
<ChainToken
|
|
27
51
|
chainImage={props.chain.image}
|
|
28
52
|
tokenImage={props.token.image}
|
|
@@ -30,50 +54,86 @@ export function TokenAmount(props: PropTypes) {
|
|
|
30
54
|
/>
|
|
31
55
|
|
|
32
56
|
<Divider direction="horizontal" size={4} />
|
|
33
|
-
<div>
|
|
57
|
+
<div className={flexShrinkFix()}>
|
|
34
58
|
{props.label && (
|
|
35
59
|
<Typography size="xsmall" variant="body" color="$neutral700">
|
|
36
60
|
{props.label}
|
|
37
61
|
</Typography>
|
|
38
62
|
)}
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
<TokenInfoRow className={flexShrinkFix()}>
|
|
64
|
+
<Typography
|
|
65
|
+
size="medium"
|
|
66
|
+
variant="title"
|
|
67
|
+
ref={realValueRef}
|
|
68
|
+
className={`${textTruncate()} ${flexShrinkFix()}`}
|
|
69
|
+
style={{ fontWeight: 600 }}>
|
|
70
|
+
{props.price.realValue}
|
|
71
|
+
</Typography>
|
|
72
|
+
{props.price.realValue && isRealValueTruncated && (
|
|
73
|
+
<>
|
|
74
|
+
<Divider direction="horizontal" size={2} />
|
|
75
|
+
|
|
76
|
+
<NumericTooltip
|
|
77
|
+
styles={{ root: tooltipRootStyle }}
|
|
78
|
+
content={props.price.realValue}
|
|
79
|
+
open={!props.price.realValue ? false : undefined}
|
|
80
|
+
container={props.tooltipContainer}>
|
|
81
|
+
<InfoIcon size={12} color="gray" />
|
|
82
|
+
</NumericTooltip>
|
|
83
|
+
</>
|
|
84
|
+
)}
|
|
85
|
+
<Divider direction="horizontal" size={8} />
|
|
86
|
+
<TokenNameText
|
|
87
|
+
size="medium"
|
|
88
|
+
variant="title"
|
|
89
|
+
className={textTruncate()}
|
|
90
|
+
ref={displayNameRef}
|
|
91
|
+
style={{ fontWeight: 400 }}>
|
|
92
|
+
{props.token.displayName}
|
|
93
|
+
</TokenNameText>
|
|
94
|
+
{isDisplayNameTruncated && (
|
|
95
|
+
<>
|
|
96
|
+
<Divider direction="horizontal" size={2} />
|
|
97
|
+
<Tooltip
|
|
98
|
+
content={props.token.displayName}
|
|
99
|
+
container={props.tooltipContainer}>
|
|
100
|
+
<InfoIcon size={12} color="gray" />
|
|
101
|
+
</Tooltip>
|
|
102
|
+
</>
|
|
103
|
+
)}
|
|
104
|
+
</TokenInfoRow>
|
|
60
105
|
</div>
|
|
61
|
-
</
|
|
106
|
+
</TokenAmountWrapper>
|
|
62
107
|
{props.price.usdValue && props.price.usdValue !== '0' && (
|
|
63
108
|
<div className={usdValueStyles()}>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</
|
|
73
|
-
|
|
74
|
-
|
|
109
|
+
{props.type === 'input' && (
|
|
110
|
+
<ValueTypography className={usdValueText()}>
|
|
111
|
+
<Typography
|
|
112
|
+
ref={realUSdValueRef}
|
|
113
|
+
className={textTruncate()}
|
|
114
|
+
size="small"
|
|
115
|
+
variant="body">
|
|
116
|
+
{`~$${props.price.realUsdValue}`}
|
|
117
|
+
</Typography>
|
|
118
|
+
{isRealUsedValueTruncated && (
|
|
119
|
+
<NumericTooltip
|
|
120
|
+
content={props.price.realUsdValue}
|
|
121
|
+
container={props.tooltipContainer}>
|
|
122
|
+
<InfoIcon size={12} color="gray" />
|
|
123
|
+
</NumericTooltip>
|
|
124
|
+
)}
|
|
125
|
+
</ValueTypography>
|
|
126
|
+
)}
|
|
75
127
|
{props.type === 'output' && (
|
|
76
128
|
<PriceImpact
|
|
129
|
+
className={`${
|
|
130
|
+
props.direction === 'horizontal'
|
|
131
|
+
? usdValueText()
|
|
132
|
+
: verticalUsdValueText()
|
|
133
|
+
} ${flexShrinkFix()} ${flexShrink()}`}
|
|
134
|
+
style={{
|
|
135
|
+
...(props.direction === 'horizontal' && { flexWrap: 'wrap' }),
|
|
136
|
+
}}
|
|
77
137
|
size="small"
|
|
78
138
|
tooltipProps={{ container: props.tooltipContainer, side: 'top' }}
|
|
79
139
|
outputUsdValue={props.price.usdValue}
|
|
@@ -5,26 +5,26 @@ import React from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { TypographyContainer } from './Typography.styles.js';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
color,
|
|
13
|
-
|
|
14
|
-
}: PropsWithChildren<TypographyPropTypes>) {
|
|
8
|
+
export const Typography = React.forwardRef<
|
|
9
|
+
HTMLSpanElement,
|
|
10
|
+
PropsWithChildren<TypographyPropTypes>
|
|
11
|
+
>((props, ref) => {
|
|
12
|
+
const { children, id, className, color, ...rest } = props;
|
|
13
|
+
|
|
15
14
|
const customCss = color
|
|
16
|
-
? {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: {
|
|
20
|
-
color: '$foreground',
|
|
21
|
-
};
|
|
15
|
+
? { color: color.startsWith('$') ? color : `$${color}` }
|
|
16
|
+
: { color: '$foreground' };
|
|
17
|
+
|
|
22
18
|
return (
|
|
23
19
|
<TypographyContainer
|
|
20
|
+
id={id}
|
|
24
21
|
className={`_typography _text ${className || ''}`}
|
|
25
22
|
css={customCss}
|
|
26
|
-
{
|
|
23
|
+
ref={ref}
|
|
24
|
+
{...rest}>
|
|
27
25
|
{children}
|
|
28
26
|
</TypographyContainer>
|
|
29
27
|
);
|
|
30
|
-
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Typography.displayName = 'Typography';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './Wallet.js';
|
|
2
2
|
export type { WalletInfo } from './Wallet.types.js';
|
|
3
3
|
export { WalletState } from './Wallet.types.js';
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
SelectableWalletButton,
|
|
6
|
+
WalletImageContainer,
|
|
7
|
+
} from './Wallet.styles.js';
|
|
@@ -107,7 +107,7 @@ export const balanceStyles = css({
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
export const amountStyles = css({
|
|
110
|
-
width: '
|
|
110
|
+
width: '48%',
|
|
111
111
|
maxWidth: '170px',
|
|
112
112
|
display: 'flex',
|
|
113
113
|
flexDirection: 'column',
|
|
@@ -126,4 +126,5 @@ export const UsdPrice = styled(Typography, {
|
|
|
126
126
|
whiteSpace: 'nowrap',
|
|
127
127
|
overflow: 'hidden',
|
|
128
128
|
textOverflow: 'ellipsis',
|
|
129
|
+
maxWidth: 147,
|
|
129
130
|
});
|