11'use client' ;
22
3+ import { WalletAdvancedDefault } from '@coinbase/onchainkit/wallet' ;
4+ import { Buy } from '@coinbase/onchainkit/buy' ;
5+ import { Checkout , CheckoutButton } from '@coinbase/onchainkit/checkout' ;
6+ import { SwapDefault } from '@coinbase/onchainkit/swap' ;
37import { useCallback , useEffect , useMemo , useState } from 'react' ;
48import { createHighlighter } from 'shiki' ;
59import sun from './sun.svg' ;
610import moon from './moon.svg' ;
711import Image , { StaticImageData } from 'next/image' ;
8- import Button from 'apps/web/src/components/base-org/Button' ;
912import { Icon } from 'apps/web/src/components/Icon/Icon' ;
1013import Title from 'apps/web/src/components/base-org/typography/Title' ;
1114import { TitleLevel } from 'apps/web/src/components/base-org/typography/Title/types' ;
1215import classNames from 'classnames' ;
13- import { WalletAdvancedDefault , WalletDefault } from '@coinbase/onchainkit/wallet' ;
1416import { DynamicCryptoProviders } from 'apps/web/app/CryptoProviders.dynamic' ;
17+ import type { Token } from '@coinbase/onchainkit/token' ;
18+
19+ type Tab = 'onboard' | 'onramp' | 'pay' | 'swap' | 'earn' ;
20+
21+ const degenToken : Token [ ] = [
22+ {
23+ name : 'DEGEN' ,
24+ address : '0x4ed4e862860bed51a9570b96d89af5e1b0efefed' ,
25+ symbol : 'DEGEN' ,
26+ decimals : 18 ,
27+ image :
28+ 'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/3b/bf/3bbf118b5e6dc2f9e7fc607a6e7526647b4ba8f0bea87125f971446d57b296d2-MDNmNjY0MmEtNGFiZi00N2I0LWIwMTItMDUyMzg2ZDZhMWNm' ,
29+ chainId : 8453 ,
30+ } ,
31+ ] ;
1532
16- type Tab = 'onboard' | 'onramp' | 'pay' ;
33+ const ethToken : Token [ ] = [
34+ {
35+ name : 'ETH' ,
36+ address : '' ,
37+ symbol : 'ETH' ,
38+ decimals : 18 ,
39+ image : 'https://wallet-api-production.s3.amazonaws.com/uploads/tokens/eth_288.png' ,
40+ chainId : 8453 ,
41+ } ,
42+ ] ;
1743
1844const styles = `
1945 .code-snippet::-webkit-scrollbar {
@@ -92,6 +118,43 @@ function CheckoutDemo() {
92118 <CheckoutButton coinbaseBranded={true}/>
93119 </Checkout>
94120 )
121+ }` ,
122+ swap : `import { SwapDefault } from '@coinbase/onchainkit/swap';
123+ import type { Token } from '@coinbase/onchainkit/token';
124+
125+ function SwapDemo() {
126+ const { address } = useAccount();
127+ const ETHToken: Token = {
128+ address: "",
129+ chainId: 8453,
130+ decimals: 18,
131+ name: "Ethereum",
132+ symbol: "ETH",
133+ image: "",
134+ };
135+
136+ const degenToken: Token[] = [{
137+ name: 'DEGEN',
138+ address: '0x4ed4e862860bed51a9570b96d89af5e1b0efefed',
139+ symbol: 'DEGEN',
140+ decimals: 18,
141+ image: 'https://d3r81g40ycuhqg.cloudfront.net/wallet/wais/3b/bf/3bbf118b5e6dc2f9e7fc607a6e7526647b4ba8f0bea87125f971446d57b296d2-MDNmNjY0MmEtNGFiZi00N2I0LWIwMTItMDUyMzg2ZDZhMWNm',
142+ chainId: 8453,
143+ }];
144+
145+ const swappableTokens: Token[] = [ETHToken, USDCToken];
146+
147+ return (
148+ <SwapDefault
149+ from={swappableTokens}
150+ to={swappableTokens}
151+ />
152+ )
153+ }` ,
154+ earn : `import { Earn } from '@coinbase/onchainkit/earn';
155+
156+ function EarnDemo() {
157+ return <Earn />;
95158}` ,
96159} ;
97160
@@ -122,17 +185,17 @@ export function LiveDemo() {
122185 case 'onboard' :
123186 return < WalletAdvancedDefault /> ;
124187 case 'onramp' :
125- return (
126- < Button className = "h-auto bg-[#0052FF] px-4 py-2 text-white hover:bg-[#0052FF]/70" >
127- Buy Crypto
128- </ Button >
129- ) ;
188+ return < Buy toToken = { degenToken } /> ;
130189 case 'pay' :
131190 return (
132- < Button className = "h-auto bg-[#0052FF] px-4 py-2 text-white hover:bg-[#0052FF]/70 ">
133- Pay with Crypto
134- </ Button >
191+ < Checkout productId = "my-product-id ">
192+ < CheckoutButton coinbaseBranded />
193+ </ Checkout >
135194 ) ;
195+ case 'swap' :
196+ return < SwapDefault to = { degenToken } from = { ethToken } /> ;
197+ case 'earn' :
198+ return < div > Earn yield</ div > ;
136199 default :
137200 return null ;
138201 }
@@ -172,18 +235,18 @@ export function LiveDemo() {
172235 setHighlightedCode ( cleanedCode ) ;
173236 }
174237
175- highlightCode ( ) ;
176- } , [ isMounted , activeTab , codeSnippets ] ) ;
238+ void highlightCode ( ) ;
239+ } , [ isMounted , activeTab ] ) ;
177240
178241 const handleCopy = useCallback ( ( ) => {
179- navigator . clipboard . writeText ( codeSnippets [ activeTab ] ) ;
242+ void navigator . clipboard . writeText ( codeSnippets [ activeTab ] ) ;
180243 setCopied ( true ) ;
181244 setTimeout ( ( ) => setCopied ( false ) , 2000 ) ;
182245 } , [ activeTab ] ) ;
183246
184- const toggleTheme = ( ) => {
247+ const toggleTheme = useCallback ( ( ) => {
185248 setTheme ( ( prev ) => ( prev === 'dark' ? 'light' : 'dark' ) ) ;
186- } ;
249+ } , [ ] ) ;
187250
188251 if ( ! isMounted ) {
189252 return (
@@ -210,7 +273,7 @@ export function LiveDemo() {
210273 </ div >
211274 < div
212275 className = { classNames (
213- 'overflow-hidden rounded-xl border transition-colors' ,
276+ 'rounded-xl border transition-colors' ,
214277 theme === 'dark'
215278 ? 'border-dark-palette-line/50 bg-black'
216279 : 'border-dark-palette-line/50 bg-white' ,
@@ -224,6 +287,7 @@ export function LiveDemo() {
224287 < div className = "no-scrollbar flex items-center space-x-8 overflow-x-auto" >
225288 < div className = "flex space-x-8 px-1" >
226289 < button
290+ type = "button"
227291 onClick = { ( ) => setActiveTab ( 'onboard' ) }
228292 className = { classNames (
229293 'whitespace-nowrap rounded-lg text-base font-medium transition-colors' ,
@@ -233,6 +297,7 @@ export function LiveDemo() {
233297 Sign in
234298 </ button >
235299 < button
300+ type = "button"
236301 onClick = { ( ) => setActiveTab ( 'onramp' ) }
237302 className = { classNames (
238303 'whitespace-nowrap rounded-lg text-base font-medium transition-colors' ,
@@ -242,6 +307,7 @@ export function LiveDemo() {
242307 Onramp
243308 </ button >
244309 < button
310+ type = "button"
245311 onClick = { ( ) => setActiveTab ( 'pay' ) }
246312 className = { classNames (
247313 'whitespace-nowrap rounded-lg text-base font-medium transition-colors' ,
@@ -250,11 +316,32 @@ export function LiveDemo() {
250316 >
251317 Pay
252318 </ button >
319+ < button
320+ type = "button"
321+ onClick = { ( ) => setActiveTab ( 'swap' ) }
322+ className = { classNames (
323+ 'whitespace-nowrap rounded-lg text-base font-medium transition-colors' ,
324+ activeTab === 'swap' ? buttonClasses . active : buttonClasses . inactive ,
325+ ) }
326+ >
327+ Swap
328+ </ button >
329+ < button
330+ type = "button"
331+ onClick = { ( ) => setActiveTab ( 'earn' ) }
332+ className = { classNames (
333+ 'whitespace-nowrap rounded-lg text-base font-medium transition-colors' ,
334+ activeTab === 'earn' ? buttonClasses . active : buttonClasses . inactive ,
335+ ) }
336+ >
337+ Earn yield
338+ </ button >
253339 </ div >
254340 </ div >
255341
256342 < div className = "flex items-center space-x-2" >
257343 < button
344+ type = "button"
258345 onClick = { handleCopy }
259346 className = { classNames (
260347 'rounded-lg border p-2 transition-colors' ,
@@ -272,6 +359,7 @@ export function LiveDemo() {
272359 ) }
273360 </ button >
274361 < button
362+ type = "button"
275363 onClick = { toggleTheme }
276364 className = { classNames (
277365 'rounded-lg border p-2 transition-colors' ,
@@ -291,15 +379,16 @@ export function LiveDemo() {
291379
292380 < div className = "grid grid-cols-1 lg:grid-cols-2" >
293381 < div
294- className = { `flex h-[300px] items-center justify-center border-b p-8 transition-colors lg:h-[500px] lg:border-b-0 lg:border-r lg:p-12 ${
295- theme === 'dark' ? 'border-dark-palette-line/50' : 'border-dark-palette-line/50'
296- } `}
382+ className = { classNames (
383+ 'h-[300px] p-8 lg:h-[500px] lg:p-12' ,
384+ 'border-b lg:border-b-0 lg:border-r' ,
385+ 'flex items-center justify-center transition-colors' ,
386+ 'overflow-visible' ,
387+ theme === 'dark' ? 'border-dark-palette-line/50' : 'border-dark-palette-line/50' ,
388+ ) }
297389 >
298- < DynamicCryptoProviders >
299- < WalletDefault />
300- </ DynamicCryptoProviders >
390+ < DynamicCryptoProviders > { demoComponent } </ DynamicCryptoProviders >
301391 </ div >
302-
303392 < div className = "h-[300px] py-6 pl-6 pr-1 lg:h-[500px]" >
304393 < div className = { `${ theme } relative h-full` } >
305394 { highlightedCode ? (
0 commit comments