Skip to content

Overlays beta ​

Interface of @v12-engine/client/kit

ts
export interface Overlays

What 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 ​

ts
clear(): void;

Takes everything away: dialogs open answer undefined

closeMenu ​

ts
closeMenu(): void;

Closes the open menu, if any

confirm ​

ts
confirm(options: {
        title: string;
        message?: string;
        yes?: string;
        no?: string;
        danger?: boolean;
    }): Promise<boolean>;

Asks yes or no: true for yes

dialogs ​

ts
readonly dialogs: () => OpenDialog[];

The dialogs open now, in the order they were opened

ts
readonly menu: () => OpenMenu | undefined;

The menu open now; none when there is no menu

openDialog ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
readonly toasts: () => Toast[];

The toasts on the screen now