11<script lang =" ts" >
2+ import { toast } from " svelte-sonner"
23import { cn } from " $lib/utilities/shadcn.ts"
3- import * as Dialog from " $lib/components/ui/dialog"
4- import { Button } from " $lib/components/ui/button/index.js"
54import { Badge } from " $lib/components/ui/badge"
65import type { UserAddresses } from " $lib/types.ts"
7- import { toast } from " svelte-sonner"
6+ import * as Dialog from " $lib/components/ui/dialog"
7+ import { Button } from " $lib/components/ui/button/index.js"
88
99export let kind: " from" | " to"
1010export let dialogOpen = false
1111export let onChainSelect: (newSelectedChain : string ) => void
1212export let chains: Array <{ chain_id: string ; display_name: string ; rpc_type: string }>
1313export let selectedChain: string
14- export let userAddr : UserAddresses | null
14+ export let userAddress : UserAddresses | null
1515
1616$ : document .body .style .overflow = dialogOpen ? " hidden" : " auto"
1717
1818function selectChain(chain : { chain_id: string ; display_name: string ; rpc_type: string }) {
19- if (chain .rpc_type === " evm" && ! userAddr ?.evm ) {
19+ if (chain .rpc_type === " evm" && ! userAddress ?.evm ) {
2020 toast .info (` Connect EVM wallet ` )
2121 return
2222 }
2323
24- if (chain .rpc_type === " cosmos" && ! userAddr ?.cosmos ) {
24+ if (chain .rpc_type === " cosmos" && ! userAddress ?.cosmos ) {
2525 toast .info (` Connect Cosmos wallet ` )
2626 return
2727 }
@@ -36,55 +36,35 @@ function selectChain(chain: { chain_id: string; display_name: string; rpc_type:
3636 bind:open ={dialogOpen }
3737 closeOnOutsideClick ={true }
3838>
39- <Dialog .Content
40- class ={cn (
41- ' border-solid overflow-auto flex flex-col items-start p-0 pt-4 pb-2' ,
42- )}
43- >
39+ <Dialog .Content class ={cn (' border-solid overflow-auto flex flex-col items-start p-0 pt-4 pb-2' )}>
4440 <Dialog .Header class =" max-h-min p-2 w-full" >
4541 <Dialog .Title class =" px-2" >
4642 Select {kind } Network
4743 </Dialog .Title >
4844 </Dialog .Header >
4945 <Dialog .Description class =" size-full" >
50- <!--
51- <div class="relative mr-auto flex-1 w-full">
52- <Search class="absolute left-2.5 top-2.5 size-4 text-muted-foreground" />
53- <Input
54- type="search"
55- pattern="[a-z]"
56- autocorrect="off"
57- spellcheck="false"
58- autocapitalize="off"
59- placeholder="choose origin chain"
60- on:input={event => handleChainSearch(event)}
61- class="w-full bg-current/95 pl-8 self-stretch lowercase focus-visible:ring-0 rounded-none focus-visible:outline-none border-x-0"
62- />
63- </div>
64- !-->
6546 <ul class =" flex flex-col" >
6647 {#each chains as chain , index }
6748 {@const selected = selectedChain === chain .chain_id }
68- <li
69- class ={cn (
70- ' dark:text-accent-foreground flex flex-col' ,
71- )}
72- >
49+ <li class ={cn (' dark:text-accent-foreground flex flex-col' )}>
7350 <Button
7451 variant ={' ghost' }
75- on:click ={() => {selectChain (chain )}}
76- class ={cn (' size-full px-4 py-2 w-full text-foreground rounded-none flex items-center justify-between dark:hover:text-black' ,
77- selected ? ' bg-muted-foreground text-background' : ' '
52+ on:click ={() => {
53+ selectChain (chain )
54+ }}
55+ class ={cn (
56+ ' size-full px-4 py-2 w-full text-foreground rounded-none flex items-center justify-between dark:hover:text-black' ,
57+ selected ? ' bg-muted-foreground text-background' : ' ' ,
7858 )}
7959 >
8060 <span class =" text-lg font-bold" >
8161 {chain .display_name }
8262 </span >
83- {#if (chain .rpc_type === " evm" && ! userAddr ?.evm ) || (chain .rpc_type === " cosmos" && ! userAddr ?.cosmos ) }
84- <Badge variant ={selected ? ' secondary' : ' default' }>Disconnected</Badge >
85- {:else }
86- <Badge variant ={selected ? ' secondary' : ' default' }>Connected</Badge >
87- {/if }
63+ {#if (chain .rpc_type === ' evm' && ! userAddress ?.evm ) || (chain .rpc_type === ' cosmos' && ! userAddress ?.cosmos )}
64+ <Badge variant ={selected ? ' secondary' : ' default' }>Disconnected</Badge >
65+ {:else }
66+ <Badge variant ={selected ? ' secondary' : ' default' }>Connected</Badge >
67+ {/if }
8868 </Button >
8969 </li >
9070 {/each }
0 commit comments