Skip to content

Commit

Permalink
Merge branch 'main' into dms/internal
Browse files Browse the repository at this point in the history
  • Loading branch information
dschlabach committed Jan 24, 2025
2 parents 0a19b44 + 46415c9 commit a212e85
Show file tree
Hide file tree
Showing 39 changed files with 2,636 additions and 157 deletions.
5 changes: 0 additions & 5 deletions .changeset/perfect-knives-draw.md

This file was deleted.

15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Changelog

## 0.36.8

### Patch Changes

- **feat**: Add Popover UI Primitive. By @cpcramer #1849
- **feat**: Added NFT data hooks. By @alessey #1838
- **fix**: Made improvements to FundCard component. By @rustam-cb #1806 #1818 #1839
- **fix**: Made improvements to WalletIsland component. By @brendan-cb #1842
- **fix**: Made internal typesafety and efficiency improvements. By @dschlabach #1855 #1843
- **fix**: Fixed typos in documentation and commments. By @youyyytrok @vipocenka #1840 #1841

## 0.36.7

### Patch Changes

- **feat** Implemented `FundCard` component by @rustam-cb #1718
- **fix** Updated client boundaries for `NFT`, `Wallet*`, and `WalletAdvanced*` components by @dschlabach #1809, #1810, #1821
- **feat**: Implemented `FundCard` component by @rustam-cb #1718
- **fix**: Updated client boundaries for `NFT`, `Wallet*`, and `WalletAdvanced*` components by @dschlabach #1809, #1810, #1821

## 0.36.6

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/onchainkit",
"version": "0.36.7",
"version": "0.36.8",
"type": "module",
"repository": "https://github.com/coinbase/onchainkit.git",
"license": "MIT",
Expand Down
16 changes: 8 additions & 8 deletions playground/nextjs-app-router/onchainkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@
"default": "./esm/index.js"
},
"./api": {
"types": "./esm/core/api/index.d.ts",
"module": "./esm/core/api/index.js",
"import": "./esm/core/api/index.js",
"default": "./esm/core/api/index.js"
"types": "./esm/api/index.d.ts",
"module": "./esm/api/index.js",
"import": "./esm/api/index.js",
"default": "./esm/api/index.js"
},
"./buy": {
"types": "./esm/buy/index.d.ts",
Expand All @@ -146,10 +146,10 @@
"default": "./esm/fund/index.js"
},
"./identity": {
"types": "./esm/ui/react/identity/index.d.ts",
"module": "./esm/ui/react/identity/index.js",
"import": "./esm/ui/react/identity/index.js",
"default": "./esm/ui/react/identity/index.js"
"types": "./esm/identity/index.d.ts",
"module": "./esm/identity/index.js",
"import": "./esm/identity/index.js",
"default": "./esm/identity/index.js"
},
"./nft": {
"types": "./esm/ui/react/nft/index.d.ts",
Expand Down
234 changes: 234 additions & 0 deletions site/docs/pages/fund/fund-card.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
---
title: <FundCard /> · OnchainKit
description: The `<FundCard />` component provides a complete fiat onramp experience with amount input, currency switching, and payment method selection.
---

import { Avatar, Name } from '@coinbase/onchainkit/identity';
import { FundCard } from '@coinbase/onchainkit/fund';
import { Wallet, ConnectWallet } from '@coinbase/onchainkit/wallet';
import App from '../../components/App';
import FundWrapper from '../../components/FundWrapper';

# `<FundCard />`

The `<FundCard />` component provides a complete fiat onramp experience within your app. It includes:

- Amount input with fiat/crypto switching
- Payment method selection (Coinbase, Apple Pay, Debit Card)
- Automatic exchange rate updates
- Smart handling of payment method restrictions (based on country and subdivision)

:::info
The Apple Pay and Debit Card onramp options are only available for Coinbase supported assets.
:::

## Prerequisites

Before using the `FundCard` component, ensure you've completed the [Getting Started](/installation/nextjs#get-your-client-api-key) steps.

::::tip
To use the `FundCard` component, you'll need to provide a Client API Key in `OnchainKitProvider`. You can get one following our [Getting Started](/installation/nextjs#get-your-client-api-key) steps.
:::::

## Usage

### Drop in the `<FundCard />` component

```tsx
import { FundCard } from '@coinbase/onchainkit/fund';

<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
/>;
```

<App>
<FundWrapper>
{({ address }) => {
if (address) {
return <FundCard assetSymbol="ETH" country="US" currency="USD" />;
}
return (
<>
<Wallet>
<ConnectWallet>
<Avatar className="h-6 w-6" />
<Name />
</ConnectWallet>
</Wallet>
</>
);
}}
</FundWrapper>
</App>

## Customization

### Custom Header and Button Text

You can customize the header and button text:

```tsx
<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
headerText="Purchase Ethereum"
buttonText="Purchase"
/>
```

<App>
<FundWrapper>
{({ address }) => {
if (address) {
return (
<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
headerText="Purchase Ethereum"
buttonText="Purchase"
/>
);
}
return (
<>
<Wallet>
<ConnectWallet>
<Avatar className="h-6 w-6" />
<Name />
</ConnectWallet>
</Wallet>
</>
);
}}
</FundWrapper>
</App>

### Custom Currency

You can specify which fiat currency to use:

```tsx
<FundCard
assetSymbol="ETH"
country="GB"
currency="GBP"
/>
```

### Preset Amount Inputs

You can specify preset amount buttons:

```tsx
const presetAmountInputs = ['10', '20', '50'] as const;

<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
presetAmountInputs={presetAmountInputs}
/>;
```

:::info
**Note: 3 preset amount inputs are required in order to show the preset amount buttons.**
:::

### Custom Content

You can provide custom children to completely customize the card content while keeping the fund button functionality:

```tsx
<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
>
<div className="space-y-4">
<h2>Custom Header</h2>
<input type="number" placeholder="Enter amount" />
<select>
<option>Payment Method 1</option>
<option>Payment Method 2</option>
</select>
</div>
</FundCard>
```

You can also reuse the existing children from the default implementation and add your own custom content.

```tsx
import {
FundCardHeader,
FundCardAmountInput,
FundCardAmountInputTypeSwitch,
FundCardPresetAmountInputList,
FundCardPaymentMethodDropdown,
FundCardSubmitButton,
} from '@coinbase/onchainkit/fund';

<FundCard
assetSymbol="ETH"
country="US"
currency="USD"
>

<h2>Custom Header instead of the default "FundCardHeader" </h2>
<FundCardAmountInput />
<FundCardAmountInputTypeSwitch />
<FundCardPresetAmountInputList />
<div>Any custom content</div>
<FundCardPaymentMethodDropdown />
<FundCardSubmitButton />
<div>Any custom content</div>
</FundCard>
```

:::info
**Note:** If you are using the custom components then you are going to need to access the state of the `FundCard` component. You can do this by using the `useFundContext` hook.
:::

```tsx
const {
asset,
currency,
selectedPaymentMethod,
setSelectedPaymentMethod,
fundAmountFiat,
setFundAmountFiat,
fundAmountCrypto,
setFundAmountCrypto,
selectedInputType,
setSelectedInputType,
exchangeRate,
setExchangeRate,
exchangeRateLoading,
setExchangeRateLoading,
submitButtonState,
setSubmitButtonState,
paymentMethods,
setPaymentMethods,
paymentMethodsLoading,
setPaymentMethodsLoading,
headerText,
buttonText,
country,
subdivision,
lifecycleStatus,
updateLifecycleStatus,
presetAmountInputs,
} = useFundContext();
```

## Props

- [`FundCardPropsReact`](/fund/types#fundcardpropsreact)

## Related Components

- [`<FundButton />`](/fund/fund-button)
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"sitemap": "node createSitemap.js"
},
"dependencies": {
"@coinbase/onchainkit": "0.36.7",
"@coinbase/onchainkit": "0.36.8",
"@types/react": "latest",
"@vercel/edge": "^1.1.1",
"express": "^4.21.1",
Expand Down
4 changes: 4 additions & 0 deletions site/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export const sidebar = [
text: 'FundButton',
link: '/fund/fund-button',
},
{
text: 'FundCard',
link: '/fund/fund-card',
},
],
},
{
Expand Down
10 changes: 5 additions & 5 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ __metadata:
languageName: node
linkType: hard

"@coinbase/onchainkit@npm:0.36.7":
version: 0.36.7
resolution: "@coinbase/onchainkit@npm:0.36.7"
"@coinbase/onchainkit@npm:0.36.8":
version: 0.36.8
resolution: "@coinbase/onchainkit@npm:0.36.8"
dependencies:
"@tanstack/react-query": "npm:^5"
clsx: "npm:^2.1.1"
Expand All @@ -496,7 +496,7 @@ __metadata:
"@types/react": ^18 || ^19
react: ^18 || ^19
react-dom: ^18 || ^19
checksum: 3ffca599b9a4f2a33e9aef0aec15b3d03ec6009ea8863152117e02e4f51f84e86950779b6594f49c46f9bfd6c1ae2eae2d47b58d14fa29bf1534f44b738e7826
checksum: 73eca5767193f98addd2185695b1f8adf7c82e1d5664dfd7de9d07467b4997d6a7b5311fdd1b8dca482bf600022844f24321e6e7787fb46aa18c4410d576c876
languageName: node
linkType: hard

Expand Down Expand Up @@ -8408,7 +8408,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "onchainkit@workspace:."
dependencies:
"@coinbase/onchainkit": "npm:0.36.7"
"@coinbase/onchainkit": "npm:0.36.8"
"@types/express": "npm:^4"
"@types/react": "npm:latest"
"@types/sitemap-generator": "npm:^8"
Expand Down
Loading

0 comments on commit a212e85

Please sign in to comment.