A read's states said one way in every app, plus the source line's Read again and an admin table.
<div class="cap-specimen-row" id="rs-reading"><div data-mount="reading"></div></div>
Installation
// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/read-state.css";
import "capsomer/tokens.css";
import "capsomer/read-state.css";
import { ReadState, ReadAgain, SourceState } from "capsomer/react/read-state";
Usage
import { ReadAgain, ReadState } from "capsomer/react/read-state";
import { Panel, TablePanel } from "capsomer/react/panel";
import "capsomer/read-state.css";
<Panel title="Sites" src={<ReadAgain at={data?.read_at} reading={load.loading} onRead={load.reread} />}>
<ReadState what="the backups" loading={load.loading} error={load.error} hasData={!!data}>
<BackupTable rows={data.sites} />
</ReadState>
</Panel>
<TablePanel title="Operator actions" headingId="audit" caption="The audit log, newest first." reading={pending}
isEmpty={rows.length === 0} empty={<Empty kind="nothing-yet" flush title="No audit log entries yet." />}>
<thead>…</thead>
<tbody>…</tbody>
</TablePanel>
Examples
The read failed, with Try again
<div class="cap-specimen-row" id="rs-failed"><div data-mount="failed"></div></div>
Nothing read yet, and why
<div class="cap-specimen-row" id="rs-nothing-yet"><div data-mount="nothing-yet"></div></div>
A reread failed over the last answer
<div class="cap-specimen-row" id="rs-stale"><div data-mount="stale"></div></div>
One source of several: empty, no data, not read
<div class="cap-specimen-row" id="rs-sources"><div data-mount="sources"></div></div>
The source line: how old, and Read again
<div class="cap-specimen-row" id="rs-read-again"><div data-mount="read-again"></div></div>
A panel reading again
<div class="cap-specimen-row" id="rs-reading-again"><div data-mount="reading-again"></div></div>
An admin table in its panel
<div class="cap-specimen-row" id="rs-table-panel"><div data-mount="table-panel"></div></div>
An admin table with nothing in it
<div class="cap-specimen-row" id="rs-table-empty"><div data-mount="table-empty"></div></div>
API reference
ReadState
| Prop | Type | Required | Does |
|---|
what | string | Yes | What is being read, in words: "the queue", "the scoreboard". |
|---|
loading | boolean | Yes | A read is under way. |
|---|
error | string | null | | The last read's error, in words, if it failed. |
|---|
hasData | boolean | Yes | There is an answer to show (the last good read, or this one). |
|---|
empty | ReactNode | | Why there is nothing yet, when no read has answered: "devkit's live workflow has not published one." |
|---|
onRetry | () => void | | Try the read again (the failed state's button). |
|---|
children | ReactNode | Yes | The answer, drawn once there is one. |
|---|
ReadAgain
| Prop | Type | Required | Does |
|---|
at | number | Date | string | | When the answer on screen was read. |
|---|
reading | boolean | Yes | A read is under way. |
|---|
onRead | () => void | Yes | |
|---|
now | number | | A fixed now, for a report or a test. |
|---|
SourceState
| Prop | Type | Required | Does |
|---|
src | SourceResult<T> | Yes | |
|---|
children | (data: T) => ReactNode | Yes | |
|---|
Parts and data attributes
| Class | Is |
|---|
.cap-read-again | its own class |
|---|
.cap-read-state | the root |
|---|
| Attribute | Values |
|---|
data-state | reading |
|---|
Accessibility
| Key | Does |
|---|
| Tab | Reaches Try again, Read again and the table's scrolling region |
| Enter or Space on Read again | Reads again |
- Reading is a status region; a failed first read is an alert (Empty's failed contract); a failed reread is a polite banner.
- Status words carry a glyph and a word, never color alone.
- The table panel's scrolling region is focusable and named by the panel's heading.