Skip to content

feat(react): zone colours and a readable table header - #962

Merged
eizedev merged 19 commits into
mainfrom
feat/readable-table-header
Nov 26, 2026
Merged

eizedev merged 19 commits into
mainfrom
feat/readable-table-header

Conversation

@eizedev

@eizedev eizedev commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

Refs #920. This builds the decision in the issue's comment: the zone colours and a readable table header. I keep #920 open for its PowerShell Universal part (the module's theme tokens), which follows in that repository.

  • Field area and field list: chips get an opaque fill in their zone colour (rows, columns, values) without a coloured border; filter chips stay neutral. Zone titles and the field list's zone badges use the same colours. Data-type icons are neutral grey by default.
  • Table header: the layout is as before. Each field name in the header gets its zone icon and fill; repeated value names get the icon only. The sort arrow sits behind the name, only on the sorted field, in the text colour; other header cells show it on hover and focus. A custom order shows no arrow, on the header or the chip.
  • Tokens (all overridable, no !important):
    • zone colours: --pk-zone-rows, --pk-zone-columns, --pk-zone-values, --pk-zone-filters;
    • fill: --pk-zone-tint (16 %) and --pk-zone-tint-base;
    • other: --pk-control-icon, --pk-sort-arrow and --pk-field-hover.
    • --pk-type-* now default to the muted colour.
    • --pk-radius is 8 px (was 10).
    • There is a color-mix() fallback and a system border in forced-colors mode.
  • Accessibility:
    • Header cells have scope, and the empty corner has a label.
    • The sorted header carries aria-sort and a description with the order and the next click.
    • Chip controls have 24×24 px targets.
    • Type icon letters are as tall as 11 px text.
    • Contrast is measured in the real component: zone icons are at least 4.6:1 against the header in both themes, including the Grand Total header, and control icons at least 3:1 on every fill.

The light default of --pk-zone-values is #0b785c instead of the #0b7a5c from the decision: the decided value measured 4.52:1 on the Grand Total header, below the 4.6:1 the decision asks for. Export output (CSV, XLSX, report HTML) is unchanged.

Whole-change check

Docs

I read each page whole, rendered.

  • docs/use/fields.md
    • Reader: someone who builds a report and wants to know what the parts of the screen are.
    • They find the zones' colours in the row they already read for the zones, and the header's icons in the table's list.
    • I added no new section. I extended the existing table cell for Fields and The zones, and the list item about the value name.
    • Nothing removed.
  • docs/use/filters.md
    • Reader: someone who sorts by a header.
    • The sort arrow (where it shows, the custom order without one) now sits in the paragraph on header sorting, where they look for it.
    • I re-wrapped that paragraph to the page's line length. Nothing removed.
  • docs/use/keyboard.md
    • Reader: a screen reader user.
    • The bullet on the sorted header now says what they hear: the order, then what the next click does.
    • One bullet changed and re-wrapped. Nothing removed.
  • docs/reference/theming.md
    • Reader: a host that sets the report's colours.
    • The new tokens are rows of the existing token table, next to the ones they relate to, each with its default and the contrast it keeps. A host must check that contrast when they lighten --pk-muted.
    • I changed two rows in place: the radius and the type icons. I added no new section.
    • Nothing removed. The type icons lost their own default colours, and the upgrading page says how to set them again.
  • docs/getting-started/upgrading.md
    • Reader: a host moving from 0.10 to 0.11.
    • One row in the existing table: the radius is 8 px, chips use the small radius, and type icons are neutral by default, with the action to take.
    • Nothing removed.

Code

I read each function and file whole.

  • packages/pivotkit-react/src/header-cells.js (new)
    • Its job: what a header cell names, meaning its zone, its fill and its scope, plus the words of the empty corner for a screen reader.
    • I extracted this from the table's render so it is plain logic with its own unit tests.
  • packages/pivotkit-react/src/table.jsx
    • HeaderContent and BlankCorner are new, each with one job: the content of a header cell, and the empty corner.
    • I moved both out of PivotTable, so the function is 3 lines shorter, and the arrow function the growth guard tracks in this file drops from complexity 32 to 29.
    • The sort button only gained its description. I compute its tooltip text once, as hint, and use it for both.
  • packages/pivotkit-react/src/zones.jsx
    • Badges draws the sorted chip's arrow from the same glyph as the header, and no arrow for a custom order.
    • Chip and DragChip only change a class and the icon size.
    • The rest fits as it is.
  • packages/pivotkit-react/src/fields.jsx
    • FieldItem only changes the icon size and gives the zone mark its fill class. Its job stays the same.
  • packages/pivotkit-react/src/styles.css
    • I define the zone colours once as tokens, and the fill once as the internal --pk-zone-fill. Chips, field marks and header names all reuse that fill.
    • The three header-name rules are now one.
    • I removed the values chip's own frame colour instead of overriding it. A filled chip shows its frame on hover only.
  • scripts/growth-baseline.json
    • I lowered two entries because this change shrank them: PivotTable to 352 lines, and the table's arrow function to complexity 29.
    • No growth guard fails.

Checklist (PRODUCT.md)

  • Linked issue; for a new feature, the answers to the five questions
  • New or changed tests fail without this change; no test weakened
  • Docs and upgrading notes describe the new state; CHANGELOG.md entry (optional)
  • Reviewed before opening by someone who did not write it (strongly recommended, mandatory for the maintainer's own AI agents; for AI-written code a person or a separate AI session), and I read, ran and understand all of it

Test plan

  • The checks of Check your change: those for every change, and those for what this one changes
  • npm run growth passes, or the known baseline entry it fails on is named in the whole-change check
  • What I ran, with numbers where a check gives some, such as benchmark timings:
    • npm run lint, types, test, growth, pack:check: exit 0.
    • npm run test:browser: 2906 passed, 3 failed under load. Each of the three passed 3 of 3 alone. One of them is levels.spec.js:330, which also fails on main (levels.spec Filter level test measures the menu during its opening animation #961).
    • New: tests/browser/table-header.spec.js (contrast in both themes at 1280 and 390 px, en and de; sort state of chip and header; accessible names; reflow) and packages/pivotkit-react/test/header-cells.test.js. contrast.test.js has new pairs for zones, focus ring and the Grand Total header.
    • Changed: sort-column.spec.js. The rule "a faint arrow on every header at rest" became "an arrow only on the sorted header", as the decision asks.
    • Sizes: first load 179.7 KiB gzip (budget 182.5); menus 59.5 (59.6). No budget changed.
    • Checked inside a PowerShell Universal app as well: the module built with these packages, in light and dark and at phone width.

Neutral review

Three rounds by a separate reviewer, before publishing:

  1. Medium: the values icon measured 4.52:1 on the Grand Total header, and the new test allowed 3:1 there. Fixed: a slightly darker default and the test back at 4.6:1. Low findings also fixed: a focus-ring contrast test, the upgrading note, the --pk-muted condition in theming.md, one property for the fill, changelog and wrapping. The type icon size from the decision was added.
  2. The chip showed ↑ for a custom order while the header showed none. Fixed: no arrow on either, with a test for all five sort states.
  3. Low: a code comment about the custom order's direction. Fixed. Nothing medium or worse left.

🤖 Generated with Claude Code

eizedev and others added 19 commits November 25, 2026 23:16
Add zone colour tokens (--pk-zone-rows, --pk-zone-columns, --pk-zone-values,
--pk-zone-filters) with an opaque fill mixed into --pk-zone-tint-base at
--pk-zone-tint (16%). Chips of rows, columns and values take the fill and
lose their coloured border; filter chips stay neutral. Zone titles and the
field list's badges take the zone colour; type icons, chip controls and the
field list's hover take neutral tokens (--pk-control-icon, --pk-field-hover).
A sorted chip draws the same arrow as the table's sorted header
(--pk-sort-arrow). Chips use the small radius; --pk-radius is 8px.
Without color-mix() the fill falls back to --pk-surface-3; in forced
colours a fill becomes a system border.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each field name in the header carries its zone's icon and fill; with two
or more values the repeated value names carry the icon alone. The sort
arrow stands behind the name: at rest only on the sorted header, in the
text colour and bold, on others on hover and focus. The sorted header's
button describes the order ("sorted Largest Count of Ticket first").
Header cells get their scope (a column field's name heads its row of
items, a row field's name its column of labels) and the empty corner a
label naming the fields on each axis. headerRows() and the exports are
unchanged.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The order in use became the sort button's description and replaced the
tooltip's, so a screen reader no longer heard what a click does. The
description now gives both: "sorted Largest Count of Ticket first. Sort
by Count of Ticket: smallest first".

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document the zone tokens, the fill, the neutral type icons and the 8px
radius in the theming reference; describe the header's field names, the
sort arrow behind the name and what a screen reader hears; retake the
documentation's screenshots of the playground. Changelog entries for
pivotkit-react and pivotkit-element (first load 179.7 KiB gzip).

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PivotTable is 352 lines (was 355) and the header cell's arrow function
29 in complexity (was 32), with the header's content and the empty
corner in components of their own.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n only

The fill's padding and the room kept for the arrow widened every column
with a field's name, and the caps' least width grew with them: on a
phone two row fields left no value in view, and five long row fields no
longer fit at 1440 px. The fill now reaches into the cell's padding
(negative margin) and on under the arrow as a shadow, so only the icon
takes room; where a cap leaves too little for the icon and a word, the
icon stands above the name. The test of the faint arrows at rest now
checks the rule of #920: no arrow at rest until a sort is chosen.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The value name's icon and fill take room from the name; its least width
now adds them back (internal --pk-th-extra), so "Population" no longer
breaks inside the word at 360 px. The row labels' caps leave it out.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The light --pk-zone-values was #0b7a5c: its icon measured 4.52:1 on the
Grand Total column's darker header (--pk-total-strong). #0b785c is the
smallest darkening that measures 4.6:1 there (4.64:1). The browser test
asks 4.6:1 on that header again, and the contrast test checks the
values colour on --pk-total-strong and the focus ring on each zone's
fill (3:1), light and dark.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The type icons in the field list and on chips are 16 px (were 14 and
13): the "A" of the text type now stands 8 px, the cap height of 11 px
text is 7.75 px. The icons fit the boxes they had, so chips (33 px) and
the field list's rows (36 px) keep their height, wide and narrow.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The header pill's shadow tail reads --pk-zone-fill instead of mixing the
colour a second time, and the three .pk-th-field rules are one.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reader that skips aria-description still hears the order from the th.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Theming gives the new values hex and says the 3:1 on fills holds for the
default --pk-muted. Upgrading names the radius and type icon defaults.
Re-wraps the new lines in filters and keyboard, and merges the
changelog's duplicate sections.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lues colour

Three shots whose only differences were render noise (a native select's
arrow, the chart tabs) stay as they were.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table's header shows no arrow for a custom order, so the chip draws
none either: one glyph for one state. The chip's name still says
"sorted Custom order", and the header cell keeps aria-sort="other".

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the import decimal mark (#949) and the whole-change check
(#959). No conflicts. The growth baseline is main's, with the two
entries this branch shrank lowered (PivotTable 352 lines, the table's
arrow function 29 complexity).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comments said a custom order has no direction; the menu offers it
both ways. They now say what holds: no arrow, and its name says it.

Refs #920

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eizedev
eizedev merged commit 04f9849 into main Nov 26, 2026
27 checks passed
@eizedev
eizedev deleted the feat/readable-table-header branch November 26, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant