ran pretty on the front
This commit is contained in:
parent
7743bda3eb
commit
4160235b92
54 changed files with 808 additions and 694 deletions
|
@ -1,4 +1,4 @@
|
|||
import type {Popup} from "./Popup";
|
||||
import type { Popup } from "./Popup";
|
||||
|
||||
export type ButtonClickedCallback = (popup: Popup) => void;
|
||||
|
||||
|
@ -6,13 +6,13 @@ export interface ButtonDescriptor {
|
|||
/**
|
||||
* The label of the button
|
||||
*/
|
||||
label: string,
|
||||
label: string;
|
||||
/**
|
||||
* The type of the button. Can be one of "normal", "primary", "success", "warning", "error", "disabled"
|
||||
*/
|
||||
className?: "normal" | "primary" | "success" | "warning" | "error" | "disabled",
|
||||
className?: "normal" | "primary" | "success" | "warning" | "error" | "disabled";
|
||||
/**
|
||||
* Callback called if the button is pressed
|
||||
*/
|
||||
callback: ButtonClickedCallback,
|
||||
callback: ButtonClickedCallback;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import {sendToWorkadventure} from "../IframeApiContribution";
|
||||
import type {ClosePopupEvent} from "../../Events/ClosePopupEvent";
|
||||
import { sendToWorkadventure } from "../IframeApiContribution";
|
||||
import type { ClosePopupEvent } from "../../Events/ClosePopupEvent";
|
||||
|
||||
export class Popup {
|
||||
constructor(private id: number) {
|
||||
}
|
||||
constructor(private id: number) {}
|
||||
|
||||
/**
|
||||
* Closes the popup
|
||||
*/
|
||||
public close(): void {
|
||||
sendToWorkadventure({
|
||||
'type': 'closePopup',
|
||||
'data': {
|
||||
'popupId': this.id,
|
||||
} as ClosePopupEvent
|
||||
type: "closePopup",
|
||||
data: {
|
||||
popupId: this.id,
|
||||
} as ClosePopupEvent,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
import type {IframeResponseEventMap} from "../../Api/Events/IframeEvent";
|
||||
import type {IframeCallback} from "../../Api/iframe/IframeApiContribution";
|
||||
import type {IframeCallbackContribution} from "../../Api/iframe/IframeApiContribution";
|
||||
import type { IframeResponseEventMap } from "../../Api/Events/IframeEvent";
|
||||
import type { IframeCallback } from "../../Api/iframe/IframeApiContribution";
|
||||
import type { IframeCallbackContribution } from "../../Api/iframe/IframeApiContribution";
|
||||
|
||||
export const registeredCallbacks: { [K in keyof IframeResponseEventMap]?: IframeCallback<K> } = {}
|
||||
export const registeredCallbacks: { [K in keyof IframeResponseEventMap]?: IframeCallback<K> } = {};
|
||||
|
||||
export function apiCallback<T extends keyof IframeResponseEventMap>(callbackData: IframeCallbackContribution<T>): IframeCallbackContribution<keyof IframeResponseEventMap> {
|
||||
export function apiCallback<T extends keyof IframeResponseEventMap>(
|
||||
callbackData: IframeCallbackContribution<T>
|
||||
): IframeCallbackContribution<keyof IframeResponseEventMap> {
|
||||
const iframeCallback = {
|
||||
typeChecker: callbackData.typeChecker,
|
||||
callback: callbackData.callback
|
||||
callback: callbackData.callback,
|
||||
} as IframeCallback<T>;
|
||||
|
||||
const newCallback = { [callbackData.type]: iframeCallback };
|
||||
Object.assign(registeredCallbacks, newCallback)
|
||||
Object.assign(registeredCallbacks, newCallback);
|
||||
return callbackData as unknown as IframeCallbackContribution<keyof IframeResponseEventMap>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue