-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded Zapps in Zupass #1899
Merged
Merged
Embedded Zapps in Zupass #1899
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
008cb12
WIP
robknight 56f003a
Working embedded Zapps
robknight f3cf514
Update test zapp to work as hosted zapp
robknight 5104756
Rename ZAPPS env var to EMBEDDED_ZAPPS for clarity
robknight afcbefa
Add listen modes for embedded vs. embedding
robknight 71b5516
Make listen mode explicit rather than using default value
robknight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
99 changes: 0 additions & 99 deletions
99
apps/passport-client/components/screens/EmbeddedScreens/EmbeddedAddSubscription.tsx
This file was deleted.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
apps/passport-client/components/screens/ZappScreens/ZappScreen.tsx
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,36 @@ | ||
import { ReactNode } from "react"; | ||
import { useDispatch, useEmbeddedScreenState } from "../../../src/appHooks"; | ||
import { ListenMode, useZappServer } from "../../../src/zapp/useZappServer"; | ||
import { AdhocModal } from "../../modals/AdhocModal"; | ||
import { EmbeddedScreen } from "../EmbeddedScreens/EmbeddedScreen"; | ||
|
||
export function ZappScreen({ url }: { url: string }): ReactNode { | ||
return ( | ||
<> | ||
<ZappModal /> | ||
<iframe | ||
style={{ width: "100%", height: "100%", borderRadius: "10px" }} | ||
src={url} | ||
sandbox="allow-downloads allow-same-origin allow-scripts allow-popups allow-modals allow-forms allow-storage-access-by-user-activation allow-popups-to-escape-sandbox" | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
function ZappModal(): ReactNode { | ||
useZappServer(ListenMode.LISTEN_IF_NOT_EMBEDDED); | ||
const embeddedScreen = useEmbeddedScreenState(); | ||
const dispatch = useDispatch(); | ||
return ( | ||
<AdhocModal | ||
open={embeddedScreen?.screen !== undefined} | ||
onClose={() => { | ||
dispatch({ | ||
type: "hide-embedded-screen" | ||
}); | ||
}} | ||
> | ||
<EmbeddedScreen /> | ||
</AdhocModal> | ||
); | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it doesn't already, can we have this preload the webpage in the background so that it shows up quickly, if not immediately, once the button is pressed?
https://stackoverflow.com/questions/32547844/how-to-preload-iframes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recommended answer in that thread has a few people saying that it doesn't work, and MDN doesn't list "document" as a supported "as" attribute for . Probably the only reliable option is to load the iframe in the background, but this means that it's sitting there consuming resources, running scripts, making network requests, and so on, even if the user never interacts with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make the loading process visually smoother by hiding the iframe until the Zapp is fully loaded, showing a nicer loading screen in the meantime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a new Linear issue for this.