Skip to content

Status matrix

Every row against every column at a glance, each cell a status glyph named with where it is and why.

<div id="sm-grid" data-mount="grid"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/status-matrix.css";

Usage

import { MatrixKey, StatusMatrix } from "capsomer/react/status-matrix";

<StatusMatrix
  caption="Completeness by area and site"
  columns={sites.map((s) => ({ id: s.id, name: s.name }))}
  rows={areas.map((a) => ({
    id: a.id,
    name: <Link to={`#${a.id}`}>{a.name}</Link>,
    text: a.name,
    cells: Object.fromEntries(Object.entries(a.cells).map(([id, c]) => [id, { tone: TONE[c.status], label: LABEL[c.status], reason: c.reason }])),
  }))}
/>

API reference

StatusMatrix

PropTypeRequiredDoes
captionstringYes
showCaptionboolean
columnsMatrixColumn[]Yes
rowsMatrixRow[]Yes
emptyLabelstringA cell with no status: not checked, or not applicable. Read as these words.

MatrixKey

PropTypeRequiredDoes
itemsArray<{ tone: Tone; glyph?: GlyphName; label: string }>Yes

Parts and data attributes

ClassIs
.cap-matrixthe root
.cap-matrix-keya part
.cap-matrix-marka part
.cap-matrix-nonea part

Accessibility

A real table: column headers, row headers, and each cell's image named with both, so a screen reader moving by cell hears where it is. The scroll box is a named region with tabindex="0".