Skip to content

Commit 1d98c3e

Browse files
committed
improve fiat onramp ui
1 parent 0349636 commit 1d98c3e

File tree

3 files changed

+92
-87
lines changed

3 files changed

+92
-87
lines changed

packages/thirdweb/src/react/web/ui/Bridge/QuoteLoader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function QuoteLoader({
163163
<Spinner color="secondaryText" size="xl" />
164164
<Spacer y="md" />
165165
<Text center color="primaryText" size="lg" style={{ fontWeight: 600 }}>
166-
Finding the best route...
166+
Finding the best route
167167
</Text>
168168
<Spacer y="sm" />
169169
<Text center color="secondaryText" size="sm">

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/FiatProviderSelection.tsx

Lines changed: 89 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,15 @@ export function FiatProviderSelection({
7979
return quoteQueries.map((q) => q.data).filter((q) => !!q);
8080
}, [quoteQueries]);
8181

82+
const isPending = quoteQueries.some((q) => q.isLoading);
83+
8284
if (quoteQueries.every((q) => q.isError)) {
8385
return (
84-
<Container center="both" flex="column" style={{ minHeight: "120px" }}>
86+
<Container
87+
center="both"
88+
flex="column"
89+
style={{ minHeight: "200px", flexGrow: 1 }}
90+
>
8591
<Text color="secondaryText" size="sm">
8692
No quotes available
8793
</Text>
@@ -92,11 +98,17 @@ export function FiatProviderSelection({
9298
// TODO: add a "remember my choice" checkbox
9399

94100
return (
95-
<Container flex="column" gap="sm">
96-
{quotes.length > 0 ? (
101+
<Container
102+
flex="column"
103+
gap="xs"
104+
style={{
105+
flexGrow: 1,
106+
}}
107+
>
108+
{!isPending ? (
97109
quotes
98110
.sort((a, b) => a.currencyAmount - b.currencyAmount)
99-
.map((quote, index) => {
111+
.map((quote) => {
100112
const provider = PROVIDERS.find(
101113
(p) => p.id === quote.intent.onramp,
102114
);
@@ -105,98 +117,92 @@ export function FiatProviderSelection({
105117
}
106118

107119
return (
108-
<Container
109-
animate="fadein"
120+
<Button
110121
key={provider.id}
122+
fullWidth
123+
onClick={() => onProviderSelected(provider.id)}
111124
style={{
112-
animationDelay: `${index * 100}ms`,
125+
border: `1px solid ${theme.colors.borderColor}`,
126+
borderRadius: radius.md,
127+
textAlign: "left",
113128
}}
129+
variant="secondary"
114130
>
115-
<Button
116-
fullWidth
117-
onClick={() => onProviderSelected(provider.id)}
118-
style={{
119-
backgroundColor: theme.colors.tertiaryBg,
120-
border: `1px solid ${theme.colors.borderColor}`,
121-
borderRadius: radius.md,
122-
padding: `${spacing.sm} ${spacing.md}`,
123-
textAlign: "left",
124-
}}
125-
variant="secondary"
131+
<Container
132+
flex="row"
133+
gap="sm"
134+
style={{ alignItems: "center", width: "100%" }}
126135
>
136+
<Img
137+
alt={provider.name}
138+
client={client}
139+
height={iconSize.lg}
140+
src={provider.iconUri}
141+
width={iconSize.lg}
142+
style={{
143+
borderRadius: radius.full,
144+
}}
145+
/>
146+
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
147+
<Text color="primaryText" size="md" weight={500}>
148+
{provider.name}
149+
</Text>
150+
</Container>
127151
<Container
128-
flex="row"
129-
gap="sm"
130-
style={{ alignItems: "center", width: "100%" }}
152+
flex="column"
153+
gap="3xs"
154+
style={{ alignItems: "flex-end" }}
131155
>
132-
<Container
133-
style={{
134-
alignItems: "center",
135-
borderRadius: "50%",
136-
display: "flex",
137-
height: `${iconSize.md}px`,
138-
justifyContent: "center",
139-
overflow: "hidden",
140-
padding: spacing.xs,
141-
width: `${iconSize.md}px`,
142-
}}
156+
<Text
157+
color="primaryText"
158+
size="sm"
159+
style={{ fontWeight: 500 }}
143160
>
144-
<Img
145-
alt={provider.name}
146-
client={client}
147-
height={iconSize.md}
148-
src={provider.iconUri}
149-
width={iconSize.md}
150-
/>
151-
</Container>
152-
<Container flex="column" gap="3xs" style={{ flex: 1 }}>
153-
<Text
154-
color="primaryText"
155-
size="md"
156-
style={{ fontWeight: 600 }}
157-
>
158-
{provider.name}
159-
</Text>
160-
</Container>
161-
<Container
162-
flex="column"
163-
gap="3xs"
164-
style={{ alignItems: "flex-end" }}
165-
>
166-
<Text
167-
color="primaryText"
168-
size="sm"
169-
style={{ fontWeight: 500 }}
170-
>
171-
{formatCurrencyAmount(
172-
currency || "US",
173-
quote.currencyAmount,
174-
)}
175-
</Text>
176-
<Text color="secondaryText" size="xs">
177-
{formatNumber(
178-
Number(
179-
toTokens(
180-
quote.destinationAmount,
181-
quote.destinationToken.decimals,
182-
),
161+
{formatCurrencyAmount(
162+
currency || "US",
163+
quote.currencyAmount,
164+
)}
165+
</Text>
166+
<Text color="secondaryText" size="xs">
167+
{formatNumber(
168+
Number(
169+
toTokens(
170+
quote.destinationAmount,
171+
quote.destinationToken.decimals,
183172
),
184-
4,
185-
)}{" "}
186-
{quote.destinationToken.symbol}
187-
</Text>
188-
</Container>
173+
),
174+
4,
175+
)}{" "}
176+
{quote.destinationToken.symbol}
177+
</Text>
189178
</Container>
190-
</Button>
191-
</Container>
179+
</Container>
180+
</Button>
192181
);
193182
})
194183
) : (
195-
<Container center="both" flex="column" style={{ minHeight: "120px" }}>
196-
<Spinner color="secondaryText" size="lg" />
197-
<Spacer y="sm" />
198-
<Text center color="secondaryText" size="sm">
199-
Generating quotes...
184+
<Container
185+
center="both"
186+
flex="column"
187+
style={{ flexGrow: 1, paddingBottom: spacing.lg }}
188+
px="md"
189+
>
190+
<Spinner color="secondaryText" size="xl" />
191+
<Spacer y="lg" />
192+
<Text center color="primaryText" size="lg" weight={500}>
193+
Searching Providers
194+
</Text>
195+
<Spacer y="xs" />
196+
<Text
197+
center
198+
color="secondaryText"
199+
size="sm"
200+
multiline
201+
style={{
202+
textWrap: "pretty",
203+
}}
204+
>
205+
Searching for the best providers for this payment
200206
</Text>
201207
</Container>
202208
)}

packages/thirdweb/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,9 @@ export function PaymentSelection({
282282
return (
283283
<Container flex="column" p="md">
284284
<ModalHeader onBack={getBackHandler()} title={getStepTitle()} />
285+
<Spacer y="lg" />
285286

286-
<Spacer y="xl" />
287-
288-
<Container flex="column">
287+
<Container flex="column" style={{ minHeight: "300px" }}>
289288
{currentStep.type === "walletSelection" && (
290289
<WalletFiatSelection
291290
client={client}

0 commit comments

Comments
 (0)