Skip to content

Commit 0349636

Browse files
committed
Add JSDoc, fix lint
1 parent 654cc82 commit 0349636

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,78 @@ export function SwapWidget(props: SwapWidgetProps) {
167167
);
168168
}
169169

170+
/**
171+
* A widget for swapping tokens with cross-chain support
172+
*
173+
* @param props - Props of type [`SwapWidgetProps`](https://portal.thirdweb.com/references/typescript/v5/SwapWidgetProps) to configure the SwapWidget component.
174+
*
175+
* @example
176+
* ### Basic usage
177+
*
178+
* By default, no tokens are selected in the widget UI.
179+
*
180+
* You can set specific tokens to buy or sell by default by passing the `prefill` prop. User can change these selections in the widget UI.
181+
*
182+
* ```tsx
183+
* <SwapWidget client={client} />
184+
* ```
185+
*
186+
* ### Set an ERC20 token to Buy by default
187+
*
188+
* ```tsx
189+
* <SwapWidget client={client} prefill={{
190+
* buyToken: {
191+
* // Base USDC
192+
* chainId: 8453,
193+
* tokenAddress: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
194+
* },
195+
* }} />
196+
* ```
197+
*
198+
* ### Set a native token to Sell by default
199+
*
200+
* By not specifying a `tokenAddress`, the native token will be used.
201+
*
202+
* ```tsx
203+
* <SwapWidget client={client} prefill={{
204+
* // Base native token (ETH)
205+
* sellToken: {
206+
* chainId: 8453,
207+
* },
208+
* }} />
209+
* ```
210+
*
211+
* ### Set amount and token to Buy by default
212+
*
213+
* ```tsx
214+
* <SwapWidget client={client} prefill={{
215+
* buyToken: {
216+
* // 0.1 Base USDC
217+
* chainId: 8453,
218+
* amount: "0.1",
219+
* tokenAddress: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
220+
* },
221+
* }} />
222+
* ```
223+
*
224+
* ### Set both buy and sell tokens by default
225+
*
226+
* ```tsx
227+
* <SwapWidget client={client} prefill={{
228+
* buyToken: {
229+
* // Base USDC
230+
* chainId: 8453,
231+
* tokenAddress: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
232+
* },
233+
* sellToken: {
234+
* // Polygon native token (MATIC)
235+
* chainId: 137,
236+
* },
237+
* }} />
238+
* ```
239+
*
240+
* @returns
241+
*/
170242
export function SwapWidgetContainer(props: {
171243
theme: SwapWidgetProps["theme"];
172244
className: string | undefined;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export function SelectToken(props: SelectTokenUIProps) {
118118
);
119119
}
120120

121-
export function SelectTokenUI(
121+
function SelectTokenUI(
122122
props: SelectTokenUIProps & {
123123
ownedTokens: TokenBalance[];
124124
allTokens: Token[];

0 commit comments

Comments
 (0)