Skip to content

Commit 4191902

Browse files
committed
Add bridge widget iframe docs, update path, link to docs (#8528)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `Bridge` and `Bridge Widget` functionalities, improving UI elements, adding new features, and updating documentation. It includes modifications to components, styling adjustments, and expanded capabilities for currency selection. ### Detailed summary - Updated `Sidebar.tsx` to remove padding. - Changed `page.mdx` headers from "Key Features" to "Features". - Enhanced `reportBridgePageLinkClick` to include "integrate-bridge-widget". - Modified `page.tsx` to include client ID instructions. - Adjusted header font sizes in `header.tsx`. - Improved `bridgeRedirects` to include new paths. - Updated `bridge-widget` links in `sidebar.tsx`. - Added `persistTokenSelections` and `currency` props to `UniversalBridgeEmbed`. - Created `IframeCodePreview` component for iframe integration documentation. - Added a new `BadgeLink` component for better user interaction. - Expanded `BuyAndSwapEmbed` props to support currency and token selections. - Updated documentation for `BridgeWidget` and `Iframe` integrations with examples. - Enhanced `BridgePageUI` to include the new `AddBridgeWidgetLink`. - Introduced multiple currency options for fiat values in widget interfaces. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Bridge widget available via Iframe, Script, and React component * Fiat currency selection for buy/swap widgets * Token selection persistence option * "Add Bridge widget" integration link added to Bridge page * **Documentation** * New detailed guides and examples for Iframe, Script, and React integration * Code preview and embedding examples added * **Style** * Typography, spacing, and layout refinements across Bridge pages * Navigation reorganized into a Bridge Widget group * **Chores** * Added redirects for Bridge widget paths <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 56eb1d2 commit 4191902

24 files changed

Lines changed: 467 additions & 28 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ export function reportProductFeedback(properties: {
683683
*
684684
*/
685685
export function reportBridgePageLinkClick(params: {
686-
linkType: "bridge-docs" | "trending-tokens";
686+
linkType: "bridge-docs" | "trending-tokens" | "integrate-bridge-widget";
687687
}) {
688688
posthog.capture("bridge page link clicked", params);
689689
}

apps/dashboard/src/@/components/blocks/BuyAndSwapEmbed.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import { useTheme } from "next-themes";
55
import { useEffect, useMemo, useRef, useState } from "react";
66
import { defineChain } from "thirdweb";
7-
import { BuyWidget, SwapWidget } from "thirdweb/react";
7+
import {
8+
BuyWidget,
9+
type SupportedFiatCurrency,
10+
SwapWidget,
11+
} from "thirdweb/react";
812
import type { Wallet } from "thirdweb/wallets";
913
import {
1014
reportAssetBuyCancelled,
@@ -34,6 +38,7 @@ import { getConfiguredThirdwebClient } from "../../constants/thirdweb.server";
3438
type PageType = "asset" | "bridge" | "chain" | "bridge-iframe";
3539

3640
export type BuyAndSwapEmbedProps = {
41+
persistTokenSelections?: boolean;
3742
buyTab:
3843
| {
3944
buyToken:
@@ -65,6 +70,7 @@ export type BuyAndSwapEmbedProps = {
6570
| undefined;
6671
pageType: PageType;
6772
wallets?: Wallet[];
73+
currency?: SupportedFiatCurrency;
6874
};
6975

7076
export function BuyAndSwapEmbed(props: BuyAndSwapEmbedProps) {
@@ -118,6 +124,7 @@ export function BuyAndSwapEmbed(props: BuyAndSwapEmbedProps) {
118124

119125
{tab === "buy" && (
120126
<BuyWidget
127+
currency={props.currency || "USD"}
121128
amount={props.buyTab?.buyToken?.amount || "1"}
122129
chain={
123130
props.buyTab?.buyToken?.chainId
@@ -241,6 +248,8 @@ export function BuyAndSwapEmbed(props: BuyAndSwapEmbedProps) {
241248

242249
{tab === "swap" && (
243250
<SwapWidget
251+
currency={props.currency || "USD"}
252+
persistTokenSelections={props.persistTokenSelections}
244253
client={client}
245254
theme={themeObj}
246255
className="!rounded-2xl !border-none"

apps/dashboard/src/app/bridge/(general)/components/bridge-page.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import RoutesImage from "../assets/routes.png";
88
import TokensImage from "../assets/tokens.png";
99
import { bridgeStats, bridgeStatsNumbers } from "../data";
1010
import { AnimatedNumbers } from "./client/animated-numbers";
11+
import { AddBridgeWidgetLink } from "./client/badge-link";
1112
import { UniversalBridgeEmbed } from "./client/UniversalBridgeEmbed";
1213
import { BridgePageHeader } from "./header";
1314

@@ -29,6 +30,12 @@ export function BridgePageUI(props: {
2930
/>
3031
</div>
3132

33+
<div className="container max-w-2xl flex justify-center">
34+
<AddBridgeWidgetLink />
35+
</div>
36+
37+
<div className="h-10" />
38+
3239
<HeadingSection title={props.title} />
3340

3441
<div className="h-20 lg:h-40" />
@@ -43,7 +50,7 @@ export function BridgePageUI(props: {
4350
function HeadingSection(props: { title: React.ReactNode }) {
4451
return (
4552
<div className="container">
46-
<div className="mb-3 lg:mb-6">{props.title}</div>
53+
<div className="mb-3 lg:mb-5">{props.title}</div>
4754

4855
<p className="text-muted-foreground text-sm text-pretty text-center lg:text-lg mb-6 lg:mb-8">
4956
Seamlessly move your assets across {bridgeStats.supportedChains} chains
@@ -81,9 +88,9 @@ function DataSquare(props: {
8188
imageClassName?: string;
8289
}) {
8390
return (
84-
<div className="py-2 lg:py-0 size-full lg:size-[220px] rounded-xl border hover:bg-card bg-card/50 relative shrink-0 overflow-hidden">
91+
<div className="py-2 lg:py-0 size-full lg:size-[200px] rounded-2xl border hover:bg-card bg-card/50 relative shrink-0 overflow-hidden">
8592
<div className="p-4">
86-
<div className="flex items-center gap-1 text-3xl lg:text-5xl font-medium tracking-tight font-mono mb-1 h-[45px] lg:h-[56px]">
93+
<div className="flex items-center gap-1 text-3xl lg:text-4xl font-semibold tracking-tight mb-1 h-[45px]">
8794
<AnimatedNumbers
8895
value={props.data}
8996
format={props.format}

apps/dashboard/src/app/bridge/(general)/components/client/UniversalBridgeEmbed.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import type { SupportedFiatCurrency } from "thirdweb/react";
34
import { createWallet } from "thirdweb/wallets";
45
import {
56
BuyAndSwapEmbed,
@@ -19,12 +20,16 @@ export const bridgeWallets = [
1920
];
2021

2122
export function UniversalBridgeEmbed(props: {
23+
persistTokenSelections?: boolean;
2224
buyTab: BuyAndSwapEmbedProps["buyTab"];
2325
swapTab: BuyAndSwapEmbedProps["swapTab"];
2426
pageType: "bridge" | "bridge-iframe";
27+
currency?: SupportedFiatCurrency;
2528
}) {
2629
return (
2730
<BuyAndSwapEmbed
31+
persistTokenSelections={props.persistTokenSelections}
32+
currency={props.currency}
2833
buyTab={props.buyTab}
2934
swapTab={props.swapTab}
3035
pageType={props.pageType}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use client";
2+
import { ArrowUpRightIcon } from "lucide-react";
3+
import Link from "next/link";
4+
import { reportBridgePageLinkClick } from "@/analytics/report";
5+
6+
export function AddBridgeWidgetLink() {
7+
return (
8+
<BadgeLink
9+
href="https://portal.thirdweb.com/bridge/bridge-widget"
10+
label="Add Bridge widget in your app"
11+
onClick={() => {
12+
reportBridgePageLinkClick({ linkType: "integrate-bridge-widget" });
13+
}}
14+
/>
15+
);
16+
}
17+
18+
function BadgeLink(props: {
19+
href: string;
20+
label: string;
21+
onClick?: () => void;
22+
}) {
23+
return (
24+
<Link
25+
href={props.href}
26+
className="text-sm text-foreground bg-accent/50 rounded-full px-4 py-2 border hover:bg-accent flex items-center gap-2"
27+
target="_blank"
28+
onClick={props.onClick}
29+
>
30+
{props.label}
31+
<ArrowUpRightIcon className="size-4 text-foreground" />
32+
</Link>
33+
);
34+
}

apps/dashboard/src/app/bridge/(general)/components/header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import { bridgeWallets } from "./client/UniversalBridgeEmbed";
1313

1414
export function BridgePageHeader(props: { containerClassName?: string }) {
1515
return (
16-
<div className="border-b border-border/70">
16+
<div>
1717
<header
1818
className={cn(
19-
"container flex max-w-7xl justify-between py-3 lg:py-4",
19+
"container flex max-w-5xl justify-between py-3 lg:py-5",
2020
props.containerClassName,
2121
)}
2222
>

apps/dashboard/src/app/bridge/(general)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default async function Page(props: {
6060
: undefined,
6161
}}
6262
title={
63-
<h1 className="text-3xl md:text-6xl font-semibold tracking-tighter text-balance text-center">
63+
<h1 className="text-3xl md:text-5xl font-semibold tracking-tighter text-balance text-center">
6464
Bridge and Swap tokens <br className="max-sm:hidden" /> across any
6565
chain, instantly
6666
</h1>
File renamed without changes.

apps/dashboard/src/app/bridge/embed/opengraph-image.png renamed to apps/dashboard/src/app/bridge/widget/opengraph-image.png

File renamed without changes.

apps/dashboard/src/app/bridge/embed/page.tsx renamed to apps/dashboard/src/app/bridge/widget/page.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { isAddress, NATIVE_TOKEN_ADDRESS } from "thirdweb";
33
import { UniversalBridgeEmbed } from "../(general)/components/client/UniversalBridgeEmbed";
44
import { bridgeStats } from "../(general)/data";
55
import "@workspace/ui/global.css";
6+
import type { SupportedFiatCurrency } from "thirdweb/react";
67
import { NEXT_PUBLIC_BRIDGE_IFRAME_CLIENT_ID } from "@/constants/public-envs";
78
import { BridgeProviders } from "../(general)/components/client/Providers.client";
89

@@ -38,15 +39,28 @@ export default async function Page(props: {
3839
const buyChain = parse(searchParams.outputChain, onlyNumber);
3940
const buyCurrency = parse(searchParams.outputCurrency, onlyAddress);
4041

42+
const persistTokenSelections =
43+
parse(searchParams.persistTokenSelections, (v) =>
44+
v === "false" ? "false" : "true",
45+
) || "true";
46+
4147
const theme =
4248
parse(searchParams.theme, (v) => (v === "light" ? "light" : "dark")) ||
4349
"dark";
4450

51+
const currency = parse(searchParams.currency, (v) =>
52+
VALID_CURRENCIES.includes(v as SupportedFiatCurrency)
53+
? (v as SupportedFiatCurrency)
54+
: undefined,
55+
);
56+
4557
return (
4658
<Providers theme={theme}>
4759
<div className="flex items-center justify-center min-h-screen py-6 bg-background">
4860
<UniversalBridgeEmbed
61+
persistTokenSelections={persistTokenSelections === "true"}
4962
pageType="bridge-iframe"
63+
currency={currency}
5064
buyTab={{
5165
buyToken: buyChain
5266
? {
@@ -75,6 +89,32 @@ export default async function Page(props: {
7589
);
7690
}
7791

92+
const VALID_CURRENCIES: SupportedFiatCurrency[] = [
93+
"USD",
94+
"EUR",
95+
"GBP",
96+
"JPY",
97+
"KRW",
98+
"CNY",
99+
"INR",
100+
"NOK",
101+
"SEK",
102+
"CHF",
103+
"AUD",
104+
"CAD",
105+
"NZD",
106+
"MXN",
107+
"BRL",
108+
"CLP",
109+
"CZK",
110+
"DKK",
111+
"HKD",
112+
"HUF",
113+
"IDR",
114+
"ILS",
115+
"ISK",
116+
];
117+
78118
function parse<T>(
79119
value: string | string[] | undefined,
80120
fn: (value: string) => T | undefined,

0 commit comments

Comments
 (0)