Flow Diagram¶
A hub in the middle with lanes of pills on its left, right, and below, each joined to the hub by a line with arrows that show the way things travel.
Decision¶
| When | Use |
|---|---|
| Showing what one thing is connected to and which way each connection runs, such as the servers this one pulls from, pushes to, and syncs with | Flow Diagram |
| A long list of connections | A List or a Paginated Table |
| Steps in order | A Stepper or a Timeline |
Usage¶
import { createFlowDiagram } from './configurationpage?name=myplugin_stolon.js';
container.appendChild(createFlowDiagram({
label: 'Servers this one is set up with',
hub: { label: 'Home' },
lanes: [
{ key: 'pull', side: 'left', direction: 'in', color: 'green', label: 'Pull', items: [{ label: 'Office', status: 'green' }] },
{ key: 'push', side: 'right', direction: 'out', color: 'blue', label: 'Push', items: [{ label: 'Cabin', status: 'orange' }] }
]
}).element);
Classes: stolon-flow-diagram, stolon-flow-diagram-lane, stolon-flow-diagram-item, stolon-flow-diagram-dot. The handle is { element, getValue, setValue, destroy }.
Parts: stolon-flow-diagram-arrow, stolon-flow-diagram-hub, stolon-flow-diagram-hub-box, stolon-flow-diagram-hub-label, stolon-flow-diagram-join, stolon-flow-diagram-label, stolon-flow-diagram-line, stolon-flow-diagram-pill, stolon-flow-diagram-stub, stolon-flow-diagram-trunk.
States and Modifiers¶
- It is drawn at its own size when it fits its box, never shrunk. When it does not fit, it is drawn again as a stack at full size, with the
stolon-stackedmodifier. The hub sits on top and each lane is a list under it, each on its own upright line, so no line crosses another and every label stays readable. It switches back as the box widens. - A lane is
{ key, side, direction, color, label, items }.sideis'left','right', or'below', and each side draws its first lane only. An empty lane is not drawn, and with no lanes the hub stands alone. directionsets the arrows.'in'points at the hub,'out'points at each pill, and'both'does both.coloris a status color name or a hex code, gray by default, and colors the lane's lines and arrows. A hex code sets--stolon-customon the lane, asapplyColordoes.- An item is
{ label, title, status, id }.statusis a status color name or a hex code for the dot in its pill, and an item with no status has no dot.titleis the pill's tooltip, which is the label and the lane label by default. - A label longer than
maxLabelcharacters, 18 by default, ends in an ellipsis. The tooltip keeps it whole. In the stack a label uses the room it has, and only amaxLabelthe caller set cuts it. - A side lane holds eight pills in a column and a lane below holds four in a row, or half the lane when that is more. A second column or row sits in the gaps of the first, so there are never more than two.
- The hub stays in the middle of the picture.
hub.titleis its tooltip, and the label by default. - The diagram is
role="img", and its accessible name listslabel, the hub, and each item with its lane label. WithonSelectit isrole="group", and each pill is a button that takes focus, answers a click, Enter, and Space, and shows an accent ring while focused. - Never rely on a dot's color alone. Put the state in the item's
title.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
createFlowDiagram¶
function createFlowDiagram(options?: FlowDiagramOptions): FlowDiagramHandle
A hub in the middle with lanes of pills on its left, right, and below, each pill joined to the hub by a line in the lane's color with arrows that show the way things travel. A lane past one pill per row or column wraps into a second, offset into the gaps of the first, and the hub stays centered.
| Option | Type | What it does |
|---|---|---|
hub |
FlowDiagramHub |
{ label, title } for the node in the middle |
lanes |
FlowDiagramLane[] |
array of { key, side, direction, color, label, items } where side is 'left', 'right', or 'below', direction is 'in', 'out', or 'both', color is a status color name or a hex code (default 'gray'), label names the lane in the accessible name, and items is an array of { label, title, status, id }. An empty lane is not drawn, and each side draws its first lane only |
maxLabel |
number |
characters of a label before it ends in an ellipsis (default 18) [optional] |
label |
string |
text the accessible name starts with [optional] |
| Handle member | Type |
|---|---|
getValue |
(): FlowDiagramValue |
setValue |
(next: FlowDiagramValue): void |
destroy |
(): void |
| Type | What it is |
|---|---|
FlowDiagramHub |
The node in the middle of a flow diagram. title is its tooltip (default the label). |
FlowDiagramItem |
One pill in a lane. status is a status color name or a hex code for its dot, and no status draws no dot. |
FlowDiagramLane |
One lane of pills on a side of the hub. direction 'in' points the arrows at the hub, 'out' at the pills, and 'both' at both. |
FlowDiagramValue |
What a flow diagram draws, as setValue takes it and getValue returns it. |
| Class | What it looks like |
|---|---|
stolon-flow-diagram |
Hub and lanes picture that shrinks to fit its container and stays centered |
stolon-flow-diagram-hub-box |
The node in the middle, a raised surface box with a neutral border, never a lane color, and a bold label |
stolon-flow-diagram-lane |
One lane, whose lines and arrows take the lane's color |
stolon-flow-diagram-pill |
A pill in a lane, a surface box with a status dot and a label, and an accent ring while focused |
stolon-flow-diagram-dot |
Round status dot inside a pill, in a status color |
Example¶
Example Code¶
<!-- title: Flow Diagram -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const mount = document.getElementById('mount');
mount.appendChild(base.createFlowDiagram({
label: 'Servers this one is set up with',
hub: { label: 'Home', title: 'Home, this server' },
lanes: [
{ key: 'pull', side: 'left', direction: 'in', color: 'green', label: 'Pull', items: [
{ label: 'Office', status: 'green', title: 'Office, Pull, answering' },
{ label: 'Parents', status: 'orange', title: 'Parents, Pull, no plugin' },
{ label: 'Archive', status: 'gray', title: 'Archive, Pull, disabled' }
] },
{ key: 'push', side: 'right', direction: 'out', color: 'blue', label: 'Push', items: [
{ label: 'Cabin', status: 'green', title: 'Cabin, Push, answering' },
{ label: 'Backup NAS', status: 'red', title: 'Backup NAS, Push, not answering' }
] },
{ key: 'sync', side: 'below', direction: 'both', color: 'purple', label: 'Sync', items: [
{ label: 'Studio', status: 'green', title: 'Studio, Sync, answering' },
{ label: 'Lake House', status: 'green', title: 'Lake House, Sync, answering' },
{ label: 'Grandma', status: 'orange', title: 'Grandma, Sync, no plugin' },
{ label: 'Travel Laptop Server', status: 'red', title: 'Travel Laptop Server, Sync, not answering' },
{ label: 'Garage', status: 'gray', title: 'Garage, Sync, disabled' }
] }
]
}).element);
</script>