Overlays beta
Interface of @v12-engine/client/kit
export interface OverlaysWhat floats over one place, a game or the page: its toasts, its dialogs, its menu, which an OverlayRoot given it shows. A game has its own, gone with it (clear): what it opened does not stay over what comes after it; an app of scenes has its own over its menus (StartedApp.overlays), the editor its own. A component reaches those of where it is with useOverlays()
Members
clear
clear(): void;Takes everything away: dialogs open answer undefined
closeMenu
closeMenu(): void;Closes the open menu, if any
confirm
confirm(options: {
title: string;
message?: string;
yes?: string;
no?: string;
danger?: boolean;
}): Promise<boolean>;Asks yes or no: true for yes
dialogs
readonly dialogs: () => OpenDialog[];The dialogs open now, in the order they were opened
menu
readonly menu: () => OpenMenu | undefined;The menu open now; none when there is no menu
openDialog
openDialog(options: {
title: string;
message?: string;
body?: () => Node;
buttons?: DialogButton[];
}): Promise<string | undefined>;Asks something in a dialog over everything: what the promise gives is the value of the button pressed, or undefined when it was closed otherwise (Escape, outside it, the place gone)
openMenu
openMenu(at: Element | {
x: number;
y: number;
}, items: MenuItem[], placement?: TipPlacement): () => void;Opens a menu by an element or at a point (where a right click was). One at a time: opening one closes the other
toast
toast(message: string, options?: {
tone?: Tone;
seconds?: number;
action?: Toast['action'];
}): () => void;Shows a message for a while (seconds, 4 when left out; Infinity until closed). Gives back what closes it early
toaster
readonly toaster: Toaster;Ark's toaster, which keeps them: for what toast does not say (one changed while it shows, one that follows a promise, all of them paused). What it is told shows in toasts too
toasts
readonly toasts: () => Toast[];The toasts on the screen now