Skip to content

Commit 1405e11

Browse files
committed
add embed in chain, bridge page
1 parent 0d2d39d commit 1405e11

File tree

9 files changed

+94
-74
lines changed

9 files changed

+94
-74
lines changed

apps/dashboard/src/@/analytics/report.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ type TokenSwapParams = {
255255
buyTokenAddress: string;
256256
sellTokenChainId: number;
257257
sellTokenAddress: string;
258+
pageType: "asset" | "bridge" | "chain";
258259
};
259260

260261
/**
Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import { cn } from "@/lib/utils";
1616
import { parseError } from "@/utils/errorParser";
1717
import { getSDKTheme } from "@/utils/sdk-component-theme";
1818

19-
export function BuyTokenEmbed(props: {
19+
export function BuyAndSwapEmbed(props: {
2020
client: ThirdwebClient;
2121
chain: Chain;
22-
tokenAddress: string;
22+
tokenAddress: string | undefined;
23+
buyAmount: string | undefined;
24+
pageType: "asset" | "bridge" | "chain";
2325
}) {
2426
const { theme } = useTheme();
2527
const [tab, setTab] = useState<"buy" | "swap">("swap");
@@ -41,7 +43,7 @@ export function BuyTokenEmbed(props: {
4143

4244
{tab === "buy" && (
4345
<BuyWidget
44-
amount="1"
46+
amount={props.buyAmount || "1"}
4547
chain={props.chain}
4648
className="!rounded-2xl !w-full !border-none"
4749
title=""
@@ -51,19 +53,23 @@ export function BuyTokenEmbed(props: {
5153
}}
5254
onError={(e) => {
5355
const errorMessage = parseError(e);
54-
reportAssetBuyFailed({
55-
assetType: "coin",
56-
chainId: props.chain.id,
57-
contractType: "DropERC20",
58-
error: errorMessage,
59-
});
56+
if (props.pageType === "asset") {
57+
reportAssetBuyFailed({
58+
assetType: "coin",
59+
chainId: props.chain.id,
60+
contractType: "DropERC20",
61+
error: errorMessage,
62+
});
63+
}
6064
}}
6165
onSuccess={() => {
62-
reportAssetBuySuccessful({
63-
assetType: "coin",
64-
chainId: props.chain.id,
65-
contractType: "DropERC20",
66-
});
66+
if (props.pageType === "asset") {
67+
reportAssetBuySuccessful({
68+
assetType: "coin",
69+
chainId: props.chain.id,
70+
contractType: "DropERC20",
71+
});
72+
}
6773
}}
6874
theme={themeObj}
6975
tokenAddress={props.tokenAddress as `0x${string}`}
@@ -92,6 +98,7 @@ export function BuyTokenEmbed(props: {
9298
buyTokenAddress: quote.intent.destinationTokenAddress,
9399
sellTokenChainId: quote.intent.originChainId,
94100
sellTokenAddress: quote.intent.originTokenAddress,
101+
pageType: props.pageType,
95102
});
96103
}}
97104
onSuccess={(quote) => {
@@ -100,6 +107,7 @@ export function BuyTokenEmbed(props: {
100107
buyTokenAddress: quote.intent.destinationTokenAddress,
101108
sellTokenChainId: quote.intent.originChainId,
102109
sellTokenAddress: quote.intent.originTokenAddress,
110+
pageType: props.pageType,
103111
});
104112
}}
105113
onCancel={(quote) => {
@@ -108,6 +116,7 @@ export function BuyTokenEmbed(props: {
108116
buyTokenAddress: quote.intent.destinationTokenAddress,
109117
sellTokenChainId: quote.intent.originChainId,
110118
sellTokenAddress: quote.intent.originTokenAddress,
119+
pageType: props.pageType,
111120
});
112121
}}
113122
/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { GridPattern } from "@/components/ui/background-patterns";
2+
3+
export function GridPatternEmbedContainer(props: {
4+
children: React.ReactNode;
5+
}) {
6+
return (
7+
<div className=" sm:flex sm:justify-center w-full sm:border sm:border-dashed sm:bg-accent/20 sm:py-12 rounded-lg overflow-hidden relative">
8+
<GridPattern
9+
width={30}
10+
height={30}
11+
x={-1}
12+
y={-1}
13+
strokeDasharray={"4 2"}
14+
className="text-border dark:text-border/70 hidden lg:block"
15+
style={{
16+
maskImage:
17+
"linear-gradient(to bottom right,white,transparent,transparent)",
18+
}}
19+
/>
20+
<div className="sm:w-[420px] z-10">{props.children}</div>
21+
</div>
22+
);
23+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
"use client";
2-
import { useTheme } from "next-themes";
3-
import { defineChain, type ThirdwebClient } from "thirdweb";
2+
import type { ThirdwebClient } from "thirdweb";
43
import type { ChainMetadata } from "thirdweb/chains";
5-
import { BuyWidget } from "thirdweb/react";
6-
import { getSDKTheme } from "@/utils/sdk-component-theme";
4+
import { BuyAndSwapEmbed } from "@/components/blocks/BuyAndSwapEmbed";
5+
import { GridPatternEmbedContainer } from "@/components/blocks/grid-pattern-embed-container";
6+
import { defineDashboardChain } from "@/lib/defineDashboardChain";
77

88
export function BuyFundsSection(props: {
99
chain: ChainMetadata;
1010
client: ThirdwebClient;
1111
}) {
12-
const { theme } = useTheme();
1312
return (
14-
<section className="flex flex-col gap-4 items-center justify-center">
15-
<BuyWidget
16-
amount="0"
17-
// eslint-disable-next-line no-restricted-syntax
18-
chain={defineChain(props.chain.chainId)}
13+
<GridPatternEmbedContainer>
14+
<BuyAndSwapEmbed
1915
client={props.client}
20-
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
16+
// eslint-disable-next-line no-restricted-syntax
17+
chain={defineDashboardChain(props.chain.chainId, props.chain)}
18+
buyAmount={undefined}
19+
tokenAddress={undefined}
20+
pageType="chain"
2121
/>
22-
</section>
22+
</GridPatternEmbedContainer>
2323
);
2424
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import type { ThirdwebContract } from "thirdweb";
33
import type { ChainMetadata } from "thirdweb/chains";
44
import { getContractMetadata } from "thirdweb/extensions/common";
55
import { decimals, getActiveClaimCondition } from "thirdweb/extensions/erc20";
6-
import { GridPattern } from "@/components/ui/background-patterns";
6+
import { BuyAndSwapEmbed } from "@/components/blocks/BuyAndSwapEmbed";
7+
import { GridPatternEmbedContainer } from "@/components/blocks/grid-pattern-embed-container";
78
import { HAS_USED_DASHBOARD } from "@/constants/cookie";
89
import { resolveFunctionSelectors } from "@/lib/selectors";
910
import { AssetPageView } from "../_components/asset-page-view";
@@ -14,7 +15,6 @@ import { TokenDropClaim } from "./_components/claim-tokens/claim-tokens-ui";
1415
import { ContractAnalyticsOverview } from "./_components/contract-analytics/contract-analytics";
1516
import { DexScreener } from "./_components/dex-screener";
1617
import { mapChainIdToDexScreenerChainSlug } from "./_components/dex-screener-chains";
17-
import { BuyTokenEmbed } from "./_components/PayEmbedSection";
1818
import { RecentTransfers } from "./_components/RecentTransfers";
1919
import { fetchTokenInfoFromBridge } from "./_utils/fetch-coin-info";
2020
import { getCurrencyMeta } from "./_utils/getCurrencyMeta";
@@ -104,31 +104,17 @@ export async function ERC20PublicPage(props: {
104104

105105
{showBuyEmbed && (
106106
<div className="container max-w-7xl pb-10">
107-
<div className=" sm:flex sm:justify-center w-full sm:border sm:border-dashed sm:bg-accent/20 sm:py-12 rounded-lg overflow-hidden relative">
108-
<GridPattern
109-
width={30}
110-
height={30}
111-
x={-1}
112-
y={-1}
113-
strokeDasharray={"4 2"}
114-
className="text-border dark:text-border/70"
115-
style={{
116-
maskImage:
117-
"linear-gradient(to bottom right,white,transparent,transparent)",
118-
}}
107+
<GridPatternEmbedContainer>
108+
<BuyEmbed
109+
chainMetadata={props.chainMetadata}
110+
claimConditionMeta={claimConditionMeta}
111+
clientContract={props.clientContract}
112+
tokenAddress={props.clientContract.address}
113+
tokenDecimals={tokenDecimals}
114+
tokenName={contractMetadata.name}
115+
tokenSymbol={contractMetadata.symbol}
119116
/>
120-
<div className="sm:w-[420px] z-10">
121-
<BuyEmbed
122-
chainMetadata={props.chainMetadata}
123-
claimConditionMeta={claimConditionMeta}
124-
clientContract={props.clientContract}
125-
tokenAddress={props.clientContract.address}
126-
tokenDecimals={tokenDecimals}
127-
tokenName={contractMetadata.name}
128-
tokenSymbol={contractMetadata.symbol}
129-
/>
130-
</div>
131-
</div>{" "}
117+
</GridPatternEmbedContainer>
132118
</div>
133119
)}
134120

@@ -185,10 +171,12 @@ function BuyEmbed(props: {
185171
}) {
186172
if (!props.claimConditionMeta) {
187173
return (
188-
<BuyTokenEmbed
174+
<BuyAndSwapEmbed
189175
chain={props.clientContract.chain}
190176
client={props.clientContract.client}
191177
tokenAddress={props.clientContract.address}
178+
buyAmount={undefined}
179+
pageType="asset"
192180
/>
193181
);
194182
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"use client";
22

3-
import { useTheme } from "next-themes";
4-
import type { Address } from "thirdweb";
5-
import { BuyWidget, type TokenInfo } from "thirdweb/react";
3+
import type { TokenInfo } from "thirdweb/react";
4+
import { BuyAndSwapEmbed } from "@/components/blocks/BuyAndSwapEmbed";
65
import { useV5DashboardChain } from "@/hooks/chains/v5-adapter";
7-
import { getSDKTheme } from "@/utils/sdk-component-theme";
86
import { bridgeAppThirdwebClient } from "../../constants";
97

108
export function UniversalBridgeEmbed({
@@ -16,16 +14,17 @@ export function UniversalBridgeEmbed({
1614
token: TokenInfo | undefined;
1715
amount?: string;
1816
}) {
19-
const { theme } = useTheme();
2017
const chain = useV5DashboardChain(chainId || 1);
2118

2219
return (
23-
<BuyWidget
24-
client={bridgeAppThirdwebClient}
25-
amount={amount || "0"}
26-
chain={chain}
27-
tokenAddress={token?.address as Address | undefined}
28-
theme={getSDKTheme(theme === "light" ? "light" : "dark")}
29-
/>
20+
<div className="lg:w-[400px]">
21+
<BuyAndSwapEmbed
22+
client={bridgeAppThirdwebClient}
23+
chain={chain}
24+
buyAmount={amount}
25+
tokenAddress={token?.address}
26+
pageType="bridge"
27+
/>
28+
</div>
3029
);
3130
}

apps/dashboard/src/app/bridge/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function BridgePage({
4949
}
5050

5151
return (
52-
<div className="relative mx-auto flex h-screen w-full flex-col items-center justify-center overflow-hidden border py-10">
52+
<div className="relative mx-auto flex h-dvh w-full flex-col items-center justify-center overflow-hidden border py-10">
5353
<main className="container z-10 flex justify-center">
5454
<UniversalBridgeEmbed
5555
amount={amount as string}
@@ -69,7 +69,7 @@ export default async function BridgePage({
6969
{/* eslint-disable-next-line @next/next/no-img-element */}
7070
<img
7171
alt=""
72-
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
72+
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0 opacity-20"
7373
src="/assets/login/background.svg"
7474
/>
7575

@@ -79,17 +79,17 @@ export default async function BridgePage({
7979
<div className="absolute inset-0 bg-gradient-to-br from-green-500/5 to-transparent" />
8080
<div className="relative flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
8181
<div className="flex flex-col gap-1">
82-
<h3 className="font-medium text-lg">
83-
Get Started with thirdweb Payments
82+
<h3 className="font-semibold text-base tracking-tight">
83+
Get Started with thirdweb Bridge
8484
</h3>
8585
<p className="text-muted-foreground text-sm">
86-
Simple, instant, and secure payments across any token and
87-
chain.
86+
thirdweb Bridge allows developers to easily bridge and swap
87+
tokens between chains and wallets.
8888
</p>
8989
</div>
9090
<a
9191
className="inline-flex items-center gap-2 rounded-md bg-green-600 px-4 py-2 font-medium text-sm text-white transition-all hover:bg-green-600/90 hover:shadow-sm"
92-
href="https://portal.thirdweb.com/payments"
92+
href="https://portal.thirdweb.com/bridge"
9393
rel="noopener noreferrer"
9494
target="_blank"
9595
>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export function FundWallet({
360360
{showThirdwebBranding ? (
361361
<div>
362362
<Spacer y="md" />
363-
<PoweredByThirdweb />
363+
<PoweredByThirdweb link="https://playground.thirdweb.com/payments/fund-wallet" />
364364
</div>
365365
) : null}
366366
<Spacer y="md" />

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export function SwapUI(props: SwapUIProps) {
398398
{props.showThirdwebBranding ? (
399399
<div>
400400
<Spacer y="md" />
401-
<PoweredByThirdweb />
401+
<PoweredByThirdweb link="https://thirdweb.com/monetize/bridge" />
402402
</div>
403403
) : null}
404404
</Container>

0 commit comments

Comments
 (0)