@biolibs/bionet-panels
v0.3.17
Published
The parts of a Bionet lab application, ready to place: the freezer, where things are kept, the people, the history, what other labs are shown, backing up, and a whole window that puts them together, in a light theme and a dark one
Maintainers
Readme
@biolibs/bionet-panels
The parts of a Bionet lab application, ready to place: the freezer, where things are kept, the people, the history, what other labs are shown, backing up the key and the lab, and a whole window that puts them together. Light and dark.
Install
npm install @biolibs/bionet-panels @biolibs/bionet-react @biolibs/bionet-client @biolibs/bionet-theme reactA whole application
import "@biolibs/bionet-theme/theme.css";
import "@biolibs/bionet-panels/panels.css";
import { sourceOf } from "@biolibs/bionet-client";
import { LabProvider } from "@biolibs/bionet-react";
import { LabWindow } from "@biolibs/bionet-panels";
<LabProvider source={sourceOf(lab)}>
<LabWindow />
</LabProvider>LabWindow takes a person through the places they can be: nobody has said who is at the device, the
device is in no lab, the device is waiting to be let into one, and then the lab itself.
The panels on their own
| Panel | Shows |
|---|---|
| Freezer | Every part and its tubes: use or add, count, retire, put on offer, add a part or a tube |
| People | The roster, and for a keeper the way to add somebody and the invitation to send |
| History | Every signed change, newest first, in words, with what became of it |
| Sharing | What other labs are shown, a button to publish it, and the lab's web peer |
| SyncStatus, Trouble, DeviceKey | The small pieces |
Each reads the lab through @biolibs/bionet-react, so it goes anywhere inside a LabProvider. The
styles apply only inside an element with the class bionet, which LabWindow supplies; put a panel
used on its own inside one:
<div className="bionet"><Freezer /></div>Every colour comes from @biolibs/bionet-theme, and no rule reaches outside .bionet.
Places, and a view of your own
Places shows the tree of places and adds to it; each tube in Freezer says where it is and can be
put somewhere, by place and by position (C4). BackUpKey and RestoreKey seal the device's key to
a file and take one up again; BackUpLab and RestoreLab do the same for the lab itself. A host
that cannot offer a download supplies save to LabWindow, and may answer false if the person
chose not to save.
LabWindow takes views of the host's own, shown as tabs after its own:
<LabWindow extra={[{ id: "scene", label: "Lab", view: <MyDrawingOfTheLab /> }]} />A lab's public page
What a lab shows the world, and what it can see of another lab. These take what was fetched and checked as plain values, so they can be drawn on a server:
import { fetchInventory, originMatches, readInventory, verifyInventory } from "@biolibs/bionet";
import { Held, LabPage, PeerAnswered, PeerSilent } from "@biolibs/bionet-panels";
const mine = readInventory(published);
const checks = await verifyInventory(mine);
<LabPage name="The Wren Lab" note="A worked example, not a real freezer.">
<Held parts={mine.inventory.parts} checks={checks} origin={ORIGIN}
bound={originMatches(mine.inventory.lab.origin, ORIGIN)} />
<h2>What we can see of The Thistle Lab</h2>
<PeerAnswered found={await fetchInventory(PEER)} mine={mine.inventory.parts} />
</LabPage>| Piece | Shows |
|---|---|
| LabPage | The frame: the mark, the lab's name, a line about what it is |
| Held | What the lab holds, and what the signature over that list settles |
| PeerAnswered | Another lab that answered: what it has that this one does not, and what both have, by checksum |
| PeerSilent | Another lab that did not answer, said without accusing it |
| PartsTable, WhatASignatureSettles | The pieces those are made of |
They carry the wording as well as the markup. What a signature settles, and what it does not, has to be said the same way on every lab's page.
Everything else in this package uses hooks and is marked "use client", for frameworks that draw on
a server first.
Testing
test/panels.test.ts renders each panel to text against a real lab, and checks that the stylesheet
stays inside .bionet and uses only the theme's colours.
License
MIT
