-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add template #1 - quickstart #4
Changes from all commits
cc04fd7
04bfa48
0aad473
b33cf9a
a85c601
af1f3c6
4e39b2b
4b24408
27c1090
00cf4e0
ffdf1c1
38d678a
f2ad6c3
4235be9
3bd0308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# See https://www.coinbase.com/developer-platform/products/base-node | ||
NEXT_PUBLIC_CDP_API_KEY="GET_FROM_COINBASE_DEVELOPER_PLATFORM" | ||
ENVIRONMENT=localhost | ||
ENVIRONMENT=localhost | ||
# See https://cloud.walletconnect.com/ | ||
WALLET_CONNECTOR_PROJECT_ID="GET_FROM_WALLET_CONNECT" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
env: { | ||
WALLET_CONNECTOR_PROJECT_ID: process.env.WALLET_CONNECTOR_PROJECT_ID, | ||
}, | ||
}; | ||
|
||
module.exports = nextConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,4 +62,25 @@ ul { | |
#__next { | ||
position: relative; | ||
z-index: 0; | ||
} | ||
|
||
.ockConnectWallet_Container span { | ||
color: #030712; | ||
} | ||
|
||
/* i believe this is necessary because | ||
of a div added by rainbowkit provider */ | ||
body > div { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see junior developer tripping on this. Can we do this in a more simple way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm i couldn't really think of anything better because it is a hidden div without a classname. do you have an idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so are you trying to target what in particular? the first |
||
height: 100%; | ||
max-width: 100vw; | ||
box-sizing: border-box; | ||
padding: 0 10px; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
|
||
.templateSection > div { | ||
max-width: 100%;; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
'use client'; | ||
import WalletComponents from '../components/WalletComponents'; | ||
import Footer from 'src/components/Footer'; | ||
import TransactionWrapper from 'src/components/TransactionWrapper'; | ||
import WalletWrapper from 'src/components/WalletWrapper'; | ||
import { useAccount } from 'wagmi'; | ||
import LoginButton from '../components/LoginButton'; | ||
import SignupButton from '../components/SignupButton'; | ||
|
||
export default function Page() { | ||
const { address } = useAccount(); | ||
|
||
return ( | ||
<div className="flex w-96 flex-col md:w-[600px]"> | ||
<section className="mb-6 flex w-full flex-col border-sky-800 border-b pb-6"> | ||
<aside className="mb-6 flex"> | ||
<h2 className="text-2xl">Onchain App Template</h2> | ||
</aside> | ||
<div className="flex h-full w-96 max-w-full flex-col md:w-[1008px]"> | ||
<section className="mt-6 mb-6 flex w-full flex-col md:flex-row"> | ||
<div className="flex w-full flex-col items-center justify-between gap-2 md:flex-row md:gap-0"> | ||
<h2 className="text-3xl">Onchainkit</h2> | ||
<div className="flex gap-3"> | ||
<SignupButton /> | ||
{!address && <LoginButton />} | ||
</div> | ||
</div> | ||
</section> | ||
<section className="mb-6 flex w-full flex-col border-sky-800 border-b pb-6"> | ||
<aside className="mb-6 flex"> | ||
<h2 className="text-xl">Identity</h2> | ||
</aside> | ||
<main className="flex h-10 items-center space-x-4"> | ||
<WalletComponents /> | ||
</main> | ||
<section className="templateSection flex w-full grow flex-col items-center justify-center gap-4 rounded-xl md:bg-gray-100"> | ||
<div className="flex h-[450px] w-[450px] max-w-full items-center justify-center rounded-xl bg-[#030712]"> | ||
<div className="rounded-xl bg-[#F3F4F6] px-4 py-[11px]"> | ||
<p className="font-normal text-indigo-600 text-xl not-italic tracking-[-1.2px]"> | ||
npm install @coinbase/onchainkit | ||
</p> | ||
</div> | ||
</div> | ||
{address ? ( | ||
<TransactionWrapper address={address} /> | ||
) : ( | ||
<WalletWrapper | ||
className="w-[450px] max-w-full" | ||
text="Sign in to collect" | ||
/> | ||
)} | ||
</section> | ||
<Footer /> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client'; | ||
|
||
const docLinks = [ | ||
{ href: 'https://onchainkit.xyz', title: 'Docs' }, | ||
{ href: 'https://github.com/coinbase/onchainkit', title: 'Github' }, | ||
{ href: 'https://discord.gg/8gW3h6w5', title: 'Discord' }, | ||
{ | ||
href: 'https://www.figma.com/community/file/1370194397345450683/onchainkit', | ||
title: 'Figma', | ||
}, | ||
{ href: 'https://x.com/Onchainkit', title: 'X' }, | ||
]; | ||
|
||
export default function Footer() { | ||
return ( | ||
<section className="mt-12 mb-6 flex w-full flex-col justify-between gap-2 md:flex-row "> | ||
<aside className="flex items-center justify-center md:justify-start"> | ||
<h3 className="mr-2 text-m">Built with love by the OnchainKit team</h3> | ||
</aside> | ||
<ul className="flex justify-center gap-6 md:justify-start"> | ||
{docLinks.map(({ href, title }) => ( | ||
<li className="flex" key={href}> | ||
<a href={href} target="_blank" rel="noreferrer" title={title}> | ||
<p>{title}</p> | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use client'; | ||
import WalletWrapper from './WalletWrapper'; | ||
|
||
export default function LoginButton() { | ||
return <WalletWrapper text="Log in" />; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use client'; | ||
import WalletWrapper from './WalletWrapper'; | ||
|
||
export default function SignupButton() { | ||
return ( | ||
<WalletWrapper | ||
className="ockConnectWallet_Container bg-slate-200 text-[#030712] hover:bg-slate-300" | ||
text="Sign up" | ||
withWalletAggregator={true} | ||
/> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client'; | ||
import { | ||
Transaction, | ||
TransactionButton, | ||
TransactionStatus, | ||
TransactionStatusAction, | ||
TransactionStatusLabel, | ||
} from '@coinbase/onchainkit/transaction'; | ||
import { clickContractAbi, clickContractAddress } from 'src/constants'; | ||
import type { Address, ContractFunctionParameters } from 'viem'; | ||
|
||
type TransactionWrapperParams = { | ||
address: Address; | ||
}; | ||
|
||
export default function TransactionWrapper({ | ||
address, | ||
}: TransactionWrapperParams) { | ||
const contracts = [ | ||
{ | ||
address: clickContractAddress, | ||
abi: clickContractAbi, | ||
functionName: 'click', | ||
args: [], | ||
}, | ||
{ | ||
address: clickContractAddress, | ||
abi: clickContractAbi, | ||
functionName: 'click', | ||
args: [], | ||
}, | ||
] as ContractFunctionParameters[]; | ||
|
||
return ( | ||
<div className="flex w-[450px]"> | ||
<Transaction | ||
address={address} | ||
contracts={contracts} | ||
className="w-[450px]" | ||
> | ||
<TransactionButton className="mt-0 mr-auto ml-auto w-[450px] text-[white]" /> | ||
<TransactionStatus> | ||
<TransactionStatusLabel /> | ||
<TransactionStatusAction /> | ||
</TransactionStatus> | ||
</Transaction> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { render } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
import WalletComponents from './WalletComponents'; | ||
import WalletWrapper from './WalletWrapper'; | ||
|
||
describe('WalletComponents', () => { | ||
describe('WalletWrapper', () => { | ||
it('should renders', () => { | ||
render(<WalletComponents />); | ||
render(<WalletWrapper />); | ||
expect(true).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const clickContractAddress = | ||
'0x67c97D1FB8184F038592b2109F854dfb09C77C75'; | ||
export const clickContractAbi = [ | ||
{ | ||
type: 'function', | ||
name: 'click', | ||
inputs: [], | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
}, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default function BaseSvg() { | ||
return ( | ||
<svg | ||
width="20" | ||
height="20" | ||
viewBox="0 0 20 20" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<title>Base SVG</title> | ||
<circle cx="10" cy="10" r="10" fill="#0052FF" /> | ||
<path | ||
d="M10.0437 16.9488C13.9196 16.9488 17.0616 13.8123 17.0616 9.94315C17.0616 6.07404 13.9196 2.9375 10.0437 2.9375C6.36653 2.9375 3.34989 5.76073 3.05029 9.35427H12.3263V10.532H3.05029C3.34989 14.1256 6.36653 16.9488 10.0437 16.9488Z" | ||
fill="white" | ||
/> | ||
</svg> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's start introducing CSS variables