Skip to content

Commit b2d6429

Browse files
committed
Fix buy widget showing payment method selection screen
1 parent ed5ce8a commit b2d6429

File tree

6 files changed

+50
-13
lines changed

6 files changed

+50
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function DirectPayment({
100100
size="xl"
101101
token={uiOptions.paymentInfo.token}
102102
tokenAmount={uiOptions.paymentInfo.amount}
103-
weight={700}
103+
weight={600}
104104
/>
105105
<Container flex="row" gap="3xs">
106106
<Text

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function TransactionPayment({
194194
}}
195195
>
196196
{/* USD Value */}
197-
<Text color="primaryText" size="xl" weight={700}>
197+
<Text color="primaryText" size="xl" weight={600}>
198198
{transactionDataQuery.data?.usdValueDisplay ||
199199
transactionDataQuery.data?.txCostDisplay}
200200
</Text>

packages/thirdweb/src/react/web/ui/Bridge/common/WithHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function WithHeader({
4646
<>
4747
{/* title */}
4848
{showTitle && (
49-
<Text color="primaryText" size="lg" weight={700}>
49+
<Text color="primaryText" size="lg" weight={600}>
5050
{uiOptions.metadata?.title || defaultTitle}
5151
</Text>
5252
)}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,16 @@ export function PaymentSelection({
125125
const connectedWallets = useConnectedWallets();
126126
const activeWallet = useActiveWallet();
127127

128-
const [currentStep, setCurrentStep] = useState<Step>({
129-
type: "walletSelection",
130-
});
128+
const initialStep =
129+
paymentMethods.length === 1 && paymentMethods[0] === "card"
130+
? {
131+
type: "fiatProviderSelection" as const,
132+
}
133+
: {
134+
type: "walletSelection" as const,
135+
};
136+
137+
const [currentStep, setCurrentStep] = useState<Step>(initialStep);
131138

132139
useQuery({
133140
queryFn: () => {
@@ -226,6 +233,9 @@ export function PaymentSelection({
226233
};
227234

228235
const getBackHandler = () => {
236+
if (paymentMethods.length === 1 && paymentMethods[0] === "card") {
237+
return onBack;
238+
}
229239
switch (currentStep.type) {
230240
case "walletSelection":
231241
return onBack;

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ export function WalletFiatSelection({
3838
<>
3939
{paymentMethods.includes("crypto") && (
4040
<>
41-
<Text color="primaryText" size="md">
42-
Pay with Crypto
43-
</Text>
44-
<Spacer y="md" />
41+
{paymentMethods.length > 1 && (
42+
<>
43+
<Text color="primaryText" size="sm" weight={500}>
44+
Pay with Crypto
45+
</Text>
46+
<Spacer y="sm" />
47+
</>
48+
)}
49+
4550
{/* Connected Wallets */}
4651
{connectedWallets.length > 0 && (
4752
<>
@@ -134,13 +139,13 @@ export function WalletFiatSelection({
134139

135140
{paymentMethods.includes("card") && (
136141
<>
137-
<Spacer y="md" />
142+
<Spacer y="lg" />
138143

139-
<Text color="primaryText" size="md">
144+
<Text color="primaryText" size="sm" weight={500}>
140145
Pay with Card
141146
</Text>
142147

143-
<Spacer y="md" />
148+
<Spacer y="sm" />
144149

145150
<Button
146151
fullWidth

packages/thirdweb/src/stories/BuyWidget.stories.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,25 @@ export function UnsupportedToken() {
3232
/>
3333
);
3434
}
35+
36+
export function OnlyCardSupported() {
37+
return (
38+
<BuyWidget
39+
client={storyClient}
40+
chain={base}
41+
amount="0.1"
42+
paymentMethods={["card"]}
43+
/>
44+
);
45+
}
46+
47+
export function OnlyCryptoSupported() {
48+
return (
49+
<BuyWidget
50+
client={storyClient}
51+
chain={base}
52+
amount="0.1"
53+
paymentMethods={["crypto"]}
54+
/>
55+
);
56+
}

0 commit comments

Comments
 (0)