Skip to content

Commit

Permalink
fix(ui): change to fit new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ororsatti committed Oct 23, 2024
1 parent 076cc95 commit af87143
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/app-connector/src/adapters/iframe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
InitializationMessage,
RPCMessage,
Zapp
Zapp,
} from "@parcnet-js/client-rpc";
import { InitializationMessageType } from "@parcnet-js/client-rpc";
import { createNanoEvents } from "nanoevents";
Expand Down Expand Up @@ -46,7 +46,7 @@ export interface DialogController {
export function connect(
zapp: Zapp,
element: HTMLElement,
clientUrl = "https://zupass.org"
clientUrl = "https://zupass.org",
): Promise<ParcnetAPI> {
// Will throw if the URL is invalid
const normalizedUrl = new URL(clientUrl);
Expand All @@ -58,7 +58,8 @@ export function connect(
dialog.style.borderWidth = "0px";
dialog.style.borderRadius = "16px";
dialog.style.padding = "0px";
dialog.style.backgroundColor = "#19473f";
dialog.style.backgroundColor = "white";
dialog.style.overflow = "hidden";
dialog.style.width = "90vw";
dialog.style.maxWidth = "600px";
dialog.style.height = "90vh";
Expand Down Expand Up @@ -106,6 +107,9 @@ export function connect(
// Create the iframe that will host the client
const iframe = document.createElement("iframe");
const sandboxAttr = document.createAttribute("sandbox");
const scrollingAttr = document.createAttribute("scrolling");
scrollingAttr.value = "no";

sandboxAttr.value =
"allow-same-origin allow-scripts allow-popups allow-modals allow-forms allow-storage-access-by-user-activation allow-popups-to-escape-sandbox";
iframe.attributes.setNamedItem(sandboxAttr);
Expand All @@ -124,7 +128,7 @@ export function connect(
// Create a new RPC client
const client = new ParcnetRPCConnector(
chan.port2,
new DialogControllerImpl(dialog)
new DialogControllerImpl(dialog),
);
// Tell the RPC client to start. It will call the function we pass in
// when the connection is ready, at which point we can resolve the
Expand All @@ -150,11 +154,11 @@ export function connect(
contentWindow,
{
type: InitializationMessageType.PARCNET_CLIENT_CONNECT,
zapp: zapp
zapp: zapp,
},
"*",
// Our RPC client has port2, send port1 to the client
[chan.port1]
[chan.port1],
);
})
.catch((err) => {
Expand All @@ -164,7 +168,7 @@ export function connect(
console.error("no iframe content window!");
}
},
{ once: true }
{ once: true },
);
shadow.appendChild(iframe);
});
Expand All @@ -174,7 +178,7 @@ export function postWindowMessage(
window: Window,
message: InitializationMessage,
targetOrigin: string,
transfer: Transferable[] = []
transfer: Transferable[] = [],
): void {
window.postMessage(message, targetOrigin, transfer);
}
Expand Down

0 comments on commit af87143

Please sign in to comment.