Sprites.Ui.Window

Titled panels, modal or floating.

Sprites.Ui.Window

Sprites.Ui.Window.Floating Void

Sprites.Ui.Window.Floating(visible, title, hasClose, resizeable, coords, content)

A floating window, shown while visible is true. It drags by its title bar; hasClose adds a close button, and resizeable adds grips to drag its edges and corners. coords is the window's live rect that the caller owns and seeds with the opening position and size; a drag writes the clamped rect back to it, so it is the single source of truth and a window closed and reopened returns to where and how big it was. Seed left or top with Sprites.Ui.Window.far to dock flush against the right or bottom edge.

InputTypeDescription
visibleSprites.Reactive.ValueShows the window while true. A close button clears it.
titleString or Sprites.Reactive.ValueThe title bar text and drag handle.
hasCloseBooleanAdds a close button.
resizeableBooleanAdds grips to drag the edges and corners. A resizeable window takes its size from coords; a fixed window sizes to its content.
coordsSprites.Reactive.ValueThe window's live rect { left, top, width, height }, owned and seeded by the caller. A drag writes the clamped rect back, so a close and reopen returns there. A resizeable window reads its size here; a fixed window needs only left and top. Seed left or top with Sprites.Ui.Window.far to dock against the right or bottom edge.
contentFunctionBuilds the window body. Last, so it reads as the trailing block.

Returns nothing.

const open = Sprites.Reactive.Value(false);
const name = Sprites.Reactive.Value('Hero');
const coords = Sprites.Reactive.Value({ left: 80, top: 80, width: 320, height: 220 });
Sprites.Ui.Button.SetValue(open, true, 'Open tools');
Sprites.Ui.Window.Floating(open, 'Tools', true, true, coords, () => {
  Sprites.Ui.Content.Area(() => {
    Sprites.Ui.Input.Text(name);
  });
});
A button opens a floating window with a close button and an input.

Sprites.Ui.Window.Modal Void

Sprites.Ui.Window.Modal(visible, title, width, height, content)

A modal window over a backdrop, shown while visible is true. It rides the 'modal' overlay region, so it centres over the nearest modal region, or the whole window when there is none, and never lands in a loading region between them. Width and height are optional.

InputTypeDescription
visibleSprites.Reactive.ValueShows the window over a backdrop while true.
titleString or Sprites.Reactive.ValueThe title bar text.
widthNumberOptional width in pixels.
heightNumberOptional height in pixels.
contentFunctionBuilds the window body.

Returns nothing.

const open = Sprites.Reactive.Value(false);
const name = Sprites.Reactive.Value('Hero');
Sprites.Ui.Button.SetValue(open, true, 'Rename');
Sprites.Ui.Window.Modal(open, 'Rename', 320, undefined, () => {
  Sprites.Ui.Content.Area(() => {
    Sprites.Ui.Input.Text(name);
  });
  Sprites.Ui.Window.Footer(() => {
    Sprites.Ui.Button.SetValue(open, false, 'Done');
  });
});
A button opens a modal over the whole page; Done closes it.