From ed916636a1668decffbc3b1edaabb8da78681908 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 14:21:55 -0800 Subject: [PATCH 1/9] kit: MatrixGrid, cells over two axes that don't repeat their headings The axes' names go once in the corner, each axis's values once along its edge, and a cell shows only what its headings don't: by default a small mark with its whole name as a tooltip and for screen readers. Empty cells sit on the kit's hatch; values and cells that arrive or leave are change regions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- changelog.d/matrix-grid.md | 5 + docs/guides/renderer-kit-components.md | 3 + docs/guides/renderer-kit-type.md | 11 ++ docs/reference/renderer-kit.md | 55 +++++++ packages/renderers/kit/react.css | 1 + packages/renderers/kit/src/react.ts | 1 + .../renderers/kit/src/react/matrix-grid.tsx | 145 ++++++++++++++++++ packages/renderers/kit/styles/matrix.css | 74 +++++++++ .../renderers/kit/test/matrix-grid.test.mjs | 42 +++++ 9 files changed, 337 insertions(+) create mode 100644 changelog.d/matrix-grid.md create mode 100644 packages/renderers/kit/src/react/matrix-grid.tsx create mode 100644 packages/renderers/kit/styles/matrix.css create mode 100644 packages/renderers/kit/test/matrix-grid.test.mjs diff --git a/changelog.d/matrix-grid.md b/changelog.d/matrix-grid.md new file mode 100644 index 000000000..f6a46253b --- /dev/null +++ b/changelog.d/matrix-grid.md @@ -0,0 +1,5 @@ +--- +section: kit +--- + +- **`MatrixGrid` renders two-axis tables without repeating headings**. The corner names both axes (`os × compiler`) and the edges list row and column values once. Each cell shows only what its headings don't already say, defaulting to a small mark with its full name as a tooltip and for screen readers; empty cells are hatched. Added or removed values and cells render as change regions. See [Renderer kit: type and values](docs/guides/renderer-kit-type.md#grids-over-two-axes). diff --git a/docs/guides/renderer-kit-components.md b/docs/guides/renderer-kit-components.md index 57c9afe7e..e2d67542d 100644 --- a/docs/guides/renderer-kit-components.md +++ b/docs/guides/renderer-kit-components.md @@ -324,6 +324,9 @@ accept token scale steps rather than raw lengths or colors—this is how - `Facts` and `Fact` (an item's facts as a key-value list) and `ValueList` (a list of values with changes marked inline, not in pills): see [Renderer kit: type and values](renderer-kit-type.md#facts-and-value-lists). +- `MatrixGrid` renders a two-axis table with row and column headings along the + edges so cells don't repeat them; see + [Renderer kit: type and values](renderer-kit-type.md#grids-over-two-axes). - `Stack` and `Inline` arrange children in a vertical column or wrapping row with `gap={1…8}` steps from the spacing scale. - `Text` renders text using a [type role](#type-roles) (`variant`), or `size` diff --git a/docs/guides/renderer-kit-type.md b/docs/guides/renderer-kit-type.md index 19f56096a..6e2231863 100644 --- a/docs/guides/renderer-kit-type.md +++ b/docs/guides/renderer-kit-type.md @@ -56,3 +56,14 @@ in monospace, inheriting the surrounding text color with no fill or border. `Slot` renders a named placeholder in a template (`Build on os`) as muted monospace without brackets. `Tag` renders a quiet category label (such as a lifetime or mode) with a recessed fill and no border. + +## Grids over two axes + +`MatrixGrid` renders a two-axis table (such as matrix runs by OS and compiler, +or flags by environment). The corner names both axes (`os × compiler`), the +edges list row and column values once, and each cell shows only what its +headings don't already say. `cell(row, column)` returns a cell, or `null` for an +empty hatched cell. A cell without `content` shows a small mark, using its full +name (`title`) as a tooltip and for screen readers. Added or removed values and +cells render as change regions. Pass a `caption` to place several grids side by +side, one per extra dimension. diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 8726a57f6..2fade0e17 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -4553,6 +4553,61 @@ KitRenderer(__0: { "component": ComponentClass, any> | Connects a kit renderer component to its host through the renderer frame protocol. +### `MatrixAxis` + +```ts +interface MatrixAxis +``` + +One axis of a `MatrixGrid`: its name, in words, and its values. + +| Member | Signature | Description | +|---|---|---| +| `code` | `"code"?: false \| true` | Sets its values as code (identifiers, versions), in the monospace font. | +| `name` | `"name": Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What the axis is ("os", "compiler"), in the label role. | +| `values` | `"values": Array` | | + +### `MatrixCell` + +```ts +interface MatrixCell +``` + +What one cell holds: whether something is there, its change, and anything its headings don't say. + +| Member | Signature | Description | +|---|---|---| +| `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | | +| `content` | `"content"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What tells the cell apart beyond its headings; a `MatrixMark` is drawn when there is nothing. | +| `title` | `"title"?: string` | The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). | + +### `MatrixGrid` + +```ts +MatrixGrid(__0: { "caption"?: Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "cell": { (row: string, column: string | undefined): MatrixCell | null }; "columns"?: MatrixAxis; "emphasis"?: number; "label": string; "rows": MatrixAxis; "vacant"?: string }): Element +``` + +A grid over two axes, as a table: the axes' names in its corner (`os × compiler`), each axis's values once along its +edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole +name as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) +is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck +through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of +cells along `rows`. `caption` names the grid when several stand together (one per further dimension). + +### `MatrixValue` + +```ts +interface MatrixValue +``` + +One value along a `MatrixGrid` axis. + +| Member | Signature | Description | +|---|---|---| +| `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | The value's own change: it arrives or leaves along with its row or column. | +| `key` | `"key": string` | Stable key: unique along its axis. | +| `label` | `"label"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What the heading says; the key when left out. | + ### `MountOptions` ```ts diff --git a/packages/renderers/kit/react.css b/packages/renderers/kit/react.css index e9a64af31..cc49e2989 100644 --- a/packages/renderers/kit/react.css +++ b/packages/renderers/kit/react.css @@ -11,6 +11,7 @@ @import './styles/diff.css'; @import './styles/chips.css'; @import './styles/facts.css'; +@import './styles/matrix.css'; @import './styles/layout.css'; @import './styles/scope.css'; @import './styles/table.css'; diff --git a/packages/renderers/kit/src/react.ts b/packages/renderers/kit/src/react.ts index 8551f309d..9a537c726 100644 --- a/packages/renderers/kit/src/react.ts +++ b/packages/renderers/kit/src/react.ts @@ -25,6 +25,7 @@ export * from './react/status-tab.js' export * from './react/generated.js' export * from './react/diff-components.js' export * from './react/facts.js' +export * from './react/matrix-grid.js' export * from './react/icons.js' export {Fold, useFolds} from './react/fold.js' export {IdentifierText} from './react/identifiers.js' diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx new file mode 100644 index 000000000..cf5d884b2 --- /dev/null +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -0,0 +1,145 @@ +// A grid over two axes (a matrix's runs by OS and compiler, flags by environment): headings on each axis once, and in +// each cell only what its headings don't say, by default a mark that one exists there. +import type {ReactNode} from 'react' +import {identifier as identifierAttributes} from '@githubnext/projections-renderer-sdk/presentation' +import {statusLabels, type ChangeClassification} from '../emphasis.js' + +/** One value along a `MatrixGrid` axis. */ +export interface MatrixValue { + /** Stable key: unique along its axis. */ + key: string + /** What the heading says; the key when left out. */ + label?: ReactNode + /** The value's own change: it arrives or leaves along with its row or column. */ + change?: ChangeClassification | undefined +} + +/** One axis of a `MatrixGrid`: its name, in words, and its values. */ +export interface MatrixAxis { + /** What the axis is ("os", "compiler"), in the label role. */ + name: ReactNode + values: readonly MatrixValue[] + /** Sets its values as code (identifiers, versions), in the monospace font. */ + code?: boolean +} + +/** What one cell holds: whether something is there, its change, and anything its headings don't say. */ +export interface MatrixCell { + /** What tells the cell apart beyond its headings; a `MatrixMark` is drawn when there is nothing. */ + content?: ReactNode + change?: ChangeClassification | undefined + /** The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). */ + title?: string +} + +const change = (value: ChangeClassification | undefined) => (value !== undefined && value !== 'unchanged' ? {'data-change': value} : {}) + +/** A change worth saying: anything but unchanged. */ +const said = (value: ChangeClassification | undefined): value is Exclude => + value !== undefined && value !== 'unchanged' + +function Heading({value, code}: {value: MatrixValue; code: boolean}) { + const changed = said(value.change) + return ( + + + {said(value.change) && {statusLabels[value.change]}: } + {value.label ?? value.key} + + + ) +} + +/** + * A grid over two axes, as a table: the axes' names in its corner (`os × compiler`), each axis's values once along its + * edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole + * name as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) + * is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck + * through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of + * cells along `rows`. `caption` names the grid when several stand together (one per further dimension). + */ +export function MatrixGrid({ + label, + rows, + columns, + cell, + caption, + vacant = 'None', + emphasis, +}: { + /** The grid's accessible name. */ + label: string + rows: MatrixAxis + columns?: MatrixAxis + cell: (row: string, column: string | undefined) => MatrixCell | null + caption?: ReactNode + /** What assistive technology hears in a vacant cell. */ + vacant?: string + emphasis?: number +}) { + const style = emphasis === undefined ? undefined : ({'--emphasis': emphasis} as Record) + const body = (row: MatrixValue, column: MatrixValue | undefined) => { + const found = cell(row.key, column?.key) + if (!found) { + return ( + + + {vacant} + + + ) + } + const changed = said(found.change) + return ( + + + {found.content !== undefined && {found.content}} + + {said(found.change) ? `${statusLabels[found.change]}: ` : ''} + {found.title ?? ''} + + + + ) + } + return ( +
+ {caption !== undefined && caption !== null &&
{caption}
} + + + + + {columns?.values.map(value => ( + + ))} + + + + {rows.values.map(row => ( + + + {columns ? columns.values.map(column => body(row, column)) : body(row, undefined)} + + ))} + +
+ {columns ? ( + <> + {rows.name} × {columns.name} + + ) : ( + rows.name + )} + + +
+ +
+
+ ) +} diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css new file mode 100644 index 000000000..fc848bc03 --- /dev/null +++ b/packages/renderers/kit/styles/matrix.css @@ -0,0 +1,74 @@ +/* + * Matrix grids (`MatrixGrid`): a table of small cells spaced apart, its axes' names in the corner in the label role, + * each axis's values once along its edge, centred over their columns. A cell its headings fully name shows a small + * mark, drawn as its own background so it centres at any zoom; a vacant one sits on the kit's hatch (a fill, never an + * edge). A heading or cell that arrives or leaves is a kit change region; a removed one is dashed, as removals are. + */ +.pk .pk-matrix { + margin: 0; + min-width: 0; +} +.pk .pk-matrix + .pk-matrix { + margin-top: var(--projections-space-3); +} +.pk .pk-matrix-caption { + margin: 0 0 var(--projections-space-1); +} +.pk .pk-matrix-grid { + border-collapse: separate; + border-spacing: var(--projections-space-1); + margin: calc(-1 * var(--projections-space-1)); +} +.pk .pk-matrix-grid th { + padding: 0 var(--projections-space-2) 0 0; + font-weight: var(--projections-font-weight-normal); + text-align: start; + vertical-align: middle; + white-space: nowrap; +} +.pk .pk-matrix-grid thead th:not(.pk-matrix-corner) { + padding: 0 var(--projections-space-2); + text-align: center; +} +.pk .pk-matrix-grid td { + padding: 0; + vertical-align: middle; +} +.pk .pk-matrix-value { + display: inline-flex; + border-radius: var(--projections-radius-sm); +} +.pk .pk-matrix-value[data-change] { + margin: 0 calc(-1 * var(--projections-space-1)); + padding: 0 var(--projections-space-1); +} +.pk .pk-matrix-cell { + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + min-width: var(--projections-space-8); + min-height: var(--projections-control-height-sm); + padding: 2px var(--projections-space-2); + border-radius: var(--projections-radius-sm); + background: var(--raised); + box-shadow: inset 0 0 0 var(--stroke) var(--border); + white-space: nowrap; +} +.pk .pk-matrix-cell[data-marked] { + background-image: radial-gradient(circle, var(--subtle) 2.5px, transparent 3px); + background-position: center; + background-repeat: no-repeat; +} +.pk .pk-matrix-cell[data-marked][data-change] { + background-image: radial-gradient(circle, var(--pk-change-ink) 2.5px, transparent 3px); +} +.pk .pk-matrix-cell[data-vacant] { + background: var(--pk-vacant); + box-shadow: none; +} +.pk .pk-matrix .pk-region[data-change='removed'] { + box-shadow: none; + outline: var(--stroke) dashed color-mix(in srgb, var(--pk-region-edge) calc(var(--emphasis, 1) * 100%), transparent); + outline-offset: calc(-1 * var(--stroke)); +} diff --git a/packages/renderers/kit/test/matrix-grid.test.mjs b/packages/renderers/kit/test/matrix-grid.test.mjs new file mode 100644 index 000000000..5c47f3a3a --- /dev/null +++ b/packages/renderers/kit/test/matrix-grid.test.mjs @@ -0,0 +1,42 @@ +import {test} from 'node:test' +import assert from 'node:assert/strict' +import {createElement} from 'react' +import {renderToStaticMarkup} from 'react-dom/server' +import {MatrixGrid} from '../dist/react.js' +import {plain} from './markup.mjs' + +const grid = props => + renderToStaticMarkup( + createElement(MatrixGrid, { + label: 'build runs', + rows: {name: 'os', code: true, values: [{key: 'windows'}, {key: 'macos', change: 'added'}]}, + columns: {name: 'compiler', values: [{key: 'Transparent'}, {key: 'Background'}]}, + cell: (row, column) => + row === 'macos' && column === 'Background' ? null : {title: `${row} · ${column}`, ...(row === 'macos' ? {change: 'added'} : {})}, + ...props, + }), + ) + +test('a matrix names its axes once and marks each cell without repeating its headings', () => { + const markup = grid() + assert.match(markup, /os × compiler<\/th>/u) + assert.match( + markup, + /windows · Transparent<\/span><\/span>/u, + ) + // The row that arrives is a change region, said in words; the excluded combination is vacant. + assert.match( + markup, + /Added: <\/span>macos/u, + ) + assert.match(markup, /None<\/span><\/span>/u) + // On screen the cells say nothing their headings say. + const visible = plain(markup.replaceAll(/.*?<\/span>/gu, '')) + assert.equal(visible, 'os × compilerTransparentBackgroundwindowsmacos') +}) + +test('a cell with content of its own shows it, and the grid takes its own emphasis', () => { + const markup = grid({emphasis: 0.5, cell: () => ({content: 'node 22'})}) + assert.match(markup, /^
/u) + assert.match(markup, /node 22<\/span>/u) +}) From b3b57ec255ac4668ba1200adc67880262f8efe61 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 16:17:21 -0800 Subject: [PATCH 2/9] MatrixGrid: an empty content is a mark, said present, and a changed mark fades with emphasis Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- docs/guides/renderer-kit-type.md | 7 ++++--- docs/reference/renderer-kit.md | 6 +++--- .../renderers/kit/src/react/matrix-grid.tsx | 17 ++++++++++++----- packages/renderers/kit/styles/matrix.css | 7 ++++++- .../renderers/kit/test/matrix-grid.test.mjs | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/docs/guides/renderer-kit-type.md b/docs/guides/renderer-kit-type.md index 6e2231863..87a58247c 100644 --- a/docs/guides/renderer-kit-type.md +++ b/docs/guides/renderer-kit-type.md @@ -64,6 +64,7 @@ or flags by environment). The corner names both axes (`os × compiler`), the edges list row and column values once, and each cell shows only what its headings don't already say. `cell(row, column)` returns a cell, or `null` for an empty hatched cell. A cell without `content` shows a small mark, using its full -name (`title`) as a tooltip and for screen readers. Added or removed values and -cells render as change regions. Pass a `caption` to place several grids side by -side, one per extra dimension. +name (`title`) as a tooltip and for screen readers (or `present`, "Present" by +default, when it has no title). Added or removed values and cells render as +change regions. Pass a `caption` to place several grids side by side, one per +extra dimension. diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 2fade0e17..53f892d86 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -4578,18 +4578,18 @@ What one cell holds: whether something is there, its change, and anything its he | Member | Signature | Description | |---|---|---| | `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | | -| `content` | `"content"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What tells the cell apart beyond its headings; a `MatrixMark` is drawn when there is nothing. | +| `content` | `"content"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What tells the cell apart beyond its headings; a mark is drawn when there is nothing to show. | | `title` | `"title"?: string` | The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). | ### `MatrixGrid` ```ts -MatrixGrid(__0: { "caption"?: Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "cell": { (row: string, column: string | undefined): MatrixCell | null }; "columns"?: MatrixAxis; "emphasis"?: number; "label": string; "rows": MatrixAxis; "vacant"?: string }): Element +MatrixGrid(__0: { "caption"?: Iterable | Promise | ReactElement | Promise | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined> | ReactElement | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined> | Promise | ReactElement | ReactPortal | bigint | false | null | number | string | true | undefined } | { new (props: any, context: any): Component }> | ReactPortal | bigint | false | null | number | string | true | undefined; "cell": { (row: string, column: string | undefined): MatrixCell | null }; "columns"?: MatrixAxis; "emphasis"?: number; "label": string; "present"?: string; "rows": MatrixAxis; "vacant"?: string }): Element ``` A grid over two axes, as a table: the axes' names in its corner (`os × compiler`), each axis's values once along its edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole -name as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) +name (or `present`) as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of cells along `rows`. `caption` names the grid when several stand together (one per further dimension). diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx index cf5d884b2..ebbc8dc6e 100644 --- a/packages/renderers/kit/src/react/matrix-grid.tsx +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -25,13 +25,16 @@ export interface MatrixAxis { /** What one cell holds: whether something is there, its change, and anything its headings don't say. */ export interface MatrixCell { - /** What tells the cell apart beyond its headings; a `MatrixMark` is drawn when there is nothing. */ + /** What tells the cell apart beyond its headings; a mark is drawn when there is nothing to show. */ content?: ReactNode change?: ChangeClassification | undefined /** The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). */ title?: string } +/** Whether a cell has content to show: anything but nothing, `false` or an empty string (a `0` shows). */ +const shows = (content: ReactNode) => content !== undefined && content !== null && content !== false && content !== '' + const change = (value: ChangeClassification | undefined) => (value !== undefined && value !== 'unchanged' ? {'data-change': value} : {}) /** A change worth saying: anything but unchanged. */ @@ -53,7 +56,7 @@ function Heading({value, code}: {value: MatrixValue; code: boolean}) { /** * A grid over two axes, as a table: the axes' names in its corner (`os × compiler`), each axis's values once along its * edge, and each cell what `cell(row, column)` returns: by default a small mark that something is there, with its whole - * name as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) + * name (or `present`) as a tooltip and for assistive technology, so a cell never repeats its headings. A cell with nothing (`null`) * is vacant, on the kit's hatch. A value, row, column or cell that arrives or leaves is a kit change region, struck * through when it leaves, fading with `emphasis` (or the item's around it). Leave out `columns` for a single list of * cells along `rows`. `caption` names the grid when several stand together (one per further dimension). @@ -65,6 +68,7 @@ export function MatrixGrid({ cell, caption, vacant = 'None', + present = 'Present', emphasis, }: { /** The grid's accessible name. */ @@ -75,6 +79,8 @@ export function MatrixGrid({ caption?: ReactNode /** What assistive technology hears in a vacant cell. */ vacant?: string + /** What assistive technology hears in a marked cell without a `title`. */ + present?: string emphasis?: number }) { const style = emphasis === undefined ? undefined : ({'--emphasis': emphasis} as Record) @@ -90,18 +96,19 @@ export function MatrixGrid({ ) } const changed = said(found.change) + const content = shows(found.content) return ( - {found.content !== undefined && {found.content}} + {content && {found.content}} {said(found.change) ? `${statusLabels[found.change]}: ` : ''} - {found.title ?? ''} + {found.title ?? (content ? '' : present)} diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index fc848bc03..236753a2c 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -60,8 +60,13 @@ background-position: center; background-repeat: no-repeat; } +/* A changed cell's mark takes the change's hue, fading back to the plain mark as `emphasis` falls to 0. */ .pk .pk-matrix-cell[data-marked][data-change] { - background-image: radial-gradient(circle, var(--pk-change-ink) 2.5px, transparent 3px); + background-image: radial-gradient( + circle, + color-mix(in srgb, var(--pk-change-ink) calc(var(--emphasis, 1) * 100%), var(--subtle)) 2.5px, + transparent 3px + ); } .pk .pk-matrix-cell[data-vacant] { background: var(--pk-vacant); diff --git a/packages/renderers/kit/test/matrix-grid.test.mjs b/packages/renderers/kit/test/matrix-grid.test.mjs index 5c47f3a3a..773cc6d56 100644 --- a/packages/renderers/kit/test/matrix-grid.test.mjs +++ b/packages/renderers/kit/test/matrix-grid.test.mjs @@ -40,3 +40,19 @@ test('a cell with content of its own shows it, and the grid takes its own emphas assert.match(markup, /^
/u) assert.match(markup, /node 22<\/span>/u) }) + +test('a cell with nothing to show is marked and said present, and a zero is content', () => { + const markup = renderToStaticMarkup( + createElement(MatrixGrid, { + label: 'flags', + rows: {name: 'flag', values: [{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}]}, + cell: row => ({a: {content: null}, b: {content: ''}, c: {}, d: {content: 0}})[row], + present: 'On', + }), + ) + assert.equal(markup.match(/On<\/span><\/span>/gu)?.length, 3) + assert.match( + markup, + /0<\/span><\/span><\/span>/u, + ) +}) From 252fd439acfba8ccaa9cac015e17d990345a28ce Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 16:50:05 -0800 Subject: [PATCH 3/9] MatrixGrid: the table carries the grid's name, and its changes fade to plain cells at zero emphasis Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/renderers/kit/src/react/matrix-grid.tsx | 2 +- packages/renderers/kit/styles/matrix.css | 16 ++++++++++++++++ packages/renderers/kit/test/matrix-grid.test.mjs | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx index ebbc8dc6e..6d379b915 100644 --- a/packages/renderers/kit/src/react/matrix-grid.tsx +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -117,7 +117,7 @@ export function MatrixGrid({ return (
{caption !== undefined && caption !== null &&
{caption}
} - +
diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index 236753a2c..8ef7d40cd 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -77,3 +77,19 @@ outline: var(--stroke) dashed color-mix(in srgb, var(--pk-region-edge) calc(var(--emphasis, 1) * 100%), transparent); outline-offset: calc(-1 * var(--stroke)); } +/* + * A changed cell fades with `emphasis` to an unchanged one: its fill and edge return to the plain cell's, and a removed + * cell's solid edge returns as its dashed one fades. A removed heading's or cell's strike and muting fade with it, as + * a removed chip's do, so at an endpoint the grid reads plain. + */ +.pk .pk-matrix-cell.pk-region[data-change] { + background-color: color-mix(in srgb, var(--pk-region-fill) var(--pk-region-amount), var(--raised)); + box-shadow: inset 0 0 0 var(--stroke) color-mix(in srgb, var(--pk-region-edge) var(--pk-region-amount), var(--border)); +} +.pk .pk-matrix .pk-matrix-cell.pk-region[data-change='removed'] { + box-shadow: inset 0 0 0 var(--stroke) color-mix(in srgb, var(--border) calc((1 - var(--emphasis, 1)) * 100%), transparent); +} +.pk .pk-matrix [data-change='removed'] .pk-diff-text { + color: color-mix(in srgb, var(--muted) calc(var(--emphasis, 1) * 100%), var(--text)); + text-decoration: line-through color-mix(in srgb, currentColor calc(var(--emphasis, 1) * 100%), transparent); +} diff --git a/packages/renderers/kit/test/matrix-grid.test.mjs b/packages/renderers/kit/test/matrix-grid.test.mjs index 773cc6d56..c9762d49e 100644 --- a/packages/renderers/kit/test/matrix-grid.test.mjs +++ b/packages/renderers/kit/test/matrix-grid.test.mjs @@ -20,6 +20,8 @@ const grid = props => test('a matrix names its axes once and marks each cell without repeating its headings', () => { const markup = grid() assert.match(markup, /os × compiler<\/th>/u) + // The table carries the grid's name too, for moving between tables. + assert.match(markup, //u) assert.match( markup, /windows · Transparent<\/span><\/span>/u, From 34c560b8e4b735cde828f3d32250141ea3b6a3f5 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 16:51:49 -0800 Subject: [PATCH 4/9] MatrixGrid: document an axis's values and a cell's change Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- docs/reference/renderer-kit.md | 4 ++-- packages/renderers/kit/src/react/matrix-grid.tsx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/reference/renderer-kit.md b/docs/reference/renderer-kit.md index 53f892d86..7561f6aee 100644 --- a/docs/reference/renderer-kit.md +++ b/docs/reference/renderer-kit.md @@ -4565,7 +4565,7 @@ One axis of a `MatrixGrid`: its name, in words, and its values. |---|---|---| | `code` | `"code"?: false \| true` | Sets its values as code (identifiers, versions), in the monospace font. | | `name` | `"name": Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What the axis is ("os", "compiler"), in the label role. | -| `values` | `"values": Array` | | +| `values` | `"values": Array` | The axis's values, in the order their headings run. | ### `MatrixCell` @@ -4577,7 +4577,7 @@ What one cell holds: whether something is there, its change, and anything its he | Member | Signature | Description | |---|---|---| -| `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | | +| `change` | `"change"?: "added" \| "modified" \| "removed" \| "renamed" \| "unchanged" \| undefined` | The cell's own change: it arrives or leaves while its row and column stay. | | `content` | `"content"?: Iterable \| Promise \| ReactElement \| Promise \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| ReactElement \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined> \| Promise \| ReactElement \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined } \| { new (props: any, context: any): Component }> \| ReactPortal \| bigint \| false \| null \| number \| string \| true \| undefined` | What tells the cell apart beyond its headings; a mark is drawn when there is nothing to show. | | `title` | `"title"?: string` | The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). | diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx index 6d379b915..a0be1e20e 100644 --- a/packages/renderers/kit/src/react/matrix-grid.tsx +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -18,6 +18,7 @@ export interface MatrixValue { export interface MatrixAxis { /** What the axis is ("os", "compiler"), in the label role. */ name: ReactNode + /** The axis's values, in the order their headings run. */ values: readonly MatrixValue[] /** Sets its values as code (identifiers, versions), in the monospace font. */ code?: boolean @@ -27,6 +28,7 @@ export interface MatrixAxis { export interface MatrixCell { /** What tells the cell apart beyond its headings; a mark is drawn when there is nothing to show. */ content?: ReactNode + /** The cell's own change: it arrives or leaves while its row and column stay. */ change?: ChangeClassification | undefined /** The cell's whole name, for a pointer and assistive technology (its headings needn't repeat it on screen). */ title?: string From 8534846f4d7f52fa80b30ae1eb1a2aacee4921a7 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 17:28:05 -0800 Subject: [PATCH 5/9] MatrixGrid: true content is a mark too, and presence survives forced colors Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../renderers/kit/src/react/matrix-grid.tsx | 4 ++-- packages/renderers/kit/styles/matrix.css | 18 ++++++++++++++++++ .../renderers/kit/test/matrix-grid.test.mjs | 6 +++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx index a0be1e20e..59066842f 100644 --- a/packages/renderers/kit/src/react/matrix-grid.tsx +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -34,8 +34,8 @@ export interface MatrixCell { title?: string } -/** Whether a cell has content to show: anything but nothing, `false` or an empty string (a `0` shows). */ -const shows = (content: ReactNode) => content !== undefined && content !== null && content !== false && content !== '' +/** Whether a cell has content to show: anything React draws, so not nothing, a boolean or an empty string (a `0` shows). */ +const shows = (content: ReactNode) => content !== undefined && content !== null && typeof content !== 'boolean' && content !== '' const change = (value: ChangeClassification | undefined) => (value !== undefined && value !== 'unchanged' ? {'data-change': value} : {}) diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index 8ef7d40cd..72ee91130 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -93,3 +93,21 @@ color: color-mix(in srgb, var(--muted) calc(var(--emphasis, 1) * 100%), var(--text)); text-decoration: line-through color-mix(in srgb, currentColor calc(var(--emphasis, 1) * 100%), transparent); } +/* + * Forced colors drop fills, shadows and gradients, the mark and the hatch among them: an occupied cell keeps an edge in + * the system's text color and its mark as a dot of text (silent to assistive technology, which hears the cell's name), + * and a vacant cell has neither. + */ +@media (forced-colors: active) { + .pk .pk-matrix-cell:not([data-vacant]) { + outline: var(--stroke) solid CanvasText; + outline-offset: calc(-1 * var(--stroke)); + } + .pk .pk-matrix-cell[data-marked]::before { + content: '●'; + content: '●' / ''; + color: CanvasText; + font-size: 0.5em; + line-height: 1; + } +} diff --git a/packages/renderers/kit/test/matrix-grid.test.mjs b/packages/renderers/kit/test/matrix-grid.test.mjs index c9762d49e..bb284aa1d 100644 --- a/packages/renderers/kit/test/matrix-grid.test.mjs +++ b/packages/renderers/kit/test/matrix-grid.test.mjs @@ -47,12 +47,12 @@ test('a cell with nothing to show is marked and said present, and a zero is cont const markup = renderToStaticMarkup( createElement(MatrixGrid, { label: 'flags', - rows: {name: 'flag', values: [{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}]}, - cell: row => ({a: {content: null}, b: {content: ''}, c: {}, d: {content: 0}})[row], + rows: {name: 'flag', values: [{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}, {key: 'e'}]}, + cell: row => ({a: {content: null}, b: {content: ''}, c: {}, d: {content: 0}, e: {content: true}})[row], present: 'On', }), ) - assert.equal(markup.match(/On<\/span><\/span>/gu)?.length, 3) + assert.equal(markup.match(/On<\/span><\/span>/gu)?.length, 4) assert.match( markup, /0<\/span><\/span><\/span>/u, From 4e98000391a4c34f2c54b63d4e901b932bffaab3 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 18:02:30 -0800 Subject: [PATCH 6/9] MatrixGrid: in forced colors a changed cell's edge is thicker, in the highlight color Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/renderers/kit/styles/matrix.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index 72ee91130..d85bd8511 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -95,14 +95,19 @@ } /* * Forced colors drop fills, shadows and gradients, the mark and the hatch among them: an occupied cell keeps an edge in - * the system's text color and its mark as a dot of text (silent to assistive technology, which hears the cell's name), - * and a vacant cell has neither. + * the system's text color and its mark as a dot of text (silent to assistive technology, which hears the cell's name + * and change), and a vacant cell has neither. A changed cell's edge is thicker, in the highlight color. */ @media (forced-colors: active) { .pk .pk-matrix-cell:not([data-vacant]) { outline: var(--stroke) solid CanvasText; outline-offset: calc(-1 * var(--stroke)); } + /* A cell that arrives or changes draws its edge twice as thick in the highlight color; a removed one stays dashed. */ + .pk .pk-matrix .pk-matrix-cell[data-change]:not([data-change='removed']) { + outline: var(--stroke-strong) solid Highlight; + outline-offset: calc(-1 * var(--stroke-strong)); + } .pk .pk-matrix-cell[data-marked]::before { content: '●'; content: '●' / ''; From 5e754210cd982543b034eaa0b2b38a37036d7255 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 19:09:01 -0800 Subject: [PATCH 7/9] MatrixGrid: in forced colors a changed cell's thicker edge thins with emphasis Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/renderers/kit/styles/matrix.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index d85bd8511..2f284ac05 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -96,17 +96,21 @@ /* * Forced colors drop fills, shadows and gradients, the mark and the hatch among them: an occupied cell keeps an edge in * the system's text color and its mark as a dot of text (silent to assistive technology, which hears the cell's name - * and change), and a vacant cell has neither. A changed cell's edge is thicker, in the highlight color. + * and change), and a vacant cell has neither. A changed cell's edge is thicker. */ @media (forced-colors: active) { .pk .pk-matrix-cell:not([data-vacant]) { outline: var(--stroke) solid CanvasText; outline-offset: calc(-1 * var(--stroke)); } - /* A cell that arrives or changes draws its edge twice as thick in the highlight color; a removed one stays dashed. */ + /* + * A cell that arrives or changes draws a thicker edge, thinning to the plain one as `emphasis` falls to 0 (forced + * colors can't mix colors, so the thickness carries it). A removed one stays dashed. + */ .pk .pk-matrix .pk-matrix-cell[data-change]:not([data-change='removed']) { - outline: var(--stroke-strong) solid Highlight; - outline-offset: calc(-1 * var(--stroke-strong)); + --pk-matrix-edge: calc(var(--stroke) + 2 * (var(--stroke-strong) - var(--stroke)) * var(--emphasis, 1)); + outline: var(--pk-matrix-edge) solid CanvasText; + outline-offset: calc(-1 * var(--pk-matrix-edge)); } .pk .pk-matrix-cell[data-marked]::before { content: '●'; From 14a79b60923bc3706f6c57d21f96f7ad8d350c51 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 19:41:42 -0800 Subject: [PATCH 8/9] MatrixGrid: in forced colors a changed heading is outlined too, fading with emphasis Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/renderers/kit/styles/matrix.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/renderers/kit/styles/matrix.css b/packages/renderers/kit/styles/matrix.css index 2f284ac05..4a0a6d1ae 100644 --- a/packages/renderers/kit/styles/matrix.css +++ b/packages/renderers/kit/styles/matrix.css @@ -112,6 +112,11 @@ outline: var(--pk-matrix-edge) solid CanvasText; outline-offset: calc(-1 * var(--pk-matrix-edge)); } + /* A heading that arrives or changes is outlined the same way, around it rather than over its text, and not at all at 0. */ + .pk .pk-matrix .pk-matrix-value[data-change]:not([data-change='removed']) { + outline: calc((var(--stroke) + 2 * (var(--stroke-strong) - var(--stroke))) * var(--emphasis, 1)) solid CanvasText; + outline-offset: 0; + } .pk .pk-matrix-cell[data-marked]::before { content: '●'; content: '●' / ''; From d4b427987570266b7baa1a64bac121e48dd7b072 Mon Sep 17 00:00:00 2001 From: Alex Gorischek Date: Wed, 2 Dec 2026 20:19:42 -0800 Subject: [PATCH 9/9] MatrixGrid: a list of nothing to show is a mark too Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- packages/renderers/kit/src/react/matrix-grid.tsx | 8 ++++++-- packages/renderers/kit/test/matrix-grid.test.mjs | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/renderers/kit/src/react/matrix-grid.tsx b/packages/renderers/kit/src/react/matrix-grid.tsx index 59066842f..98e6b4494 100644 --- a/packages/renderers/kit/src/react/matrix-grid.tsx +++ b/packages/renderers/kit/src/react/matrix-grid.tsx @@ -34,8 +34,12 @@ export interface MatrixCell { title?: string } -/** Whether a cell has content to show: anything React draws, so not nothing, a boolean or an empty string (a `0` shows). */ -const shows = (content: ReactNode) => content !== undefined && content !== null && typeof content !== 'boolean' && content !== '' +/** + * Whether a cell has content to show: anything React draws, so not nothing, a boolean, an empty string or a list of + * those (an empty `.map()`). A `0` shows. + */ +const shows = (content: unknown): boolean => + Array.isArray(content) ? content.some(shows) : content !== undefined && content !== null && typeof content !== 'boolean' && content !== '' const change = (value: ChangeClassification | undefined) => (value !== undefined && value !== 'unchanged' ? {'data-change': value} : {}) diff --git a/packages/renderers/kit/test/matrix-grid.test.mjs b/packages/renderers/kit/test/matrix-grid.test.mjs index bb284aa1d..005f5d728 100644 --- a/packages/renderers/kit/test/matrix-grid.test.mjs +++ b/packages/renderers/kit/test/matrix-grid.test.mjs @@ -47,12 +47,15 @@ test('a cell with nothing to show is marked and said present, and a zero is cont const markup = renderToStaticMarkup( createElement(MatrixGrid, { label: 'flags', - rows: {name: 'flag', values: [{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}, {key: 'e'}]}, - cell: row => ({a: {content: null}, b: {content: ''}, c: {}, d: {content: 0}, e: {content: true}})[row], + rows: {name: 'flag', values: ['a', 'b', 'c', 'd', 'e', 'f', 'g'].map(key => ({key}))}, + cell: row => + ({a: {content: null}, b: {content: ''}, c: {}, d: {content: 0}, e: {content: true}, f: {content: []}, g: {content: [null, false]}})[ + row + ], present: 'On', }), ) - assert.equal(markup.match(/On<\/span><\/span>/gu)?.length, 4) + assert.equal(markup.match(/On<\/span><\/span>/gu)?.length, 6) assert.match( markup, /0<\/span><\/span><\/span>/u,