Skip to content

Read state

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";

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

PropTypeRequiredDoes
whatstringYesWhat is being read, in words: "the queue", "the scoreboard".
loadingbooleanYesA read is under way.
errorstring | nullThe last read's error, in words, if it failed.
hasDatabooleanYesThere is an answer to show (the last good read, or this one).
emptyReactNodeWhy there is nothing yet, when no read has answered: "devkit's live workflow has not published one."
onRetry() => voidTry the read again (the failed state's button).
childrenReactNodeYesThe answer, drawn once there is one.

ReadAgain

PropTypeRequiredDoes
atnumber | Date | stringWhen the answer on screen was read.
readingbooleanYesA read is under way.
onRead() => voidYes
nownumberA fixed now, for a report or a test.

SourceState

PropTypeRequiredDoes
srcSourceResult<T>Yes
children(data: T) => ReactNodeYes

Parts and data attributes

ClassIs
.cap-read-againits own class
.cap-read-statethe root
AttributeValues
data-statereading

Accessibility

KeyDoes
TabReaches Try again, Read again and the table's scrolling region
Enter or Space on Read againReads 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.