The stage

The stage is one React component. It shows a scene and, given the next one, moves there; it hears acts and never changes a scene itself.

Use it

A screen that shows a scene
import { readScene, after } from "@hopper/dynamic-ui/scene";
import { Stage } from "@hopper/dynamic-ui/react";
import "@hopper/dynamic-ui/style.css";

const read = readScene(value); // from an agent, an operation, a graph answer
if (read.ok) {
  return <Stage scene={read.scene} label="Who is connected" room="day"
    onAct={(act) => setScene(after(read.scene, act))} />;
}

A thing keeps its id from scene to scene, and that is the whole of the motion. What stays travels to its new place, what is new gathers out of the thing it belongs to, and what is gone returns to it.

A scene with models needs their shapes. The stage asks the host for each by the digest the scene names, and only when the model is drawn.

Giving the stage its shapes
<Stage scene={scene} label="The parts of a gear reduction" onAct={onAct}
  shapes={async (shape) => {
    const answer = await fetch("/shapes/" + shape.digest.slice(7) + ".mesh");
    return new Uint8Array(await answer.arrayBuffer());   // checked against shape.digest before it is drawn
  }} />

Your own look

The stage names no colour and no typeface. A host says six tokens and the stage wears them. This page’s stage wears these.

A host’s stylesheet
.dyn-stage {
  --dyn-ground: var(--surface);
  --dyn-ink: var(--ink);
  --dyn-hot: var(--highlight);
  --dyn-font: var(--sans);
  --dyn-font-display: var(--display);
  --dyn-radius: var(--radius-card);
}

Day and night

A stage stands on a light ground or a dark one, whichever the host’s tokens say, and draws its light to suit: on a dark ground light adds to light, on a light one it is ink laid over. When the page changes its look, the stage reads the tokens again.

What holds

  • Nothing moves for longer than half a second. When someone asks for reduced motion, nothing moves at all.
  • Colour is the host’s highlight on what is looked at or can be acted on, and nowhere else.
  • A stage at a phone’s width is the same scene laid out again, not a second design.
  • A scene is at most 600 things and 2,000 ties. More than that is a question for a graph, not a screen.
  • A scene is read whole or refused with a code and where. Nothing is repaired or guessed.

Not here yet

  • The package is used inside HopperLabs apps. It is not published for others to install.
  • Posts on Bluesky, and any player beyond YouTube videos and posts on X.
  • An engine asked from a page. The calculation on this site holds six answers the engine gave beforehand; in the app, an agent runs the engine and says the scene again.
  • A model of more than one solid, or any shape but a mesh of triangles.
  • A stage for anything but React.