Skip to content

Commit

Permalink
Merge pull-request #25 from sameoldlab/function-api
Browse files Browse the repository at this point in the history
export connectModal as function
update example
Remove custom element workarounds
- Moves style imports to script
return state after connection attempt
enable svelte imports
- alows use of connect modal from compiled svelte or direclty importing
components
  • Loading branch information
sameoldlab committed Aug 12, 2024
1 parent 5305e38 commit 1382268
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
29 changes: 16 additions & 13 deletions examples/svelte/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
const evm = addEvmConnection($wagmiConfig)
let account
const connect = async (conf) => create(conf).then((connect) => connect()
.then(res => {
account = {
config: res,
accountData: res.accountData
}
console.log(res)
})
.catch(err => console.error(err))
const connect = async (conf) =>
create(conf).then((connect) =>
connect()
.then((res) => {
account = {
config: res,
accountData: res.accountData
}
console.log(res)
})
.catch((err) => console.error(err))
)
</script>

<header>
<button on:click={()=>connect(evm)}>Connect EVM</button>
<button on:click={()=>connect(stark)}>Connect Stark</button>
<button on:click={() => connect(evm)}>Connect EVM</button>
<button on:click={() => connect(stark)}>Connect Stark</button>
</header>
<main>
<div class="hero">
Expand All @@ -43,8 +46,8 @@
</p>
</div>
{#if account}
<AccountModal {...account}/>
{/if}
<AccountModal {...account} />
{/if}

<!--
{#if connected}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/AccountModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Zorb from './zorb/Zorb.svelte'
import Modal from './Common/Modal.svelte'
import { onDestroy } from 'svelte'
import type { Readable} from 'svelte/store'
import type { Readable } from 'svelte/store'
export let accountData: Readable<AccountData>
export let config: ConfigConnected<Connector>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Common/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
dialog.close()
dispatch('close')
}
onDestroy(()=>{
onDestroy(() => {
dispatch('close')
})
</script>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/FractlModal.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { Config } from '@fractl-ui/types'
import ConnectModal from './ConnectModal/ConnectModal.svelte';
import AccountModal from './AccountModal.svelte';
import ConnectModal from './ConnectModal/ConnectModal.svelte'
import AccountModal from './AccountModal.svelte'
import { blur } from 'svelte/transition'
import { quintOut } from 'svelte/easing'
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import ConnectModal from './components/ConnectModal/ConnectModal.svelte'
import AccountModal from './components/AccountModal.svelte'

export { create } from './components/index.js'
export {FractlModal , AccountModal, ConnectModal }
export { FractlModal, AccountModal, ConnectModal }
// export T&C text prop

0 comments on commit 1382268

Please sign in to comment.