Skip to content

Commit 1630701

Browse files
committed
Portal: Add BridgeWidget script docs (#8129)
<!-- ## 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 `BridgeWidget` functionality, updating UI components, and improving documentation for better user experience and clarity. ### Detailed summary - Added `BridgeWidget Script` route in sidebar. - Updated `Paragraph` and `Heading` components' margin classes. - Revised `Details` component structure. - Changed text references from `BuyWidget` to `SwapWidget`. - Enhanced documentation for `BridgeWidget Script` with detailed integration instructions. - Introduced new options for customizing the widget's appearance and behavior. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 10fb338 commit 1630701

File tree

10 files changed

+492
-23
lines changed

10 files changed

+492
-23
lines changed
151 KB
Loading
165 KB
Loading

apps/portal/src/app/bridge/bridge-widget-script/page.mdx

Lines changed: 467 additions & 0 deletions
Large diffs are not rendered by default.

apps/portal/src/app/bridge/page.mdx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ const preparedQuote = await Bridge.Buy.prepare({
102102
</TabsContent>
103103

104104
<TabsContent value="react">
105-
The quickest way to setup Bridge in your React app is with the [`BuyWidget`](/references/typescript/v5/widgets/BuyWidget) component.
106-
105+
The quickest way to setup Bridge in your React app is with the [`SwapWidget`](/references/typescript/v5/widgets/SwapWidget) component.
106+
107107
### Live Playground
108108

109109
<ArticleIconCard
110-
title="Payment Widgets Playground"
111-
description="Try out the Payment Widgets in our live playground"
110+
title="Swap Widget Playground"
111+
description="Try out the Swap Widget in our live playground"
112112
icon={ReactIcon}
113-
href="https://playground.thirdweb.com/connect/pay/transactions"
113+
href="https://playground.thirdweb.com/bridge/swap-widget"
114114
/>
115-
115+
116116
### Installation
117117

118118
Install the thirdweb SDK in your React project:
@@ -127,7 +127,7 @@ const preparedQuote = await Bridge.Buy.prepare({
127127

128128
### Create a Client
129129

130-
First, create a client file (e.g., `thirdwebClient.ts`) for reuse throughout your app:
130+
First, create a client file for reuse throughout your app:
131131

132132
```typescript
133133
// thirdwebClient.ts
@@ -140,7 +140,7 @@ const preparedQuote = await Bridge.Buy.prepare({
140140

141141
### Setup the Provider
142142

143-
Wrap your application with the ThirdwebProvider:
143+
Wrap your application with the `ThirdwebProvider`
144144

145145
```tsx
146146
// app.tsx / _app.tsx
@@ -155,21 +155,17 @@ const preparedQuote = await Bridge.Buy.prepare({
155155
}
156156
```
157157

158-
### Buy Widget
158+
### Add Swap Widget
159159

160-
Use the BuyWidget to let users purchase tokens:
160+
Use the SwapWidget to let users swap tokens
161161

162162
```tsx
163-
import { BuyWidget } from "thirdweb/react";
164-
import { base } from "thirdweb/chains";
163+
import { SwapWidget } from "thirdweb/react";
165164

166-
function PaymentComponent() {
165+
function Example() {
167166
return (
168-
<BuyWidget
167+
<SwapWidget
169168
client={client}
170-
chain={base}
171-
amount="10" // 10 USDC
172-
tokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
173169
/>
174170
);
175171
}

apps/portal/src/app/bridge/sidebar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export const sidebar: SideBar = {
3232
href: `${bridgeSlug}/routes`,
3333
name: "Get Routes",
3434
},
35+
{
36+
href: `${bridgeSlug}/bridge-widget-script`,
37+
name: "BridgeWidget Script",
38+
},
3539
],
3640
name: "Guides",
3741
},

apps/portal/src/components/Document/Details.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function Details(props: {
3030
<div className="flex gap-3">
3131
<span
3232
className={cn(
33-
"break-all font-bold text-foreground text-sm tracking-tight",
33+
"break-all text-foreground text-lg",
3434
"flex w-full gap-3 text-left font-semibold text-foreground group-hover:underline",
3535
props.headingClassName,
3636
)}
@@ -58,7 +58,9 @@ export function Details(props: {
5858
props.accordionTriggerClassName,
5959
)}
6060
>
61-
<div className="pl-4 [&>:first-child]:mt-0">{props.children}</div>
61+
<div className="pl-4 [&>:first-child]:mt-0 [&>*:last-child]:mb-0">
62+
{props.children}
63+
</div>
6264
</CustomAccordion>
6365
);
6466
}

apps/portal/src/components/Document/Heading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function Heading(props: {
4646
case 3: {
4747
return (
4848
<Anchor
49-
className={cn("mt-10 mb-3", props.anchorClassName)}
49+
className={cn("mt-10 mb-2", props.anchorClassName)}
5050
data-noindex={props.noIndex}
5151
id={props.anchorId}
5252
>

apps/portal/src/components/Document/Paragraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export function Paragraph(props: {
55
className?: string;
66
}) {
77
return (
8-
<p className={cn("mb-5 leading-7", props.className)}>{props.children}</p>
8+
<p className={cn("mb-3 leading-7", props.className)}>{props.children}</p>
99
);
1010
}

apps/portal/src/components/ui/tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const TabsTrigger = React.forwardRef<
3232
"border-transparent border-b text-muted-foreground ring-offset-700 transition-all",
3333
"hover:text-foreground hover:bg-accent data-[state=active]:text-foreground",
3434
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
35-
"data-[state=active]:before:opacity-100 before:absolute before:opacity-0 before:border-b before:left-0 before:right-0 before:bottom-[-5px] before:transition-opacity before:duration-300",
35+
"data-[state=active]:before:opacity-100 before:absolute before:opacity-0 before:border-b-2 before:border-foreground before:left-0 before:right-0 before:bottom-[-5px] before:transition-opacity before:duration-300",
3636
className,
3737
)}
3838
ref={ref}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type SwapWidgetProps = {
4848
*/
4949
client: ThirdwebClient;
5050
/**
51-
* The prefill Buy and/or Sell tokens for the swap widget. If `tokenAddress` is not provided, the native token will be used
51+
* Prefill Buy and/or Sell tokens for the swap widget. If `tokenAddress` is not provided, the native token will be used
5252
*
5353
* @example
5454
*

0 commit comments

Comments
 (0)