Skip to content
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: wallet island docs #1801

Draft
wants to merge 150 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
640e1f9
initial walletisland ux
brendan-defi Jan 2, 2025
2d381be
svgs and util placeholder
brendan-defi Jan 2, 2025
0603d86
fix: imports
brendan-defi Jan 2, 2025
1cd4d1d
playground demo
brendan-defi Jan 2, 2025
180f4fb
playground options
brendan-defi Jan 2, 2025
f0a2752
demo positioning
brendan-defi Jan 2, 2025
a58ccc9
add walletisland to wallet content options
brendan-defi Jan 3, 2025
c57f9cd
WalletIslandProps
brendan-defi Jan 3, 2025
4598882
refactor for new architecture
brendan-defi Jan 3, 2025
7be24c7
temp animations
brendan-defi Jan 3, 2025
ee135e2
fix: linters
brendan-defi Jan 3, 2025
0ab1505
fix walletisland provider
brendan-defi Jan 3, 2025
06b33bf
qr animations
brendan-defi Jan 3, 2025
bf8eca7
update animations
brendan-defi Jan 3, 2025
956ff3a
fix: icon size
brendan-defi Jan 3, 2025
a01056b
content block animations
brendan-defi Jan 3, 2025
8f8f80c
fix: linters
brendan-defi Jan 3, 2025
9ad8298
fix: test:
brendan-defi Jan 3, 2025
84c4b9d
fix: tests
brendan-defi Jan 3, 2025
c4d6164
improve defaults, fix variable spelling
brendan-defi Jan 3, 2025
eca0fb8
fix: tests
brendan-defi Jan 3, 2025
8f7edb2
fixed error handling for useWalletIslandContext
brendan-defi Jan 3, 2025
9a65a1d
optional containerRef
brendan-defi Jan 3, 2025
a81d2ba
fix: tests
brendan-defi Jan 3, 2025
5cb60c5
fix: linters
brendan-defi Jan 3, 2025
7934bcb
fix: test
brendan-defi Jan 3, 2025
4c1b9ea
fix: lint
brendan-defi Jan 3, 2025
484c886
fix: lint, test
brendan-defi Jan 3, 2025
8b7b61b
fix: linters
brendan-defi Jan 3, 2025
54a49a5
add types to tests
brendan-defi Jan 3, 2025
96df8e7
more types in swaptests
brendan-defi Jan 3, 2025
f113e9c
portfolio api method and hook
brendan-defi Jan 4, 2025
18f4e2f
portfolio data
brendan-defi Jan 4, 2025
7e8fbab
portfolio refresh, svg sizing
brendan-defi Jan 4, 2025
19f6975
refresh svg
brendan-defi Jan 4, 2025
317f74c
loading state
brendan-defi Jan 4, 2025
d197df6
refetch and loading state
brendan-defi Jan 4, 2025
1d12639
update query config
brendan-defi Jan 4, 2025
258af8b
fix: linters
brendan-defi Jan 4, 2025
64289b6
refactored types
brendan-defi Jan 4, 2025
3888b57
removing unused files, adding tests
brendan-defi Jan 4, 2025
bc98a5b
add: tests
brendan-defi Jan 4, 2025
731cddb
fix: tests
brendan-defi Jan 4, 2025
d347a65
fix: tests
brendan-defi Jan 4, 2025
71c6b57
add test
brendan-defi Jan 4, 2025
11d8dc7
add tests
brendan-defi Jan 4, 2025
8f3665a
fix: linters
brendan-defi Jan 4, 2025
b333c34
specify swap tokens
brendan-defi Jan 4, 2025
125a2f8
updated type definitions
brendan-defi Jan 6, 2025
e3afa9c
update type usage
brendan-defi Jan 6, 2025
283c6f7
fix: linters
brendan-defi Jan 6, 2025
19fba38
fix tests
brendan-defi Jan 6, 2025
a5ebef5
fix: types
brendan-defi Jan 6, 2025
52f7549
add test
brendan-defi Jan 6, 2025
9ddd27a
update spacing
brendan-defi Jan 6, 2025
2ffd2a1
filter zero-balance tokens
brendan-defi Jan 6, 2025
b580476
standard icon treatment
brendan-defi Jan 6, 2025
26c8c95
add test
brendan-defi Jan 6, 2025
e0b8375
fix: linters
brendan-defi Jan 6, 2025
9bc678b
fix: tests
brendan-defi Jan 6, 2025
6464e36
address comments
brendan-defi Jan 6, 2025
4061c4f
change default playground position
brendan-defi Jan 7, 2025
a7cbabb
draggable prop on wallet
brendan-defi Jan 7, 2025
4d71fc0
wallet island default to-tokens, max-height
brendan-defi Jan 7, 2025
dcf885c
remove ref from walletisland
brendan-defi Jan 7, 2025
af42881
refactor draggable component to entire wallet
brendan-defi Jan 7, 2025
2869534
prevent click functionality on drag
brendan-defi Jan 7, 2025
45db298
fix: lint
brendan-defi Jan 7, 2025
a18aae0
fix: types
brendan-defi Jan 7, 2025
815db40
fix: types
brendan-defi Jan 7, 2025
7ba6cb7
fix: lint
brendan-defi Jan 7, 2025
8951289
remove comment, fix lint
brendan-defi Jan 7, 2025
8140fe6
move walletisland types to wallet/types
brendan-defi Jan 7, 2025
2c84581
walletisland constants
brendan-defi Jan 7, 2025
5cad2fd
add walletisland exports
brendan-defi Jan 7, 2025
d898f4a
draggable functionality on entire wallet
brendan-defi Jan 7, 2025
ce71d3a
fix: lint
brendan-defi Jan 7, 2025
d9da561
fix walletisland-connectwallet gap
brendan-defi Jan 7, 2025
a3b40bc
fix icon sizes
brendan-defi Jan 7, 2025
4e34b83
update wallet tests
brendan-defi Jan 7, 2025
5adb882
add test cleanup
brendan-defi Jan 7, 2025
2039a94
fix: lint
brendan-defi Jan 7, 2025
7c730e4
stronger test cleanup
brendan-defi Jan 7, 2025
979980d
add test for click prevention on drag
brendan-defi Jan 7, 2025
648f829
fix: lint
brendan-defi Jan 7, 2025
3ba0475
use standard tailwind
brendan-defi Jan 7, 2025
2bccd8d
update get portfolios data structure
brendan-defi Jan 8, 2025
418326e
remove focus, fix spacing, fix animation
brendan-defi Jan 8, 2025
4f213e1
remove focus, fix spacing, fix animation
brendan-defi Jan 8, 2025
95ea7f2
fix spacing
brendan-defi Jan 8, 2025
d3d79dc
fix: tests
brendan-defi Jan 8, 2025
854f499
add null portfolios check
brendan-defi Jan 8, 2025
9010b14
fixed click prevention on non-drag clicks
brendan-defi Jan 8, 2025
539726d
fix: test
brendan-defi Jan 8, 2025
a873f7c
remove duplicate theme detection
brendan-defi Jan 8, 2025
642af4d
remove default swap tokens
brendan-defi Jan 8, 2025
fdc3fe5
rename WalletIslandDefault to WalletIslandDraggable
brendan-defi Jan 8, 2025
555fdac
added WalletIslandFixed
brendan-defi Jan 8, 2025
69b45ba
add WalletIslandFixed to playground
brendan-defi Jan 8, 2025
84e3599
simplify demo
brendan-defi Jan 8, 2025
0f1ec45
update ock
brendan-defi Jan 8, 2025
652b5c7
fix tests
brendan-defi Jan 8, 2025
292afe0
use radiusInner, fix spacing, address comments
brendan-defi Jan 8, 2025
f138166
better svg titles
brendan-defi Jan 8, 2025
dfff1a9
add startingPosition prop for WalletIslandDraggable
brendan-defi Jan 8, 2025
ba219f0
better aria-labels
brendan-defi Jan 8, 2025
04a236e
remove throttle on portfolio refresh
brendan-defi Jan 8, 2025
a4c252c
extract actions into callbacks
brendan-defi Jan 8, 2025
59c41ce
better return value if no portfolios received
brendan-defi Jan 8, 2025
d9d283b
fix: lint
brendan-defi Jan 8, 2025
f36ea1c
fix: tests
brendan-defi Jan 8, 2025
6bb31e9
fix: lint
brendan-defi Jan 8, 2025
32075e8
update parameter for usePortfolioTokenBalances
brendan-defi Jan 8, 2025
6b5f914
fix: tests
brendan-defi Jan 8, 2025
c860663
fix: test
brendan-defi Jan 8, 2025
0d3c3bc
update QrCodeSvg props and value handling
brendan-defi Jan 8, 2025
c3225fb
fix test
brendan-defi Jan 8, 2025
78ff185
refactor PressableIcon
brendan-defi Jan 8, 2025
9d11483
fix tests
brendan-defi Jan 8, 2025
27899ae
fix: lint
brendan-defi Jan 8, 2025
d45febc
add test
brendan-defi Jan 8, 2025
13d0b98
fix circular deps
brendan-defi Jan 8, 2025
39943a5
fix circular dependencies
brendan-defi Jan 8, 2025
38eb00c
min-height on token holdings
brendan-defi Jan 8, 2025
606c36e
update types
brendan-defi Jan 9, 2025
7eda23d
update tests for new types and filters
brendan-defi Jan 9, 2025
a9793bd
remove filters and transform, now performed on backend
brendan-defi Jan 9, 2025
22e1e1d
fix tests
brendan-defi Jan 9, 2025
337b5bf
fix: lint
brendan-defi Jan 9, 2025
2b62dd5
update type to match data structure
brendan-defi Jan 9, 2025
346aa33
animations based on open position
brendan-defi Jan 9, 2025
20938b2
move positioning useEffect to provider
brendan-defi Jan 9, 2025
0b13fbc
fix tests
brendan-defi Jan 9, 2025
d514c29
fix tests
brendan-defi Jan 9, 2025
2ce661e
add tests
brendan-defi Jan 9, 2025
b2b3759
fix: lints
brendan-defi Jan 9, 2025
3b88373
fix test
brendan-defi Jan 9, 2025
582e1a6
fix test
brendan-defi Jan 9, 2025
a50947e
reuse token constants
brendan-defi Jan 9, 2025
fea30ed
remove outer div
brendan-defi Jan 9, 2025
ee348b2
address QA comments
brendan-defi Jan 9, 2025
d33598b
use onAnimationEnd instead of timeouts for close handling
brendan-defi Jan 9, 2025
46050f3
update title
brendan-defi Jan 9, 2025
ec62c42
update default start position
brendan-defi Jan 9, 2025
a99517f
remove empty div when balance is null
brendan-defi Jan 9, 2025
f6d4793
fix lints and tests
brendan-defi Jan 9, 2025
68735f6
fix tests
brendan-defi Jan 9, 2025
839861b
fix default position for WalletIslandFixed demo
brendan-defi Jan 9, 2025
10e8c69
update name and exports
brendan-defi Jan 9, 2025
3d63de4
wallet island docs
brendan-defi Jan 9, 2025
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
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all"
"trailingComma": "all",
"embeddedLanguageFormatting": "off"
}
17 changes: 13 additions & 4 deletions playground/nextjs-app-router/components/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import TransactionDemo from './demo/Transaction';
import TransactionDefaultDemo from './demo/TransactionDefault';
import WalletDemo from './demo/Wallet';
import WalletDefaultDemo from './demo/WalletDefault';
import WalletIslandDraggableDemo from './demo/WalletIslandDraggable';
import WalletIslandFixedDemo from './demo/WalletIslandFixed';

const activeComponentMapping: Record<OnchainKitComponent, React.FC> = {
[OnchainKitComponent.Buy]: BuyDemo,
Expand All @@ -31,6 +33,8 @@ const activeComponentMapping: Record<OnchainKitComponent, React.FC> = {
[OnchainKitComponent.SwapDefault]: SwapDefaultDemo,
[OnchainKitComponent.Wallet]: WalletDemo,
[OnchainKitComponent.WalletDefault]: WalletDefaultDemo,
[OnchainKitComponent.WalletIslandDraggable]: WalletIslandDraggableDemo,
[OnchainKitComponent.WalletIslandFixed]: WalletIslandFixedDemo,
[OnchainKitComponent.TransactionDefault]: TransactionDefaultDemo,
[OnchainKitComponent.NFTMintCard]: NFTMintCardDemo,
[OnchainKitComponent.NFTCard]: NFTCardDemo,
Expand All @@ -39,7 +43,7 @@ const activeComponentMapping: Record<OnchainKitComponent, React.FC> = {
[OnchainKitComponent.IdentityCard]: IdentityCardDemo,
};

function Demo() {
export default function Demo() {
const { activeComponent } = useContext(AppContext);
const [isDarkMode, setIsDarkMode] = useState(true);
const [sideBarVisible, setSideBarVisible] = useState(true);
Expand Down Expand Up @@ -140,12 +144,17 @@ function Demo() {
</div>
</div>
<div className="linear-gradient(to_bottom,#f0f0f0_1px,transparent_1px)] flex flex-1 flex-col bg-[linear-gradient(to_right,#f0f0f0_1px,transparent_1px), bg-[size:6rem_4rem]">
<div className="flex h-full w-full flex-col items-center justify-center">
<div
className={cn(
'flex h-full w-full flex-col items-center',
activeComponent === OnchainKitComponent.WalletIslandFixed
? 'mt-12 justify-start'
: 'justify-center',
)}
>
{ActiveComponent && <ActiveComponent />}
</div>
</div>
</>
);
}

export default Demo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WalletIslandDraggable } from '@coinbase/onchainkit/wallet';

export default function WalletIslandDraggableDemo() {
return <WalletIslandDraggable />;
}
11 changes: 11 additions & 0 deletions playground/nextjs-app-router/components/demo/WalletIslandFixed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { WalletIslandFixed } from '@coinbase/onchainkit/wallet';

export default function WalletIslandFixedDemo() {
return (
<div className="mx-auto">
<div className="flex justify-end">
<WalletIslandFixed />
</div>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export function ActiveComponent() {
<SelectItem value={OnchainKitComponent.WalletDefault}>
WalletDefault
</SelectItem>
<SelectItem value={OnchainKitComponent.WalletIslandDraggable}>
WalletIslandDraggable
</SelectItem>
<SelectItem value={OnchainKitComponent.WalletIslandFixed}>
WalletIslandFixed
</SelectItem>
<SelectItem value={OnchainKitComponent.NFTCard}>NFT Card</SelectItem>
<SelectItem value={OnchainKitComponent.NFTCardDefault}>
NFT Card Default
Expand Down
24 changes: 16 additions & 8 deletions playground/nextjs-app-router/onchainkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/onchainkit",
"version": "0.36.0",
"version": "0.36.4",
"type": "module",
"repository": "https://github.com/coinbase/onchainkit.git",
"license": "MIT",
Expand Down Expand Up @@ -30,15 +30,16 @@
"watch:tailwind": "tailwind -i ./src/styles/index.css -o ./src/tailwind.css --watch"
},
"peerDependencies": {
"@types/react": "^18",
"react": "^18",
"react-dom": "^18"
"@types/react": "^18 || ^19",
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"dependencies": {
"@tanstack/react-query": "^5",
"clsx": "^2.1.1",
"graphql": "^14 || ^15 || ^16",
"graphql-request": "^6.1.0",
"qrcode": "^1.5.4",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"viem": "^2.21.33",
Expand All @@ -59,6 +60,7 @@
"@storybook/test-runner": "^0.19.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^14.2.0",
"@types/qrcode": "^1",
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitest/coverage-v8": "^2.0.5",
Expand Down Expand Up @@ -119,6 +121,12 @@
"import": "./esm/core/api/index.js",
"default": "./esm/core/api/index.js"
},
"./buy": {
"types": "./esm/buy/index.d.ts",
"module": "./esm/buy/index.js",
"import": "./esm/buy/index.js",
"default": "./esm/buy/index.js"
},
"./checkout": {
"types": "./esm/checkout/index.d.ts",
"module": "./esm/checkout/index.js",
Expand All @@ -138,10 +146,10 @@
"default": "./esm/fund/index.js"
},
"./identity": {
"types": "./esm/identity/index.d.ts",
"module": "./esm/identity/index.js",
"import": "./esm/identity/index.js",
"default": "./esm/identity/index.js"
"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"
},
"./nft": {
"types": "./esm/ui/react/nft/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions playground/nextjs-app-router/types/onchainkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export enum OnchainKitComponent {
TransactionDefault = 'transaction-default',
Wallet = 'wallet',
WalletDefault = 'wallet-default',
WalletIslandDraggable = 'wallet-island-draggable',
WalletIslandFixed = 'wallet-island-fixed',
NFTCard = 'nft-card',
NFTCardDefault = 'nft-card-default',
NFTMintCard = 'nft-mint-card',
Expand Down
47 changes: 47 additions & 0 deletions site/docs/pages/wallet/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export type IsWalletACoinbaseSmartWalletResponse =
```ts
type WalletContextType = {
address?: Address | null; // The Ethereum address to fetch the avatar and name for.
chain?: Chain; // Optional chain for domain resolution
isOpen: boolean;
setIsOpen: Dispatch<SetStateAction<boolean>>;
isClosing: boolean;
setIsClosing: Dispatch<SetStateAction<boolean>>;
handleClose: () => void;
connectRef: React.RefObject<HTMLDivElement>;
showSubComponentAbove: boolean;
alignSubComponentRight: boolean;
};
```

Expand All @@ -55,6 +64,9 @@ type WalletContextType = {
```ts
type WalletReact = {
children: React.ReactNode;
className?: string;
draggable?: boolean;
startingPosition?: { x: number; y: number };
};
```

Expand Down Expand Up @@ -110,3 +122,38 @@ export type WalletDropdownLinkReact = {
target?: string;
};
```

## `WalletIslandReact`

```ts
export type WalletIslandReact = {
children: React.ReactNode;
swappableTokens?: Token[]; // Optional array of tokens to specify which tokens the user can swap _to_
};
```

## `WalletIslandContextType`

```ts
export type WalletIslandContextType = {
showSwap: boolean;
setShowSwap: Dispatch<SetStateAction<boolean>>;
isSwapClosing: boolean;
setIsSwapClosing: Dispatch<SetStateAction<boolean>>;
showQr: boolean;
setShowQr: Dispatch<SetStateAction<boolean>>;
isQrClosing: boolean;
setIsQrClosing: Dispatch<SetStateAction<boolean>>;
tokenBalances: PortfolioTokenWithFiatValue[] | undefined;
portfolioFiatValue: number | undefined;
isFetchingPortfolioData: boolean;
portfolioDataUpdatedAt: number | undefined;
refetchPortfolioData: () => Promise<
QueryObserverResult<PortfolioTokenBalances, Error>
>;
animations: {
container: string;
content: string;
};
};
```
Loading
Loading