Repository navigation
Kit: add useCategories and countFact - #225
Open
agorischek wants to merge 1 commit into
Open
agorischek wants to merge 1 commit into
agorischek wants to merge 1 commit into
Conversation
categoriesOf and useCategories color comparison rows' categories from the categorical palette, ranked over both revisions, and return each category's color, the host legend and (in React) a swatch marked as a categorical color. countFact counts distinct keys on After for the summary bar, with the keys the comparison added and removed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Colliding presentation row IDs can produce invalid filter IDs in count-fact.ts, causing summary validation failures and host filters that match nothing.
1 open issue
What changed in this PR
Adds opt-in renderer-kit helpers for stable category colors and summary counts, without changing built-in renderers.
Changes:
- Adds
categoriesOf,useCategories, andSwatchfor categories ranked across both revisions. - Adds
countFactfor distinct After counts, added/removed keys, and filter IDs. - Documents the APIs and adds focused tests and swatch styling.
| File | Description |
|---|---|
| packages/renderers/kit/test/categories.test.mjs | Tests category ranking, swatches, and count facts. |
| packages/renderers/kit/styles/layout.css | Adds small and medium swatch styles. |
| packages/renderers/kit/src/react/categories.tsx | Adds the category hook and swatch component. |
| packages/renderers/kit/src/react.ts | Exports the React category helpers. |
| packages/renderers/kit/src/index.ts | Exports category and count-fact APIs. |
| packages/renderers/kit/src/count-fact.ts | Builds distinct-count summary facts. |
| packages/renderers/kit/src/categories.ts | Builds category palettes and legends across revisions. |
| docs/reference/renderer-kit.md | Adds API reference entries. |
| docs/guides/renderer-kit.md | Links palette guidance to the category helper. |
| docs/guides/renderer-kit-components.md | Documents categories and count-fact usage. |
Review effort: Balanced
| if (was !== undefined) before.add(was) | ||
| if (now !== undefined) { | ||
| after.add(now) | ||
| ids.push(row.id) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
240dcf6a4c55c97d025a28aaade63fcd3391bf29↑ Kit tests cover ranking over both revisions, weights, language colors, the swatch markup and countFact's count, added, removed, ids, tone and single-extraction cases.
↓ No built-in uses them yet, so there's no browser coverage.
Superego feedback items 17 and 18.
useCategories(rows, key, {title, colorMode, …})(and the framework-freecategoriesOf) colors comparison rows' categories from the kit's categorical palette, ranked over both revisions. A category keeps its color and its legend place from Before to After and at every progress.key(item)returns a key, aCategory(languageCategory(name)keeps a language's own color) orundefined.weight(item).distinctandpinnedpass through tocategoryPalette.color(key), the hostlegend(foruseLegend), thepalette, and in Reactswatch(key): aSwatchdot markeddata-projections-category, as the checks expect of categorical colors.countFact(rows, {id, noun, key?, description?, icon?, tone?})is a summary-bar fact.addedandremovedare the keys only After or only Before has.idsare the rows counted on After, so the figure filters.toneapplies only while the count is above zero.Documented in the components guide (a new Categories section, plus the summary-bar facts bullet) and the renderer-kit guide.
Not adopted in the built-ins: