-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull-request #25 from sameoldlab/function-api
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
1 parent
969a088
commit e95d562
Showing
8 changed files
with
100 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
import ConnectModal from './ConnectModal/ConnectModal.svelte' | ||
import AccountModal from './AccountModal.svelte' | ||
import FractlModal from './FractlModal.svelte' | ||
import type { Config, Connector, StateConnected } from '@fractl-ui/types' | ||
|
||
export const create = async <C extends Connector>( | ||
config: Promise<Config<C>> | ||
) => { | ||
const _config = await Promise.resolve(config) | ||
|
||
//TODO: return singleton when modal is dismissed without completing connection | ||
return () => { | ||
const getTarget = () => document.body | ||
|
||
return new Promise((resolve, reject) => { | ||
const modal = new ConnectModal({ | ||
target: getTarget(), | ||
props: { | ||
config: _config, | ||
state: _config.state, | ||
onConnect: (state: StateConnected<C>) => { | ||
resolve(state) | ||
modal.$destroy() | ||
}, | ||
onConnectFail: (error) => { | ||
reject(error) | ||
modal.$destroy() | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
export { ConnectModal, AccountModal, FractlModal } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export { FractlModal } from './components/index.js' | ||
// export {open connect modal} | ||
import FractlModal from './components/FractlModal.svelte' | ||
import ConnectModal from './components/ConnectModal/ConnectModal.svelte' | ||
import AccountModal from './components/AccountModal.svelte' | ||
|
||
export { create } from './components/index.js' | ||
export { FractlModal, AccountModal, ConnectModal } | ||
// export T&C text prop |