-
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.
* migrating switch bundler to @svelte/package add svelte-preprocess to handle global styles * correct types * update example * account might be null * clarify component use
- Loading branch information
1 parent
1382268
commit 69c7ad6
Showing
13 changed files
with
301 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { SvelteComponent } from 'svelte' | ||
|
||
export class ConnectModal extends SvelteComponent<{ | ||
config: Config<Connector> | ||
state: Readable<StateDisconnected<Connector>> | ||
btnClass: string | ||
triggerText: string | ||
onConnect: (fractl: Config<Connector>) => void | ||
onConnectFail: (error: unknown) => void | ||
}> {} |
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,34 +1,6 @@ | ||
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 | ||
import ConnectModal from './ConnectModal/ConnectModal.svelte' | ||
import '../styles/index.css' | ||
|
||
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
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,7 +1,44 @@ | ||
import FractlModal from './components/FractlModal.svelte' | ||
import ConnectModal from './components/ConnectModal/ConnectModal.svelte' | ||
import AccountModal from './components/AccountModal.svelte' | ||
import type { Config, Connector } from '@fractl-ui/types' | ||
|
||
export const create = async <C extends Connector>( | ||
config: Promise<Config<C>> | ||
): Promise<() => Promise<Config<C>>> => { | ||
const _config = await Promise.resolve(config) | ||
const SINGLETON = 'fractl-connect' | ||
|
||
return () => { | ||
const getTarget = () => { | ||
const el = document.getElementById(SINGLETON) | ||
if (el) { | ||
//TODO: target only gives a mount point. Need a way of calling show instead to avoid deleting each time | ||
el.remove() | ||
} | ||
const target = document.createElement('div') | ||
target.id = SINGLETON | ||
document.body.appendChild(target) | ||
|
||
return target | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
const modal = new ConnectModal({ | ||
target: getTarget(), | ||
props: { | ||
config: _config, | ||
state: _config.state, | ||
onConnect: (state: Config<C>) => { | ||
resolve(state) | ||
modal.$destroy() | ||
}, | ||
onConnectFail: (error) => { | ||
reject(error) | ||
modal.$destroy() | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
export { create } from './components/index.js' | ||
export { FractlModal, AccountModal, ConnectModal } | ||
// export T&C text prop |
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,11 +1,7 @@ | ||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' | ||
|
||
import { sveltePreprocess } from 'svelte-preprocess' | ||
export default { | ||
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess | ||
// for more information about preprocessors | ||
|
||
preprocess: vitePreprocess(), | ||
compilerOptions: { | ||
customElement: true | ||
} | ||
preprocess: sveltePreprocess() | ||
} |
Oops, something went wrong.