Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type UIOptions = Prettify<
image?: string;
};
currency?: SupportedFiatCurrency;
buttonLabel?: string;
} & (
| {
mode: "fund_wallet";
Expand Down
8 changes: 8 additions & 0 deletions packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@
* @default "USD"
*/
currency?: SupportedFiatCurrency;

/**
* Custom label for the main action button.
*/
buttonLabel?: string;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -335,6 +340,7 @@
},
mode: "fund_wallet",
currency: props.currency || "USD",
buttonLabel: props.buttonLabel,

Check warning on line 343 in packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx#L343

Added line #L343 was not covered by tests
},
type: "success",
};
Expand Down Expand Up @@ -364,6 +370,8 @@
title: props.title,
},
mode: "fund_wallet",
currency: props.currency || "USD",
buttonLabel: props.buttonLabel,

Check warning on line 374 in packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/BuyWidget.tsx#L373-L374

Added lines #L373 - L374 were not covered by tests
},
type: "success",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
* @default "USD"
*/
currency?: SupportedFiatCurrency;

/**
* Custom label for the main action button.
*/
buttonLabel?: string;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -310,6 +315,7 @@
},
mode: "direct_payment",
currency: props.currency || "USD",
buttonLabel: props.buttonLabel,

Check warning on line 318 in packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/CheckoutWidget.tsx#L318

Added line #L318 was not covered by tests
paymentInfo: {
amount: props.amount,
feePayer: props.feePayer === "seller" ? "receiver" : "sender",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
);
};

const buyNow = (
const buyNow = uiOptions.buttonLabel ? (
<Text color="primaryButtonText" size="md">
{uiOptions.buttonLabel}
</Text>

Check warning on line 70 in packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx#L67-L70

Added lines #L67 - L70 were not covered by tests
) : (
<Container flex="row" gap="3xs">
<Text color="primaryButtonText" size="md">
Buy Now ·
Expand Down
4 changes: 2 additions & 2 deletions packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@
}}
variant="primary"
>
Buy {amount} {uiOptions.destinationToken.symbol}
{uiOptions.buttonLabel || `Buy ${amount} ${uiOptions.destinationToken.symbol}`}

Check warning on line 339 in packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx#L339

Added line #L339 was not covered by tests
</Button>
) : (
<ConnectButton
client={client}
connectButton={{
label: `Buy ${amount} ${uiOptions.destinationToken.symbol}`,
label: uiOptions.buttonLabel || `Buy ${amount} ${uiOptions.destinationToken.symbol}`,

Check warning on line 345 in packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx#L345

Added line #L345 was not covered by tests
}}
theme={theme}
{...connectOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
transactionDataQuery.data?.functionInfo?.functionName || "Contract Call";
const isLoading = transactionDataQuery.isLoading || chainMetadata.isLoading;

const buttonLabel = `Execute ${functionName}`;
const buttonLabel = uiOptions.buttonLabel || `Execute ${functionName}`;

Check warning on line 115 in packages/thirdweb/src/react/web/ui/Bridge/TransactionPayment.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L115 was not covered by tests

if (isLoading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@
* @default "USD"
*/
currency?: SupportedFiatCurrency;

/**
* Custom label for the main action button.
*/
buttonLabel?: string;
};

// Enhanced UIOptions to handle unsupported token state
Expand Down Expand Up @@ -349,6 +354,7 @@
return {
data: {
currency: props.currency || "USD",
buttonLabel: props.buttonLabel,

Check warning on line 357 in packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/Bridge/TransactionWidget.tsx#L357

Added line #L357 was not covered by tests
metadata: {
description: props.description,
image: props.image,
Expand Down
30 changes: 30 additions & 0 deletions packages/thirdweb/src/stories/Bridge/DirectPayment.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,33 @@ export const NoImageLight: Story = {
},
},
};

export const CustomButtonLabel: Story = {
args: {
theme: "dark",
uiOptions: DIRECT_PAYMENT_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "dark" },
docs: {
description: {
story: "Example showcasing custom button label functionality. The button shows 'Purchase Now' instead of the default 'Buy Now' text.",
},
},
},
};

export const CustomButtonLabelLight: Story = {
args: {
theme: "light",
uiOptions: DIRECT_PAYMENT_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "light" },
docs: {
description: {
story: "Light theme version with custom button label 'Purchase Now'.",
},
},
},
};
30 changes: 30 additions & 0 deletions packages/thirdweb/src/stories/Bridge/FundWallet.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,33 @@ export const LargeAmountLight: Story = {
},
},
};

export const CustomButtonLabel: Story = {
args: {
theme: "dark",
uiOptions: FUND_WALLET_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "dark" },
docs: {
description: {
story: "Example showcasing custom button label functionality. The button shows 'Add Funds Now' instead of the default 'Buy [amount] [symbol]' text.",
},
},
},
};

export const CustomButtonLabelLight: Story = {
args: {
theme: "light",
uiOptions: FUND_WALLET_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "light" },
docs: {
description: {
story: "Light theme version with custom button label 'Add Funds Now'.",
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,33 @@ export const ContractInteractionLight: Story = {
},
},
};

export const CustomButtonLabel: Story = {
args: {
theme: "dark",
uiOptions: TRANSACTION_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "dark" },
docs: {
description: {
story: "Example showcasing custom button label functionality. The button shows 'Execute Now' instead of the default 'Execute [functionName]' text.",
},
},
},
};

export const CustomButtonLabelLight: Story = {
args: {
theme: "light",
uiOptions: TRANSACTION_UI_OPTIONS.customButton,
},
parameters: {
backgrounds: { default: "light" },
docs: {
description: {
story: "Light theme version with custom button label 'Execute Now'.",
},
},
},
};
40 changes: 37 additions & 3 deletions packages/thirdweb/src/stories/Bridge/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ type TransactionUIOptions = Extract<UIOptions, { mode: "transaction" }>;

// UI Options for FundWallet mode
export const FUND_WALLET_UI_OPTIONS: Record<
"ethDefault" | "ethWithAmount" | "usdcDefault" | "uniLarge",
"ethDefault" | "ethWithAmount" | "usdcDefault" | "uniLarge" | "customButton",
FundWalletUIOptions
> = {
ethDefault: {
Expand Down Expand Up @@ -718,11 +718,21 @@ export const FUND_WALLET_UI_OPTIONS: Record<
initialAmount: "5",
mode: "fund_wallet" as const,
},
customButton: {
destinationToken: ETH,
initialAmount: "0.01",
metadata: {
description: "Test custom button label for funding",
title: "Custom Fund Wallet",
},
mode: "fund_wallet" as const,
buttonLabel: "Add Funds Now",
},
};

// UI Options for DirectPayment mode
export const DIRECT_PAYMENT_UI_OPTIONS: Record<
"digitalArt" | "concertTicket" | "subscription" | "sneakers" | "credits",
"digitalArt" | "concertTicket" | "subscription" | "sneakers" | "credits" | "customButton",
DirectPaymentUIOptions
> = {
concertTicket: {
Expand Down Expand Up @@ -794,11 +804,26 @@ export const DIRECT_PAYMENT_UI_OPTIONS: Record<
token: USDC,
},
},
customButton: {
metadata: {
description: "Test custom button label functionality",
image: PRODUCT_METADATA.digitalArt.image,
title: "Custom Button Test",
},
mode: "direct_payment" as const,
buttonLabel: "Purchase Now",
paymentInfo: {
amount: "0.05",
feePayer: "sender" as const,
sellerAddress: RECEIVER_ADDRESSES.primary,
token: ETH,
},
},
};

// UI Options for Transaction mode
export const TRANSACTION_UI_OPTIONS: Record<
"ethTransfer" | "erc20Transfer" | "contractInteraction",
"ethTransfer" | "erc20Transfer" | "contractInteraction" | "customButton",
TransactionUIOptions
> = {
contractInteraction: {
Expand All @@ -825,4 +850,13 @@ export const TRANSACTION_UI_OPTIONS: Record<
mode: "transaction" as const,
transaction: ethTransferTransaction,
},
customButton: {
metadata: {
description: "Test custom button label for transactions",
title: "Custom Transaction",
},
mode: "transaction" as const,
buttonLabel: "Execute Now",
transaction: ethTransferTransaction,
},
};
Loading