@rango-dev/ui 0.12.0 → 0.13.1-next.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.
- package/CHANGELOG.md +1 -7
- package/dist/index.js +6 -6
- package/dist/index.js.map +4 -4
- package/dist/widget/ui/src/components/HeaderLayout/HeaderLayout.d.ts +14 -0
- package/dist/widget/ui/src/components/HeaderLayout/HeaderLayout.d.ts.map +1 -0
- package/dist/widget/ui/src/components/HeaderLayout/index.d.ts +2 -0
- package/dist/widget/ui/src/components/HeaderLayout/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/PercentageChange/PercentageChange.d.ts +8 -0
- package/dist/widget/ui/src/components/PercentageChange/PercentageChange.d.ts.map +1 -0
- package/dist/widget/ui/src/components/PercentageChange/index.d.ts +2 -0
- package/dist/widget/ui/src/components/PercentageChange/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts +120 -0
- package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts.map +1 -0
- package/dist/widget/ui/src/components/RoutesOverview/index.d.ts +2 -0
- package/dist/widget/ui/src/components/RoutesOverview/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts +120 -0
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts.map +1 -0
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/index.d.ts +2 -0
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/TokenPreview/TokenPreview.d.ts +20 -0
- package/dist/widget/ui/src/components/TokenPreview/TokenPreview.d.ts.map +1 -0
- package/dist/widget/ui/src/components/TokenPreview/index.d.ts +2 -0
- package/dist/widget/ui/src/components/TokenPreview/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/index.d.ts +5 -0
- package/dist/widget/ui/src/components/index.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/ConfirmSwap/ConfirmSwap.stories.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/HomePanel/HomePanel.d.ts +47 -0
- package/dist/widget/ui/src/containers/HomePanel/HomePanel.d.ts.map +1 -0
- package/dist/widget/ui/src/containers/HomePanel/index.d.ts +2 -0
- package/dist/widget/ui/src/containers/HomePanel/index.d.ts.map +1 -0
- package/dist/widget/ui/src/containers/TokenInfo/TokenInfo.d.ts +34 -0
- package/dist/widget/ui/src/containers/TokenInfo/TokenInfo.d.ts.map +1 -0
- package/dist/widget/ui/src/containers/TokenInfo/index.d.ts +2 -0
- package/dist/widget/ui/src/containers/TokenInfo/index.d.ts.map +1 -0
- package/dist/widget/ui/src/containers/index.d.ts +2 -0
- package/dist/widget/ui/src/containers/index.d.ts.map +1 -1
- package/dist/widget/ui/src/types/meta.d.ts +7 -0
- package/dist/widget/ui/src/types/meta.d.ts.map +1 -1
- package/dist/widget/ui/src/types/wallet.d.ts +23 -0
- package/dist/widget/ui/src/types/wallet.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/HeaderLayout/HeaderLayout.tsx +88 -0
- package/src/components/HeaderLayout/index.ts +1 -0
- package/src/components/PercentageChange/PercentageChange.tsx +21 -0
- package/src/components/PercentageChange/index.ts +1 -0
- package/src/components/RoutesOverview/RoutesOverview.tsx +56 -0
- package/src/components/RoutesOverview/index.ts +1 -0
- package/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.tsx +47 -0
- package/src/components/SwapDetailsPlaceholder/index.ts +1 -0
- package/src/components/TokenPreview/TokenPreview.tsx +183 -0
- package/src/components/TokenPreview/index.ts +1 -0
- package/src/components/index.ts +5 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +5 -174
- package/src/containers/HomePanel/HomePanel.tsx +228 -0
- package/src/containers/HomePanel/index.ts +1 -0
- package/src/containers/TokenInfo/TokenInfo.tsx +308 -0
- package/src/containers/TokenInfo/index.ts +1 -0
- package/src/containers/index.ts +2 -0
- package/src/helper/index.ts +1 -1
- package/src/types/meta.ts +9 -0
- package/src/types/wallet.ts +25 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
AddWalletIcon,
|
|
4
|
+
Typography,
|
|
5
|
+
styled,
|
|
6
|
+
Spinner,
|
|
7
|
+
Image,
|
|
8
|
+
} from '../..';
|
|
9
|
+
import React, { PropsWithChildren } from 'react';
|
|
10
|
+
import { i18n } from '@lingui/core';
|
|
11
|
+
import { LoadingStatus } from '../../types/meta';
|
|
12
|
+
import { ConnectedWallet } from '../../types/wallet';
|
|
13
|
+
|
|
14
|
+
const Container = styled('div', {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
width: '100%',
|
|
17
|
+
justifyContent: 'end',
|
|
18
|
+
'.balance': {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const WalletImages = styled('div', {
|
|
24
|
+
display: 'flex',
|
|
25
|
+
paddingLeft: '12px',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const WalletImageContainer = styled('div', {
|
|
29
|
+
marginLeft: -15,
|
|
30
|
+
marginRight: '$6',
|
|
31
|
+
'& img': {
|
|
32
|
+
borderRadius: '50%',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
interface HeaderLayoutProps {
|
|
37
|
+
loadingStatus: LoadingStatus;
|
|
38
|
+
connectedWalletsImages: string[];
|
|
39
|
+
connectedWallets: ConnectedWallet[];
|
|
40
|
+
totalBalance: string;
|
|
41
|
+
fetchingBalance: boolean;
|
|
42
|
+
onClick: () => void;
|
|
43
|
+
}
|
|
44
|
+
export function HeaderLayout({
|
|
45
|
+
connectedWalletsImages,
|
|
46
|
+
loadingStatus,
|
|
47
|
+
connectedWallets,
|
|
48
|
+
totalBalance,
|
|
49
|
+
fetchingBalance,
|
|
50
|
+
onClick,
|
|
51
|
+
children,
|
|
52
|
+
}: PropsWithChildren<HeaderLayoutProps>) {
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<Container>
|
|
56
|
+
<Button
|
|
57
|
+
size="small"
|
|
58
|
+
suffix={<AddWalletIcon size={20} />}
|
|
59
|
+
variant="ghost"
|
|
60
|
+
flexContent
|
|
61
|
+
loading={loadingStatus === 'loading'}
|
|
62
|
+
disabled={loadingStatus === 'failed'}
|
|
63
|
+
onClick={onClick}
|
|
64
|
+
prefix={
|
|
65
|
+
connectedWalletsImages?.length ? (
|
|
66
|
+
<WalletImages>
|
|
67
|
+
{connectedWalletsImages.map((walletImage, index) => (
|
|
68
|
+
<WalletImageContainer key={index}>
|
|
69
|
+
<Image src={walletImage} size={24} />
|
|
70
|
+
</WalletImageContainer>
|
|
71
|
+
))}
|
|
72
|
+
</WalletImages>
|
|
73
|
+
) : null
|
|
74
|
+
}>
|
|
75
|
+
<div className="balance">
|
|
76
|
+
<Typography variant="body2">
|
|
77
|
+
{!connectedWallets?.length
|
|
78
|
+
? i18n.t('Connect Wallet')
|
|
79
|
+
: `$${totalBalance || 0}`}
|
|
80
|
+
</Typography>
|
|
81
|
+
{fetchingBalance && <Spinner />}
|
|
82
|
+
</div>
|
|
83
|
+
</Button>
|
|
84
|
+
</Container>
|
|
85
|
+
{children}
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HeaderLayout } from './HeaderLayout';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Typography } from '..';
|
|
3
|
+
|
|
4
|
+
interface PropTypes {
|
|
5
|
+
showPercentageChange: boolean;
|
|
6
|
+
percentageChange: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function PercentageChange(props: PropTypes) {
|
|
10
|
+
const { percentageChange, showPercentageChange } = props;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
{showPercentageChange && (
|
|
15
|
+
<Typography variant="caption" color="$error500">
|
|
16
|
+
{`(${percentageChange}%)`}
|
|
17
|
+
</Typography>
|
|
18
|
+
)}
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PercentageChange } from './PercentageChange';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChevronRightIcon, GasIcon, Divider } from '..';
|
|
3
|
+
import { styled } from '../../theme';
|
|
4
|
+
import { BestRouteResponse } from 'rango-sdk';
|
|
5
|
+
|
|
6
|
+
export const Container = styled('div', {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
padding: '$8',
|
|
11
|
+
borderRadius: '$5',
|
|
12
|
+
backgroundColor: '$neutral100',
|
|
13
|
+
color: '$neutral800',
|
|
14
|
+
fontSize: '$12',
|
|
15
|
+
|
|
16
|
+
'.routes': {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
},
|
|
20
|
+
'.fee': {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
interface PropTypes {
|
|
27
|
+
routes: BestRouteResponse | null;
|
|
28
|
+
totalFee?: string;
|
|
29
|
+
}
|
|
30
|
+
export function RoutesOverview(props: PropTypes) {
|
|
31
|
+
if (!props.routes) return null;
|
|
32
|
+
|
|
33
|
+
const swaps = props.routes.result?.swaps;
|
|
34
|
+
return (
|
|
35
|
+
<Container>
|
|
36
|
+
<div className="routes">
|
|
37
|
+
{swaps?.map((swap, idx) => {
|
|
38
|
+
const isLast = idx + 1 == swaps.length;
|
|
39
|
+
return (
|
|
40
|
+
<React.Fragment key={idx}>
|
|
41
|
+
<div className="route">{swap.from.symbol}</div>
|
|
42
|
+
<ChevronRightIcon size={12} />
|
|
43
|
+
{isLast ? <div className="route">{swap.to.symbol}</div> : null}
|
|
44
|
+
</React.Fragment>
|
|
45
|
+
);
|
|
46
|
+
})}
|
|
47
|
+
</div>
|
|
48
|
+
{props.totalFee ? (
|
|
49
|
+
<div className="fee">
|
|
50
|
+
<GasIcon size={12} />
|
|
51
|
+
<Divider size={4} direction="horizontal" />${props.totalFee}
|
|
52
|
+
</div>
|
|
53
|
+
) : null}
|
|
54
|
+
</Container>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RoutesOverview } from './RoutesOverview';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SecondaryPage, Spinner, Alert, styled } from '../..';
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
|
|
5
|
+
const PlaceholderContainer = styled('div', { height: '450px' });
|
|
6
|
+
|
|
7
|
+
export const LoaderContainer = styled('div', {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
width: '100%',
|
|
11
|
+
paddingTop: '33%',
|
|
12
|
+
flex: 1,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
interface PropTypes {
|
|
16
|
+
requestId: string;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
onBack: () => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function SwapDetailsPlaceholder(props: PropTypes) {
|
|
22
|
+
const { requestId, loading, onBack } = props;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<SecondaryPage
|
|
26
|
+
title={i18n.t('Swap Details')}
|
|
27
|
+
textField={false}
|
|
28
|
+
onBack={onBack}>
|
|
29
|
+
<PlaceholderContainer>
|
|
30
|
+
{loading ? (
|
|
31
|
+
<LoaderContainer>
|
|
32
|
+
<Spinner size={24} />
|
|
33
|
+
</LoaderContainer>
|
|
34
|
+
) : (
|
|
35
|
+
<Alert
|
|
36
|
+
type="secondary"
|
|
37
|
+
title={i18n.t(
|
|
38
|
+
'swapNotFound',
|
|
39
|
+
{ requestId },
|
|
40
|
+
{ message: 'Swap with request ID = ${requestId} not found.' }
|
|
41
|
+
)}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
</PlaceholderContainer>
|
|
45
|
+
</SecondaryPage>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SwapDetailsPlaceholder } from './SwapDetailsPlaceholder';
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TokenPreview } from './TokenPreview';
|
package/src/components/index.ts
CHANGED
|
@@ -12,18 +12,23 @@ export * from './Divider';
|
|
|
12
12
|
export * from './Drawer';
|
|
13
13
|
export * from './Header';
|
|
14
14
|
export * from './HeaderButtons';
|
|
15
|
+
export * from './HeaderLayout';
|
|
15
16
|
export * from './Icon';
|
|
16
17
|
export * from './Modal';
|
|
18
|
+
export * from './PercentageChange';
|
|
17
19
|
export * from './Radio';
|
|
20
|
+
export * from './RoutesOverview';
|
|
18
21
|
export * from './SecondaryPage';
|
|
19
22
|
export * from './SelectableWalletList';
|
|
20
23
|
export * from './Spinner';
|
|
21
24
|
export * from './StepDetail';
|
|
22
25
|
export * from './SwapContainer';
|
|
23
26
|
export * from './SwapDetail';
|
|
27
|
+
export * from './SwapDetailsPlaceholder';
|
|
24
28
|
export * from './Switch';
|
|
25
29
|
export * from './TextField';
|
|
26
30
|
export * from './TokenList';
|
|
31
|
+
export * from './TokenPreview';
|
|
27
32
|
export * from './Tooltip';
|
|
28
33
|
export * from './Typography';
|
|
29
34
|
export * from './Wallet';
|
|
@@ -2,178 +2,7 @@ import { Meta } from '@storybook/react';
|
|
|
2
2
|
import { ConfirmSwap, PropTypes } from './ConfirmSwap';
|
|
3
3
|
import { exampleFor5Wallets, wallets, bestRoute } from './mock';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import { BestRouteResponse } from 'rango-sdk';
|
|
7
|
-
import { ChevronRightIcon } from '../../components';
|
|
8
|
-
const Box = styled('div', {
|
|
9
|
-
display: 'flex',
|
|
10
|
-
flexDirection: 'column',
|
|
11
|
-
width: '100%',
|
|
12
|
-
overflow: 'hidden',
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const Container = styled('div', {
|
|
16
|
-
boxSizing: 'border-box',
|
|
17
|
-
borderRadius: '$5',
|
|
18
|
-
padding: '$8 $16 $16 $16',
|
|
19
|
-
|
|
20
|
-
variants: {
|
|
21
|
-
type: {
|
|
22
|
-
filled: {
|
|
23
|
-
backgroundColor: '$neutral100',
|
|
24
|
-
},
|
|
25
|
-
outlined: {
|
|
26
|
-
border: '1px solid $neutral100',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
defaultVariants: {
|
|
32
|
-
type: 'filled',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
'.head': {
|
|
36
|
-
display: 'flex',
|
|
37
|
-
justifyContent: 'space-between',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
minHeight: '32px',
|
|
40
|
-
'.usd-value': {
|
|
41
|
-
paddingLeft: '$8',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
'.form': {
|
|
45
|
-
display: 'flex',
|
|
46
|
-
width: '100%',
|
|
47
|
-
padding: '$2 0',
|
|
48
|
-
'.selectors': {
|
|
49
|
-
width: '35%',
|
|
50
|
-
|
|
51
|
-
'._text': {
|
|
52
|
-
whiteSpace: 'nowrap',
|
|
53
|
-
overflow: 'hidden',
|
|
54
|
-
textOverflow: 'ellipsis',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
'.amount': {
|
|
58
|
-
width: '30%',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const OutputContainer = styled('div', {
|
|
64
|
-
windth: '100%',
|
|
65
|
-
height: '$48',
|
|
66
|
-
borderRadius: '$5',
|
|
67
|
-
backgroundColor: '$surface',
|
|
68
|
-
border: '1px solid transparent',
|
|
69
|
-
position: 'relative',
|
|
70
|
-
display: 'flex',
|
|
71
|
-
alignItems: 'center',
|
|
72
|
-
paddingLeft: '$8',
|
|
73
|
-
paddingRight: '$8',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const TokenPreview = ({
|
|
77
|
-
chain,
|
|
78
|
-
token,
|
|
79
|
-
...props
|
|
80
|
-
}: {
|
|
81
|
-
label: string;
|
|
82
|
-
amount: string;
|
|
83
|
-
usdValue?: number;
|
|
84
|
-
chain: {
|
|
85
|
-
displayName: string;
|
|
86
|
-
logo: string;
|
|
87
|
-
};
|
|
88
|
-
token: {
|
|
89
|
-
symbol: string;
|
|
90
|
-
image: string;
|
|
91
|
-
};
|
|
92
|
-
}) => (
|
|
93
|
-
<Box>
|
|
94
|
-
<Container type={'outlined'}>
|
|
95
|
-
<div className="head">
|
|
96
|
-
<Typography variant="body2" color="neutral800">
|
|
97
|
-
{props.label}
|
|
98
|
-
</Typography>
|
|
99
|
-
<div>
|
|
100
|
-
<Typography
|
|
101
|
-
variant="caption"
|
|
102
|
-
color="neutral600"
|
|
103
|
-
className="usd-value">{`$${props.usdValue}`}</Typography>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
<div className="form">
|
|
107
|
-
<Button
|
|
108
|
-
className="selectors"
|
|
109
|
-
variant="outlined"
|
|
110
|
-
prefix={<Image src={chain.logo} size={24} />}
|
|
111
|
-
align="start"
|
|
112
|
-
size="large">
|
|
113
|
-
{chain.displayName}
|
|
114
|
-
</Button>
|
|
115
|
-
<Divider size={12} direction="horizontal" />
|
|
116
|
-
<Button
|
|
117
|
-
className="selectors"
|
|
118
|
-
variant="outlined"
|
|
119
|
-
prefix={<Image src={token.image} size={24} />}
|
|
120
|
-
size="large"
|
|
121
|
-
align="start">
|
|
122
|
-
{token.symbol}
|
|
123
|
-
</Button>
|
|
124
|
-
<Divider size={12} direction="horizontal" />
|
|
125
|
-
<div className="amount">
|
|
126
|
-
<OutputContainer>
|
|
127
|
-
<Typography variant="h4">{props.amount}</Typography>
|
|
128
|
-
</OutputContainer>
|
|
129
|
-
</div>
|
|
130
|
-
</div>
|
|
131
|
-
</Container>
|
|
132
|
-
</Box>
|
|
133
|
-
);
|
|
134
|
-
const OverviewContainer = styled('div', {
|
|
135
|
-
display: 'flex',
|
|
136
|
-
alignItems: 'center',
|
|
137
|
-
justifyContent: 'space-between',
|
|
138
|
-
padding: '$8',
|
|
139
|
-
borderRadius: '$5',
|
|
140
|
-
backgroundColor: '$neutral100',
|
|
141
|
-
color: '$neutral800',
|
|
142
|
-
fontSize: '$12',
|
|
143
|
-
|
|
144
|
-
'.routes': {
|
|
145
|
-
display: 'flex',
|
|
146
|
-
alignItems: 'center',
|
|
147
|
-
},
|
|
148
|
-
'.fee': {
|
|
149
|
-
display: 'flex',
|
|
150
|
-
alignItems: 'center',
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const RoutesOverview = (props: { routes: BestRouteResponse; totalFee?: string }) => {
|
|
155
|
-
const swaps = props.routes.result?.swaps;
|
|
156
|
-
return (
|
|
157
|
-
<OverviewContainer>
|
|
158
|
-
<div className="routes">
|
|
159
|
-
{swaps?.map((swap, idx) => {
|
|
160
|
-
const isLast = idx + 1 == swaps.length;
|
|
161
|
-
return (
|
|
162
|
-
<React.Fragment key={idx}>
|
|
163
|
-
<div className="route">{swap.from.symbol}</div>
|
|
164
|
-
<ChevronRightIcon size={12} />
|
|
165
|
-
{isLast ? <div className="route">{swap.to.symbol}</div> : null}
|
|
166
|
-
</React.Fragment>
|
|
167
|
-
);
|
|
168
|
-
})}
|
|
169
|
-
</div>
|
|
170
|
-
<div className="fee">
|
|
171
|
-
<GasIcon size={12} />
|
|
172
|
-
<Divider size={4} direction="horizontal" />${props.totalFee}
|
|
173
|
-
</div>
|
|
174
|
-
</OverviewContainer>
|
|
175
|
-
);
|
|
176
|
-
};
|
|
5
|
+
import { Divider, RoutesOverview, TokenPreview } from '../../';
|
|
177
6
|
|
|
178
7
|
const previewInputs = () => (
|
|
179
8
|
<>
|
|
@@ -186,7 +15,8 @@ const previewInputs = () => (
|
|
|
186
15
|
symbol: bestRoute?.result?.swaps[0].from.symbol || '',
|
|
187
16
|
image: bestRoute?.result?.swaps[0].from.logo || '',
|
|
188
17
|
}}
|
|
189
|
-
usdValue={2}
|
|
18
|
+
usdValue={'2'}
|
|
19
|
+
loadingStatus="success"
|
|
190
20
|
amount={'2.99'}
|
|
191
21
|
label="From"
|
|
192
22
|
/>
|
|
@@ -200,7 +30,8 @@ const previewInputs = () => (
|
|
|
200
30
|
symbol: bestRoute?.result?.swaps[0].to.symbol || '',
|
|
201
31
|
image: bestRoute?.result?.swaps[0].to.logo || '',
|
|
202
32
|
}}
|
|
203
|
-
usdValue={2}
|
|
33
|
+
usdValue={'2'}
|
|
34
|
+
loadingStatus="success"
|
|
204
35
|
amount={'2.99'}
|
|
205
36
|
label="To"
|
|
206
37
|
/>
|