Sign inGet started

Docs / Components

Components

Components: vector pieces you or an agent draw

Some things a story needs are not in your app: a pull request's checks, a chat message, an email. A component is one self-contained HTML file with CSS in .scenlit/components/, and a scene opens it like a page:

await open("component:pr-check");
await state("failed", { say: "The release check fails." });   // sets data-state="failed" on its root
await point("Release check");
await open("/");                                               // and on into the real app

Seven come built in and work without copying anything: pull-request, chat, email, terminal, issue, notification and phone. Each has states and text slots you fill from the scene:

await open("component:chat", { data: { channel: "releases", text: "2.2 is not ready: checkout fails." } });
await state("message", { say: "The news arrives where the team is." });

npx scenlit component list names them, npx scenlit inspect component:chat shows a component's states, slots and controls, and npx scenlit component add chat copies one into the project to change its look.

  • npx scenlit component new <name> writes a starting file with the rules in its comments.
  • npx scenlit component from <scene>/<shot> <name> starts from a frozen page of the real app.
  • States are plain CSS ([data-state="failed"] .icon { ... }); transitions between them are filmed.
  • <meta name="scenlit:host" content="git.example.com/..."> is the address the film's window shows for it.
  • Components are filmed as vectors, appear in the kit's gallery, and work in posts through shot.

Several things at once: overlays

A component can be laid over the film for a while, as the steps after it carry on underneath: a notification arriving while someone types, a phone buzzing as a payment lands.

await overlay("component:notification?icon=green", { sound: "notify", data: { app: "Ledgerly", title: "Kestrel Robotics is 12 days late", body: "Invoice INV-2046 for $2,400 is overdue." } });
await select("Status", "Past due", { say: "The filter shows who is behind." });   // happens under the notification
await overlay("component:phone", { at: "right", for: 3600, data: { title: "Payment received", body: "Kestrel Robotics paid $2,400." } });
Option What it does
at Where: top right (the default), top left, bottom right, bottom left, top, bottom, left, right, center
for How long it stays, in milliseconds (3200 when left out)
wait true holds the film until it has gone; otherwise the next step starts at once
scale Its size, as a factor
data, sound, say As for any component and any step

To start several things in the same moment, put them in together: a number counts while a chart draws and an answer streams in.

await together(async () => {
  await animate({ testid: "revenue" }, "count");
  await animate({ selector: "#chart" }, "draw");
  await overlay("component:notification", { sound: "notify", data: { title: "Payment received" } });
}, { stagger: 250, say: "The year, drawn as you watch." });

Inside go the steps that do not need the one cursor or the whole stage: animate, effect, overlay, sound. stagger starts each a little after the one before; say, sound and hold are for the group, and a group's sound plays as the group begins. A sound that belongs to one of them (the notification's) goes on that step, so it plays when that one shows. The film goes on when the last of them is done.

An overlay comes in from the nearest edge and leaves the way it came. A second one in the same place sits under the first while that one is still there. What is laid over is the element the component marks with data-overlay (else its first element), so any component of yours works: give its page a transparent background. An overlay is a picture, sharp at the film's size and softer in a 4k export.

A film the viewer takes part in

In the player a film can stop and hand the next click to the viewer, and it can lead somewhere. This works because the film shows the real pages, not a video of them.

await select("Status", "Past due", { say: "Choose who is behind.", byViewer: true });
await click("Kestrel Robotics", { byViewer: true });
await link("View invoices", "https://acme.com/docs/invoices", { say: "Every invoice is one click from here." });
await button("Try it with your own customers", "https://acme.com/start", { wait: true });
{ byViewer: true } On a step that clicks, types, chooses, hovers or drags: the cursor goes there, the film stops and the place is marked. It goes on when the viewer clicks it (or presses play, Enter or the space bar)
link(target, address) Something of the app is marked while the step lasts, and a click on it opens the address in a new tab
?tour on the film's address, or player: { tour: true } A click-through demo: every step that clicks, types, chooses, hovers or drags waits for the viewer, as if each had byViewer
button(text, address, { at, for, wait }) A button over the film for for milliseconds (4000), as the next steps carry on. at: where, as for an overlay ("bottom"). wait: true: the film stops on it until the viewer goes on

An address is a web address, a path on the site the film is on (/pricing) or mailto:. In an MP4 nothing stops: the film plays straight through, the link is only marked and the button is only shown.

Vector pictures and the kit

Next to every screenshot Scenlit keeps the page itself, frozen: its HTML and CSS with the scripts removed, form values written in, fonts and images saved beside it. Films and posts show the frozen page, so text stays sharp at any zoom, and export --4k gives a 3840×2160 film that is sharp too.

A frozen page is only used when it looks like the screenshot taken with it. When a page cannot be frozen well (a canvas chart, a video), that picture stays a screenshot; the run says how many are vector. "look": { "vector": false } turns it off.

npx scenlit kit turns every named picture into a library in .scenlit/kit/:

File What
<scene>/<shot>.html The frozen page: open it, restyle it, embed it
<scene>/<shot>.pdf The piece as vectors, text as text: opens in design tools
<scene>/<shot>.svg The same as SVG, when pdftocairo (poppler) is installed
index.html A gallery of every piece, live

Moving the app's own screen

Between the two pictures of an action Scenlit records what the app draws: a panel sliding in, text being typed. The film plays those frames, so the app's own animation shows. It is on by default ("look": { "motion": false } turns it off) and costs nothing when nothing moves.

Scenlit keeps each picture as the real page, so a film can move the page's own elements, and they stay sharp:

await animate({ testid: "revenue" }, "count", { say: "A hundred and fifty-eight thousand this year." });
await animate({ selector: "#chart" }, "draw", { ms: 2200 });
await animate({ selector: "table" }, "rows");

What is about to move is in its starting place from the moment its page first shows: a number at zero, a chart not yet drawn. It needs the picture to be a frozen page (the run says how many are) and the film to be served or exported; opened straight from disk in your own browser, the element stays still.

From the README of Scenlit 0.1.0. Read it on GitHub