Skip to content

Commit 6401737

Browse files
committed
feat: adds BuyEmbed
1 parent 76c0e00 commit 6401737

File tree

5 files changed

+587
-187
lines changed

5 files changed

+587
-187
lines changed

apps/playground-web/src/app/connect/pay/fund-wallet/page.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PageLayout } from "@/components/blocks/APIHeader";
22
import { CodeExample } from "@/components/code/code-example";
3-
import { StyledPayEmbedPreview } from "@/components/pay/embed";
43
import ThirdwebProvider from "@/components/thirdweb-provider";
4+
import { StyledBuyEmbedPreview } from "@/components/universal-bridge/buy";
55
import { metadataBase } from "@/lib/constants";
66
import type { Metadata } from "next";
77

@@ -35,7 +35,7 @@ function StyledPayEmbed() {
3535
return (
3636
<CodeExample
3737
header={{
38-
title: " Buy Crypto",
38+
title: "Buy Crypto",
3939
description: (
4040
<>
4141
Inline component that allows users to buy any currency.
@@ -44,26 +44,19 @@ function StyledPayEmbed() {
4444
</>
4545
),
4646
}}
47-
preview={<StyledPayEmbedPreview />}
47+
preview={<StyledBuyEmbedPreview />}
4848
code={`\
49-
import { PayEmbed } from "thirdweb/react";
49+
import { BuyEmbed } from "thirdweb/react";
5050
5151
function App() {
5252
return (
53-
<PayEmbed
54-
client={client}
55-
payOptions={{
56-
mode: "fund_wallet",
57-
metadata: {
58-
name: "Get funds",
59-
},
60-
prefillBuy: {
61-
chain: base,
62-
amount: "0.01",
63-
},
64-
// ... theme, currency, amounts, payment methods, etc.
65-
}}
66-
/>
53+
<BuyEmbed
54+
client={THIRDWEB_CLIENT}
55+
title="Get Funds"
56+
tokenAddress={NATIVE_TOKEN_ADDRESS}
57+
chain={arbitrum}
58+
amount={toWei("0.002")}
59+
/>
6760
);
6861
}`}
6962
lang="tsx"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use client";
2+
3+
import { THIRDWEB_CLIENT } from "@/lib/client";
4+
import { useTheme } from "next-themes";
5+
import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb";
6+
import { arbitrum } from "thirdweb/chains";
7+
import { BuyEmbed } from "thirdweb/react";
8+
9+
export function StyledBuyEmbedPreview() {
10+
const { theme } = useTheme();
11+
12+
return (
13+
<div className="flex flex-col items-center justify-center">
14+
<div className="h-10" />
15+
<BuyEmbed
16+
client={THIRDWEB_CLIENT}
17+
theme={theme === "light" ? "light" : "dark"}
18+
title="Get Funds"
19+
tokenAddress={NATIVE_TOKEN_ADDRESS}
20+
chain={arbitrum}
21+
amount={toWei("0.002")}
22+
/>
23+
</div>
24+
);
25+
}

packages/thirdweb/src/exports/react.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ export type { AutoConnectProps } from "../wallets/connection/types.js";
130130
// auth
131131
export type { SiweAuthOptions } from "../react/core/hooks/auth/useSiweAuth.js";
132132

133+
export {
134+
BuyEmbed,
135+
type BuyEmbedProps,
136+
} from "../react/web/ui/BuyEmbed.js";
133137
export {
134138
PayEmbed,
135139
type PayEmbedProps,

0 commit comments

Comments
 (0)