Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
467 changes: 467 additions & 0 deletions apps/portal/src/app/bridge/bridge-widget-script/page.mdx

Large diffs are not rendered by default.

30 changes: 13 additions & 17 deletions apps/portal/src/app/bridge/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ const preparedQuote = await Bridge.Buy.prepare({
</TabsContent>

<TabsContent value="react">
The quickest way to setup Bridge in your React app is with the [`BuyWidget`](/references/typescript/v5/widgets/BuyWidget) component.
The quickest way to setup Bridge in your React app is with the [`SwapWidget`](/references/typescript/v5/widgets/SwapWidget) component.

### Live Playground

<ArticleIconCard
title="Payment Widgets Playground"
description="Try out the Payment Widgets in our live playground"
title="Swap Widget Playground"
description="Try out the Swap Widget in our live playground"
icon={ReactIcon}
href="https://playground.thirdweb.com/connect/pay/transactions"
href="https://playground.thirdweb.com/bridge/swap-widget"
/>

### Installation

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

### Create a Client

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

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

### Setup the Provider

Wrap your application with the ThirdwebProvider:
Wrap your application with the `ThirdwebProvider`

```tsx
// app.tsx / _app.tsx
Expand All @@ -155,21 +155,17 @@ const preparedQuote = await Bridge.Buy.prepare({
}
```

### Buy Widget
### Add Swap Widget

Use the BuyWidget to let users purchase tokens:
Use the SwapWidget to let users swap tokens

```tsx
import { BuyWidget } from "thirdweb/react";
import { base } from "thirdweb/chains";
import { SwapWidget } from "thirdweb/react";

function PaymentComponent() {
function Example() {
return (
<BuyWidget
<SwapWidget
client={client}
chain={base}
amount="10" // 10 USDC
tokenAddress="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions apps/portal/src/app/bridge/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const sidebar: SideBar = {
href: `${bridgeSlug}/routes`,
name: "Get Routes",
},
{
href: `${bridgeSlug}/bridge-widget-script`,
name: "BridgeWidget Script",
},
],
name: "Guides",
},
Expand Down
6 changes: 4 additions & 2 deletions apps/portal/src/components/Document/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function Details(props: {
<div className="flex gap-3">
<span
className={cn(
"break-all font-bold text-foreground text-sm tracking-tight",
"break-all text-foreground text-lg",
"flex w-full gap-3 text-left font-semibold text-foreground group-hover:underline",
props.headingClassName,
)}
Expand Down Expand Up @@ -58,7 +58,9 @@ export function Details(props: {
props.accordionTriggerClassName,
)}
>
<div className="pl-4 [&>:first-child]:mt-0">{props.children}</div>
<div className="pl-4 [&>:first-child]:mt-0 [&>*:last-child]:mb-0">
{props.children}
</div>
</CustomAccordion>
);
}
2 changes: 1 addition & 1 deletion apps/portal/src/components/Document/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function Heading(props: {
case 3: {
return (
<Anchor
className={cn("mt-10 mb-3", props.anchorClassName)}
className={cn("mt-10 mb-2", props.anchorClassName)}
data-noindex={props.noIndex}
id={props.anchorId}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/src/components/Document/Paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function Paragraph(props: {
className?: string;
}) {
return (
<p className={cn("mb-5 leading-7", props.className)}>{props.children}</p>
<p className={cn("mb-3 leading-7", props.className)}>{props.children}</p>
);
}
2 changes: 1 addition & 1 deletion apps/portal/src/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TabsTrigger = React.forwardRef<
"border-transparent border-b text-muted-foreground ring-offset-700 transition-all",
"hover:text-foreground hover:bg-accent data-[state=active]:text-foreground",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
"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",
"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",
className,
)}
ref={ref}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type SwapWidgetProps = {
*/
client: ThirdwebClient;
/**
* The prefill Buy and/or Sell tokens for the swap widget. If `tokenAddress` is not provided, the native token will be used
* Prefill Buy and/or Sell tokens for the swap widget. If `tokenAddress` is not provided, the native token will be used
*
* @example
*
Expand Down
Loading