Workbench
The frame of an editor: a canvas with a toolbar over it, an inspector beside it and tracks under it.
Demo
Usage
import { Flow, Inspector, Toolbar, Tracks, Workbench } from '@tuttn/slant'
// The frame: a toolbar laid over the canvas, the inspector beside it and the
// tracks under both. Workbench only lays the regions out; their contents and
// the state between them are yours.
<Workbench label="Pipeline editor">
<Workbench.Toolbar>
<Toolbar label="Canvas tools" tools={tools} value={tool} onValueChange={setTool} variant="floating" size="sm" />
</Workbench.Toolbar>
<Workbench.Canvas>
<Flow label="Pipeline" nodes={nodes} onNodesChange={setNodes} edges={edges}
selected={selected} onSelectedChange={setSelected} variant="plain" />
</Workbench.Canvas>
<Workbench.Inspector>
<Inspector pages={pages} value={page} onValueChange={setPage} variant="plain" />
</Workbench.Inspector>
<Workbench.Tracks>
<Tracks tracks={tracks} duration={60} selectedClip={clip} onSelectedClipChange={setClip}
label="Run timeline" variant="plain" />
</Workbench.Tracks>
</Workbench>
// Resizable: when the frame is wide, Splitter handles size the inspector and
// the tracks, starting from the fixed layout. Keep the parts as its children.
<Workbench label="Pipeline editor" resizable>…</Workbench>
// The inspector on the inline start and wider, the toolbar along the canvas's
// bottom edge, and no border: the frame fills its container.
<Workbench inspectorSide="start" inspectorWidth="20rem" variant="plain">
<Workbench.Toolbar placement="bottom">…</Workbench.Toolbar>
<Workbench.Canvas label="Graph">…</Workbench.Canvas>
<Workbench.Inspector label="Properties">…</Workbench.Inspector>
<Workbench.Tracks label="Timeline">…</Workbench.Tracks>
</Workbench>Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | The frame's accessible name. Without one the root is a plain box, and only its regions are named. |
inspectorSide | 'start' | 'end' | 'end' | Which side of the canvas the inspector sits on: the inline end (right in left-to-right text) or the start. |
inspectorWidth | number | string | 280 | The inspector column's width: pixels when a number, any CSS length when a string. With `resizable`, where it starts. |
resizable | boolean | false | Lets the reader resize the regions: a Splitter handle between the canvas and the inspector, and another above the tracks, each a focusable separator moved with the arrow keys or a drag. They start where the fixed layout put the regions. Below 640px of width the frame still stacks, with no handles. The parts must be the frame's own children (fragments are fine): a part inside another component keeps the fixed layout. |
variant | 'framed' | 'plain' | 'framed' | `framed` draws a hairline border and the large radius on the surface; `plain` fills its container edge to edge. |
Workbench.Toolbar placement | 'top' | 'bottom' | 'top' | Lays the toolbar over the top or the bottom edge of the canvas, centred and inset a little. |
Workbench.Canvas label | string | "Canvas" | The canvas region's accessible name (messages.canvasRegion). |
Workbench.Inspector label | string | "Inspector" | The inspector region's accessible name (messages.inspectorRegion). |
Workbench.Tracks label | string | "Tracks" | The tracks region's accessible name (messages.tracksRegion). |
…rest | HTMLAttributes<HTMLDivElement> | — | className, style, other attributes and the ref go on each part's own element: the root, the toolbar's slot, and each region (a group named by its label). |
Layout
Workbench is a grid of three regions: the canvas and the inspector share the first row, the tracks run under both, and hairlines divide them. Workbench.Toolbar shares the canvas's cell, centred on its top edge (or its bottom, with placement="bottom") and above it; only the toolbar takes the pointer, the rest of the canvas stays reachable around it. The canvas region is at least 320px tall and its child fills it; the inspector column is inspectorWidth wide (280px) and scrolls on its own when the frame is given a height; the tracks take the height they need. The parts are slots: put <Toolbar variant="floating">, <Flow variant="plain">, <Inspector variant="plain"> and <Tracks variant="plain"> in them, or anything else. Workbench holds no state of its own, so the selection that ties them together is yours, as the demo shows.
Keyboard
Workbench adds no keys; each child keeps its own. The grid places the parts by area, not by order, so write them in the order Tab should take: Workbench.Toolbar first, then the canvas, the inspector and the tracks. Tab then reaches the toolbar before the canvas it sits over, whatever side the inspector is drawn on.
Narrow
The root is a size container. At 640px of its own width or less, the grid becomes one column: the canvas (at least 280px tall), then the inspector, then the tracks. It follows the frame's width, not the window's, so a Workbench in a 280px wall column stacks while the same one across a page doesn't.
Right to left
The grid areas are logical: the inspector sits on the inline end, which is the left under dir="rtl", and inspectorSide="start" moves it to the other side. What the regions hold decides for itself: Flow's canvas stays physical, while Inspector and Tracks mirror.
Screen readers
Each region is a group named by its label, "Canvas", "Inspector" and "Tracks" by default, and the root is a group too once it has a label. The toolbar's slot has no role: the Toolbar inside it is the toolbar. Name what goes inside differently from its region (the demo's Tracks is "Run timeline" inside the "Tracks" region) so the two don't read alike.
Resizing
By default the regions are fixed: the inspector's width is inspectorWidth and the rows follow their content. With resizable, a frame at least 640px wide lays them out in two Splitters instead, starting where the fixed layout put them: a handle between the canvas and the inspector ("Resize the inspector") and one above the tracks ("Resize the tracks"). Each is a focusable separator in the tab order between the regions it divides; drag it, or move it with the arrow keys, Home and End, and Enter collapses the first pane. The server and a narrow frame keep the fixed layout. Give the parts as the frame's own children (fragments are fine): parts inside a component of their own keep the fixed layout.