-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e0b5db
commit dfb419d
Showing
7 changed files
with
90 additions
and
47 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
68 changes: 68 additions & 0 deletions
68
...dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/rcfm-page.module.ts
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,68 @@ | ||
export const RcfmPageState = { | ||
loading: 'loading', | ||
dAppVerified: 'dAppVerified', | ||
timedOut: 'timedOut', | ||
} as const | ||
|
||
export type RcfmPageState = (typeof RcfmPageState)[keyof typeof RcfmPageState] | ||
|
||
export type RcfmPageModule = ReturnType<typeof RcfmPageModule> | ||
export const RcfmPageModule = (input: {}) => { | ||
const rcfmPageHtmlElement = document.createElement('radix-rcfm-page') | ||
document.body.appendChild(rcfmPageHtmlElement) | ||
|
||
const showWithData = ({ | ||
header, | ||
subheader, | ||
isError, | ||
isLoading, | ||
}: { | ||
header?: string | ||
subheader?: string | ||
isError?: boolean | ||
isLoading?: boolean | ||
}) => { | ||
rcfmPageHtmlElement.header = header || '' | ||
rcfmPageHtmlElement.subheader = subheader || '' | ||
rcfmPageHtmlElement.isError = isError || false | ||
rcfmPageHtmlElement.isLoading = isLoading || false | ||
rcfmPageHtmlElement.isHidden = false | ||
} | ||
const hide = () => { | ||
rcfmPageHtmlElement.isHidden = true | ||
} | ||
|
||
const show = (state: RcfmPageState) => { | ||
switch (state) { | ||
case RcfmPageState.dAppVerified: | ||
showWithData({ | ||
header: 'Connection succesful!', | ||
subheader: 'You can now close this tab', | ||
isError: false, | ||
isLoading: false, | ||
}) | ||
break | ||
case RcfmPageState.loading: | ||
showWithData({ | ||
isLoading: true, | ||
}) | ||
break | ||
case RcfmPageState.timedOut: | ||
showWithData({ | ||
header: 'Connection timed out', | ||
subheader: 'Close this tab and try connecting again', | ||
isError: true, | ||
isLoading: false, | ||
}) | ||
break | ||
default: | ||
break | ||
} | ||
} | ||
|
||
return { | ||
show, | ||
hide, | ||
showWithData, | ||
} | ||
} |