|
| 1 | +<!-- |
| 2 | +@component |
| 3 | +Connect button + connected-account chip. |
| 4 | +
|
| 5 | +Opens AppKit's wallet picker modal on click. AppKit handles wallet discovery |
| 6 | +(browser extensions via EIP-6963 + WalletConnect-bridged mobile wallets via |
| 7 | +QR), so this component is intentionally tiny — the picker UI lives in AppKit. |
| 8 | +--> |
1 | 9 | <script lang="ts"> |
2 | 10 | import { Button } from '$lib/components/ui/button/index.js'; |
3 | 11 | import { getWallet } from '$lib/wallet.svelte.js'; |
|
19 | 27 | Disconnect |
20 | 28 | </Button> |
21 | 29 | {:else} |
22 | | - <Button onclick={() => wallet.connect()} disabled={wallet.connecting}> |
23 | | - {wallet.connecting ? 'Connecting...' : 'Connect Wallet'} |
24 | | - </Button> |
| 30 | + <Button onclick={() => wallet.connect()}>Connect wallet</Button> |
25 | 31 | {/if} |
26 | 32 | {#if wallet.error} |
27 | 33 | <span class="text-destructive text-xs">{wallet.error}</span> |
28 | 34 | {/if} |
29 | 35 | </div> |
30 | | - |
31 | | -<!-- Wallet picker modal --> |
32 | | -{#if wallet.showPicker} |
33 | | - <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions --> |
34 | | - <div |
35 | | - class="fixed inset-0 z-50 flex items-center justify-center bg-black/50" |
36 | | - onclick={() => (wallet.showPicker = false)} |
37 | | - > |
38 | | - <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions --> |
39 | | - <div |
40 | | - class="bg-background w-80 rounded-xl border p-6 shadow-xl" |
41 | | - onclick={(e) => e.stopPropagation()} |
42 | | - > |
43 | | - <h2 class="mb-4 text-base font-semibold">Select a wallet</h2> |
44 | | - <ul class="space-y-2"> |
45 | | - {#each wallet.discoveredWallets as w} |
46 | | - <li> |
47 | | - <button |
48 | | - class="hover:bg-muted flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-colors" |
49 | | - onclick={() => wallet.connectProvider(w)} |
50 | | - > |
51 | | - <img src={w.info.icon} alt={w.info.name} class="size-8 rounded-md" /> |
52 | | - <span class="text-sm font-medium">{w.info.name}</span> |
53 | | - </button> |
54 | | - </li> |
55 | | - {/each} |
56 | | - </ul> |
57 | | - <Button variant="ghost" size="sm" class="mt-4 w-full" onclick={() => (wallet.showPicker = false)}> |
58 | | - Cancel |
59 | | - </Button> |
60 | | - </div> |
61 | | - </div> |
62 | | -{/if} |
0 commit comments