Repository navigation
feat(lab): add Rating, a star rating input and read-only display - #11082
Rajatendu1 wants to merge 17 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
Hi @Rajatendu1! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
ea1f898 to
d97ed22
Compare
There was a problem hiding this comment.
Approval waits on a component record: Rating has no component:Rating spec yet, and the action-groups family covers only its touch slide-and-lift. An engineering owner (you, if you are one) needs to settle the controlled radio-group API (including the clear prop's name beside Core's existing hasClear), the arrow-key model and the read-only display, either by merging a record on main or by approving one in this pull request with /approve-spec <full head SHA>; you do not need to write that record yourself.
These fixes are needed whatever the record decides:
- With
allowClear, ArrowRight or End on a checked last star, or Home on a checked first star, clears the rating, becausehandleKeyDowncallschoosewith the star that is already checked (Rating.tsx:284). - The arrow, Home/End and tab-stop handling and
isRightToLeftcopy what Core'suseListFocus(from@astryxdesign/core/hooks) already does for SegmentedControl's radio group, so please use the shared hook and delete the copy. - The default star names (
${star} of ${max} stars) and the read-only${label}: …name are English literals, but Astryx-owned assistive text must be one catalog message read withuseTranslator, as Lab's Chat and Comments do. - The group's
onPointerLeave={() => setHover(null)}replaces anyonPointerLeavea caller passes, and the hover preview it serves belongs in CSS (StyleX sibling markers under@media (hover: hover)) rather than React state. - Each filled star renders a second clipped SVG over the outline and sizes itself with inline
styleobjects, where one SVG per star with a styled path and StyleX styles would do.
The touch slide-and-lift, the Core re-export and the right-to-left behaviour look right.
[Automated review]
d97ed22 to
08d68b5
Compare
|
Updated this same PR as one commit, 08d68b5, and replied to the five implementation comments. The boundary-clear and caller-handler bugs are reproduced by tests. The correction passes 40 Rating tests and 171 focused tests locally; generated Core/Lab CSS and Chrome interaction checks also pass. The PR body has the exact validation limits. Full CI and Storybook are not claimed as passed. The component:Rating record and engineering-owner decisions remain open. This update does not claim spec approval or settle the clear-prop name. The shared hook's Down=increase / Up=decrease model is now explicit in tests, docs and the PR body. Please advise on the component record and final API/model. Patch prepared and tests executed by Instinct, an AI assistant, at my request. |
There was a problem hiding this comment.
Thanks for the quick turnaround: all five earlier points are fixed at this head (boundary keys, the shared useListFocus, catalog names, the caller's onPointerLeave, one SVG per star).
Approval still waits on a component record, because Rating has no component:Rating spec and the action-groups family covers only its touch slide-and-lift. An engineering owner needs to settle the controlled radio-group API, the allowClear and getStarLabel names (beside Core's hasClear and ProgressBar's formatValueLabel), the keyboard model, the read-only display and its wording, and the colour roles, either in a record merged on main or by approving an in-PR record with a /approve-spec <full head SHA> comment (the author may do this only if they are an engineering owner).
These need fixing once that is settled:
- Hovering the 4 px gap between two stars paints every star empty, because the
stylex.when.ancestor(':hover', ratingGroup)arm inRating.tsxempties them all; empty only the stars after the hovered one withstylex.when.siblingBefore(':hover', ratingStar). data-staris a new data attribute used only internally, whicharchitecture:public-component-apiDEC-2 rules out; close overstarin per-star handlers and let the native button click handle Enter and Space.- The read-only branch drops a caller's
onKeyDownandonFocus(architecture:public-component-apiINV5); forward both to therole="img"element. - Miss: each read-only star wraps its SVG in a
<span>that only carries styles (architecture:component-style-authoringINV5, INV7); render the SVG directly with those styles.
[Automated review]
|
Thanks for confirming the five earlier fixes. I'll reproduce the hover-gap and read-only handler cases and check the remaining implementation and documentation notes before preparing a follow-up. The component record and the engineering-owner decisions are still open; I am not claiming spec approval or settling those choices here. |
08d68b5 to
bcb9c7b
Compare
|
The second-review corrections are now in bcb9c7b, kept in this PR as one commit. I replied to each of the four implementation findings and six nonblocking notes and updated the PR body with the evidence and limits. The focused run passes 177 tests, including 46 Rating cases. Chrome checks against generated Core/Lab CSS cover all four hover gaps, native activation, RTL fractional fill and touch cancellation. Full CI and the other validation limits remain as stated in the PR body. The component:Rating record and engineering-owner API, naming, keyboard, wording and colour-role decisions are still open. This correction does not claim design/spec approval. |
There was a problem hiding this comment.
Thanks: all four earlier blocking points (the gap-hover preview, data-star, the read-only onKeyDown/onFocus, the read-only wrappers) and the six smaller notes are fixed at this head.
Approval still waits on a component record: Rating has no component:Rating spec (the action-groups family covers only its touch slide-and-lift), so an engineering owner needs to provide or identify one, either as a record merged on main or by approving an in-PR record with a /approve-spec <full head SHA> comment (the author may do this only if they are an engineering owner). That record settles the controlled radio-group API, the allowClear and getStarLabel names (beside Core's hasClear and ProgressBar's formatValueLabel), the keyboard model, the read-only display and its wording, and the colour roles.
After that, this needs fixing:
- Miss: when a caller ignores
onChange(as the Sizes and States stories do), an arrow key leaves the tab stop on the focused, unchecked star becauseuseListFocus'shasRovingTabIndexand Rating's owntabIndexboth write it, so drophasRovingTabIndexand add a test that Tab re-entry lands on the checked star.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/Rating · Storybook | 65.1 kB (new) · 949 B CSS (new) | 397 (new) | — · ✓ · ✗ |
Package size: @astryxdesign/cli 5.72 MB packed (−2 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
Rating requires label and value, so the swizzle proof needs a sample.
Rating reflects size to themes through themeProps, so it picks the size style and passes it to StarGlyph. The theming-target guard then finds the painted size axis in the function that reflects it.
|
/approve-spec 157dca5 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this commit yet. The ci:run label is on, but the CI, Lint and CLI Smoke Test runs for this commit are waiting for a maintainer to approve them.
An engineering owner approved Rating's contract for this exact commit, and the two checks that failed on the previous commit now pass here: the theming-target guard (the glyph size now comes from Rating) and the swizzle-proof sample check. Rating's 49 tests, the route-lock check and the official discover-list check also pass.
- Non-blocking: the description says the pull request changes only Lab, its story, the discover list and the route lock, and that later commits change only forced-colours paint, the paused preview and the tab stop. It now also adds the
lab__Ratingswizzle-proof sample and moves the glyph size style intoRating, so one added line would keep it exact.
Claims and files checked
Review mode: full; reason: author-not-engowner
Claims:
- Core's half (the internal touch exports and the two catalog messages) is already on
main, and no Core file changes: verified (nopackages/corepath in the diff; the tests import those exports). - The pull request changes only Lab, its story, the discover list and the route lock: true but narrower than the change, which also adds a changeset and one swizzle-proof test sample (
samples.mjs:410-411). - A controlled whole-star radio group with one tab stop, shared list focus without wrapping, Home/End, Space/Enter and optional clear: verified (
Rating.tsx:268-273,:410; tests). - Horizontal arrows follow text direction, Down advances and Up retreats: verified (right-to-left and arrow-key tests).
- Navigation never clears a selected boundary, while a click, Space or Enter can: verified (boundary and explicit-activation tests).
- Touch chooses only the lifted star, while leaving, cancelling or a second finger chooses nothing. Coarse targets grow toward 44 px, and a mouse stays native: verified (pointer-stream tests).
- The hover preview is scoped CSS, and an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx:150-159,:352-353,:362-367; preview tests). - Read-only is one named image with an inline-start fractional fill, a label callback that receives fractions, and catalog names: verified (tests; Chromium shows the name and the right-to-left fill).
- Lab exports
Rating,RatingPropsandRatingSize. The caller owns the value and the label, the listed props exist, and there is no half-star input: verified (packages/lab/src/index.ts;RatingProps). - Only a focus move from navigation selects. Tab, script and pointer focus do not: verified (focus tests).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (
Rating.tsx:303-306,:341-389; handler tests). - One SVG per star with static sizes, and only a fractional read-only star adds a clipped path, mirrored right-to-left: verified (tests; Chromium sizes 16, 24 and 32 px).
- A hover in a gap keeps the committed rating, with no per-star data attribute and no style-only wrappers: verified (tests; the preview's default arm).
- Rating alone owns the tab stop. The focused star holds it inside the group, Tab leaves in one press, and Shift+Tab re-enters on the checked star: verified (tab-stop test).
- Forced colours paint checked stars Highlight, empty ones CanvasText and a disabled rating GrayText, with a browser spec on a touch page and a mouse page: verified (Chromium probe; spec read, not run).
- 49 Rating tests (39 component, 10 pointer-stream) pass: verified (run on this commit).
- Lab TypeScript, ESLint, package boundaries, changesets, SYNC, use-client and the i18n catalog pass: verified (run on this commit). Babel, the CSS builds and Prettier were not rerun.
- Counts, failures and real-Chrome runs stated for earlier commits: they describe earlier commits and were not rechecked.
- The stills still hold because later commits change only forced-colours paint, the paused preview and the tab stop: the stills hold (the star sizes are unchanged), but later commits also move the size style and add the swizzle sample.
- Full CI, the Storybook browser workflow, visual regression, other browsers and a screen reader are unverified: accurate (CI waits for a maintainer).
- The issue's reply welcomed a Lab Rating and offered help with the component record, which is not supplied here: verified (issue reply; no Rating record on
main). - A maintainer added the doc's anatomy: verified (
Rating.doc.mjsusage.anatomy). - Changeset:
astryx discoverlists the experimental Rating from Lab: verified (Lab entry in the official list, which a canary CLI shows; the generator check passes).
Files:
.changeset/cli-discover-rating.md: clearapps/storybook/stories/Rating.stories.tsx: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/assets/discover/official-packages.json: clearpackages/cli/test/swizzle-proof/samples.mjs: clearpackages/lab/src/Rating/Rating.doc.mjs: clearpackages/lab/src/Rating/Rating.test.tsx: clearpackages/lab/src/Rating/Rating.tsx: clearpackages/lab/src/Rating/RatingTracking.test.tsx: clearpackages/lab/src/Rating/__tests__/RatingForcedColors.interaction.browser.spec.ts: clearpackages/lab/src/Rating/index.ts: clearpackages/lab/src/Rating/rating.stylex.ts: clearpackages/lab/src/index.ts: clear
|
/approve-spec 3cf65bf |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this commit yet. The ci:run label is on, but the CI, Lint and CLI Smoke Test runs for this commit are waiting for a maintainer to approve them.
An engineering owner approved Rating's contract for this exact commit, which only merges main and leaves Rating's own code unchanged. Rating's 49 tests, the route-lock check, the official discover-list check and the new Rating swizzle sample pass here.
- Heads-up: the swizzle-sample guard currently fails on
mainforlab__MediaPlayer(added with the media players, no sample), so CI's node tests may show that failure on this commit too; it does not come from Rating. - Non-blocking: the description says the pull request changes only Lab, its story, the discover list and the route lock, and that later commits change only forced-colours paint, the paused preview and the tab stop; it also adds the
lab__Ratingswizzle-proof sample and moves the glyph size style intoRating, so one added clause would keep it exact. - Non-blocking: an unrated star's outline uses the same border colour as Core's radio and checkbox edges, about 1.5:1 on white in the neutral theme; when the repository's 3:1 control-edge colour lands, Rating's outline should move with them.
Claims and files checked
Review mode: full; reason: author-not-engowner
Claims:
- Rating's Core half (the internal touch exports and the two catalog messages) is already on
main, and no Core file changes: verified (no Core path in the diff; the exports and messages exist onmain). - The pull request changes only Lab, its story, the discover list and the route lock: narrower than the change, which also adds a changeset and a swizzle-proof sample (
samples.mjs:422-423). - A controlled whole-star radio group with one tab stop, shared list focus without wrapping, Home/End, Space/Enter and optional clear: verified (
Rating.tsx:268-273,:410; tests; Chromium). - Horizontal arrows follow text direction; Down advances and Up retreats: verified (right-to-left and arrow-key tests).
- Navigation never clears a selected boundary, while a click, Space or Enter can: verified (boundary and explicit-activation tests).
- Touch chooses only the lifted star; leaving, cancelling or a second finger chooses nothing; coarse targets grow toward 44 px; a mouse stays native: verified (pointer-stream tests; a Chromium finger slide from 1 to 4 chooses 4).
- The hover preview is scoped CSS, and an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx:150-159,:352-353,:363-366; preview tests). - Read-only is one named image with an inline-start fractional fill, a label callback that receives fractions and catalog names: verified (tests; Chromium name and left-to-right and right-to-left clips).
- Lab exports
Rating,RatingPropsandRatingSize; the caller owns the value and the label; the listed props exist; there is no half-star input: verified (packages/lab/src/index.ts;RatingProps). - Only a focus move from navigation selects; Tab, script and pointer focus do not: verified (focus tests).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (
Rating.tsx:303-306,:341-389; pointer-leave, key and focus tests). - One SVG per star with static sizes; only a fractional read-only star adds a clipped path, mirrored right-to-left: verified (tests; Chromium sizes 16, 24 and 32 px).
- A hover in a gap keeps the committed rating; no per-star data attribute; no style-only wrappers: verified (Chromium gap probe; tests).
- Rating owns the tab stop: the focused star holds it inside the group, one Tab leaves and Shift+Tab re-enters on the checked star: verified (tab-stop test).
- Forced colours paint checked stars Highlight, empty ones CanvasText and a disabled rating GrayText, with a browser spec on a touch page and a mouse page: verified (Chromium probe; spec read, not run).
- 49 Rating tests (39 component, 10 pointer-stream) pass: verified (run on this commit).
- Lab TypeScript, ESLint, package boundaries, changesets, SYNC, use-client and the catalog check pass: verified; Prettier flags only the generated route lock, as on
main, and Lab's doc typecheck needs a Lab build (its errors are in other components' blocks). - Counts, failures and real-Chrome runs stated for earlier commits: they describe earlier commits and were not rechecked.
- The stills still hold because later commits change only forced-colours paint, the paused preview and the tab stop: the stills hold (star sizes unchanged), but later commits also move the glyph size style and add the swizzle sample.
- Full CI, the Storybook browser workflow, visual regression, other browsers and a screen reader are unverified: accurate (CI waits for a maintainer).
- The issue reply welcomed a Lab Rating and offered help with the component record, which is not supplied here: verified (issue reply; no Rating record on
main). - A maintainer added the doc's anatomy: present (
Rating.doc.mjsusage.anatomy). - Changeset:
astryx discoverlists the experimental Rating from Lab: verified (Lab entry in the official list; the generator check passes).
Files:
.changeset/cli-discover-rating.md: clearapps/storybook/stories/Rating.stories.tsx: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/assets/discover/official-packages.json: clearpackages/cli/test/swizzle-proof/samples.mjs: clearpackages/lab/src/Rating/Rating.doc.mjs: clearpackages/lab/src/Rating/Rating.test.tsx: clearpackages/lab/src/Rating/Rating.tsx: clearpackages/lab/src/Rating/RatingTracking.test.tsx: clearpackages/lab/src/Rating/__tests__/RatingForcedColors.interaction.browser.spec.ts: clearpackages/lab/src/Rating/index.ts: clearpackages/lab/src/Rating/rating.stylex.ts: clearpackages/lab/src/index.ts: clear
|
/approve-spec 391f94e |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this commit yet. The ci:run label is on, but the CI, Lint and CLI Smoke Test runs for this commit are waiting for a maintainer to approve them.
An engineering owner approved Rating's contract for this exact commit, which only merges main and leaves Rating's own code unchanged. Rating's 49 tests, all five swizzle-sample tests, the route-lock check, the official discover-list check and Lab's typecheck pass here.
- Non-blocking: the description says the pull request changes only Lab, its story, the discover list and the route lock, that later commits change only forced-colours paint, the paused preview and the tab stop, and that the land path is Lab-only; it also adds a CLI changeset and the
lab__Ratingswizzle-proof sample and moves the glyph size style intoRating, so one added clause each would keep it exact. - Non-blocking: an unrated star's outline uses the same border colour as Core's radio and checkbox edges, about 1.5:1 on white in the neutral theme; when the repository's 3:1 control-edge colour lands, Rating's outline should move with them.
Claims and files checked
Review mode: full; reason: author-not-engowner
Claims:
- Rating's Core half (the internal touch exports and the two catalog messages) is already on
main, and no Core file changes: verified (no Core path in the diff;internal/touch.ts:133-136and the two catalog messages exist). - The pull request changes only Lab, its story, the discover list and the route lock: narrower than the change, which also adds a changeset and a swizzle-proof sample (
samples.mjs:422-423). - A controlled whole-star radio group with one tab stop, shared list focus without wrapping, Home/End, Space/Enter and optional clear: verified (
Rating.tsx:268-273,:410; tests; Chromium). - Horizontal arrows follow text direction; Down advances and Up retreats: verified (right-to-left and arrow-key tests).
- Navigation never clears a selected boundary, while a click, Space or Enter can: verified (boundary and explicit-activation tests).
- Touch chooses only the lifted star; leaving, cancelling or a second finger chooses nothing; coarse targets grow toward 44 px; a mouse stays native: verified (10 pointer-stream tests; a Chromium finger slide from 1 to 4 chooses 4).
- The hover preview is scoped CSS, and an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx:104-117,:150-159,:353,:365; preview tests). - Read-only is one named image with an inline-start fractional fill, a label callback that receives fractions and catalog names: verified (tests; Chromium name and left-to-right and right-to-left clips).
- The issue reply welcomed a Lab Rating and offered help with the component record, which is not supplied here: verified (issue reply; no Rating record on
main). - Lab exports
Rating,RatingPropsandRatingSize; the caller owns the value and the label; the listed props exist; there is no half-star input: verified (packages/lab/src/index.ts:125-126;RatingProps). - Only a focus move from navigation selects; Tab, script and pointer focus do not: verified (focus tests).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (
Rating.tsx:303-306,:341-389; pointer-leave, key and focus tests). - One SVG per star with static sizes; only a fractional read-only star adds a clipped path, mirrored right-to-left: verified (tests; Chromium sizes 16, 24 and 32 px).
- A hover in a gap keeps the committed rating; no per-star data attribute; no style-only wrappers: verified (sibling hover rules at
Rating.tsx:104-117leave the committed paint when no star is hovered; tests). - Rating owns the tab stop: the focused star holds it inside the group, one Tab leaves and Shift+Tab re-enters on the checked star: verified (tab-stop test).
- Forced colours paint checked stars Highlight, empty ones CanvasText and a disabled rating GrayText, with a browser spec on a touch page and a mouse page: verified (Chromium probe against the page's system colours; spec read, not run).
- 49 Rating tests (39 component, 10 pointer-stream) pass: verified (run on this commit).
- Lab TypeScript, ESLint, package boundaries, changesets, SYNC, use-client and the catalog check pass: verified; Prettier and Lab's doc typecheck were not rerun.
- Counts, failures and real-Chrome runs stated for earlier commits: they describe earlier commits and were not rechecked.
- The stills still hold because later commits change only forced-colours paint, the paused preview and the tab stop: the stills hold (star sizes unchanged), but later commits also move the glyph size style and add the swizzle sample.
- Full CI, the Storybook browser workflow, visual regression, other browsers and a screen reader are unverified: accurate (CI waits for a maintainer).
- A maintainer added the doc's anatomy: present (
Rating.doc.mjsusage.anatomy). - The land path is Lab-only: inaccurate, since the pull request also changes CLI and Storybook files; non-blocking.
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified (Lab entry in the official list; the generator check passes).
Files:
.changeset/cli-discover-rating.md: clearapps/storybook/stories/Rating.stories.tsx: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/assets/discover/official-packages.json: clearpackages/cli/test/swizzle-proof/samples.mjs: clearpackages/lab/src/Rating/Rating.doc.mjs: clearpackages/lab/src/Rating/Rating.test.tsx: clearpackages/lab/src/Rating/Rating.tsx: clearpackages/lab/src/Rating/RatingTracking.test.tsx: clearpackages/lab/src/Rating/__tests__/RatingForcedColors.interaction.browser.spec.ts: clearpackages/lab/src/Rating/index.ts: clearpackages/lab/src/Rating/rating.stylex.ts: clearpackages/lab/src/index.ts: clear
Approval withdrawn pending description corrections; will re-approve after re-review.
There was a problem hiding this comment.
Changes requested: two statements in the description are wrong at this commit; Rating's code needs no change.
An engineering owner approved Rating's contract for this exact commit, and CI, Lint and the CLI smoke test pass here with no failing check.
- Miss: the Component record section says the separate draft record states the contract this branch implements, but that record (#12815) still says forced colours paint filled stars Highlight and empty stars CanvasText in every state, keeps the tab stop on the checked or first star, and ends the hover preview only when the pointer leaves, while this branch paints every star of a disabled rating GrayText, gives the tab stop to the focused star while focus is inside the group, and also ends the preview on a choice key, so say the record still needs those three updates or update it first.
- The Validation limits section says full CI is unverified and the repository workflows still need maintainer approval, but CI, Lint and CLI Smoke Test have run and passed at this commit, so keep only what is still unverified: a real screen reader, the Lab readiness audit, and visual regression, which has no stable Lab stories.
Non-blocking: adopting the 3:1 control edge once #11658 lands is a new commit that gets its own review, and the draft record's outline colour needs the same change.
Claims and files checked
Review mode: same-head; reason: none
Claims:
- Rating's Core half (the internal touch exports and two catalog messages) is already on
main, and no Core file changes: verified (no Core path in the diff; Core's internal touch entry lines 133-136;locales/en.json:2730,:2734). - The pull request changes Lab, its story, the discover list and its changeset, the route-lock entry and a swizzle-proof sample: verified (the 13 changed files).
- A controlled whole-star radio group with one tab stop, shared list focus without wrapping, Home/End, Space/Enter and optional clear: verified (
Rating.tsx:268-273,:410; tests). - Horizontal arrows follow text direction; Down advances and Up retreats: verified (right-to-left and arrow-key tests; the shared list focus hook).
- Navigation never clears a selected boundary, while a click, Space or Enter can: verified (boundary and explicit-activation tests).
- Touch chooses only the lifted star; leaving, cancelling or a second finger chooses nothing; coarse targets grow toward 44 px; a mouse stays native: verified (10 pointer-stream tests).
- The hover preview is scoped CSS, and an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx:100-117,:150-159,:352-354; preview tests). - Read-only is one named image with an inline-start fractional fill, a label callback that receives fractions, and catalog names: verified (tests;
Rating.tsx:140-145). - The issue reply welcomed a Lab Rating and offered help with the component record: verified (issue reply).
- Lab exports
Rating,RatingPropsandRatingSize; the caller owns the value and label; the listed props exist; no half-star input: verified (packages/lab/src/index.ts:125-126;RatingProps; whole-star rounding inclampRating). - Rating picks the glyph's size style itself and reflects
sizeto themes: verified (Rating.tsx:322,:428; the theme props call). - Only a navigation focus move selects; Tab, script and pointer focus do not: verified (focus tests).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (
Rating.tsx:303-306,:341-389; tests). - One SVG per star with static sizes; only a fractional read-only star adds a clipped path, mirrored right-to-left: verified (tests;
Rating.tsx:140-145). - A hover in a gap keeps the committed rating; no per-star data attribute; no style-only wrappers: verified (sibling hover rules; tests).
- Rating owns the tab stop; the focused star holds it inside the group; one Tab leaves and Shift+Tab returns to the checked star: verified (
Rating.tsx:368-374,:410;Rating.test.tsx:47-73). - Forced colours paint checked stars Highlight, empty ones CanvasText and a disabled rating GrayText, with a browser spec on a touch page and a mouse page: verified (
Rating.tsx:67-71,:87-98,:130-139; spec lines 66-71). - 49 Rating tests (39 component, 10 pointer-stream) pass: verified (count; CI's UI test legs pass at this commit).
- Lint, typecheck, package boundaries, changesets, SYNC, use-client and the catalog check pass: verified (CI's lint and typecheck pass at this commit).
- Failures and real-Chrome runs stated for earlier commits: they describe earlier commits and were not rechecked.
- The stills still hold because later commits change only forced-colours paint, the paused preview and the tab stop: verified in substance (the size-style change renders the same 16, 24 and 32 px stars; the other later commits are tests).
- The per-state stills index: hosted outside this repository and not read.
- Full CI is unverified and the repository workflows still need maintainer approval: false (CI, Lint and CLI Smoke Test pass at this commit, no failing check).
- The unrated outline uses the colour Core's checkbox and radio edges use, about 1.5:1 on white, below 3:1: verified (
Rating.tsx:88-90; Core's checkbox and radio indicators). - The pull request waits for the 3:1 control edge (#11658) and adopts it in a later push: a plan; #11658 is an open draft and this commit keeps the current outline.
- The separate draft record states the contract this branch implements: false (its forced-colours, tab-stop and preview rules differ).
- A maintainer added the doc's anatomy: verified (a maintainer's commit;
Rating.doc.mjsusage.anatomy). - The land path is mixed and needs no Lab API owner decision: consistent with the repository's checklist, which asks none for unpublished Lab API; an engineering owner approved the contract anyway.
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified (the official list's Lab entry; the generator check passes).
Files:
.changeset/cli-discover-rating.md: clearapps/storybook/stories/Rating.stories.tsx: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/assets/discover/official-packages.json: clearpackages/cli/test/swizzle-proof/samples.mjs: clearpackages/lab/src/Rating/Rating.doc.mjs: clearpackages/lab/src/Rating/Rating.test.tsx: clearpackages/lab/src/Rating/Rating.tsx: clearpackages/lab/src/Rating/RatingTracking.test.tsx: clearpackages/lab/src/Rating/__tests__/RatingForcedColors.interaction.browser.spec.ts: clearpackages/lab/src/Rating/index.ts: clearpackages/lab/src/Rating/rating.stylex.ts: clearpackages/lab/src/index.ts: clear
User need
Product pages that ask people to rate something, such as a recipe, a support answer or a product, need a star input, and pages that show a product's average need a star display. Today each team builds its own, and those often miss radio semantics, a single tab stop, keyboard control, touch slide-and-lift, or a text name that screen readers can read. A reusable rating input saves callers from rebuilding radio semantics, focus, keyboard controls and pointer interaction. A read-only mode displays a fractional average. This is an experimental Lab proposal, not a core API.
Problem and solution fit
useListFocusnavigation without wrapping, Home/End, Space/Enter and optional clear. Horizontal arrows follow text direction; Down advances and Up retreats, following the shared list model. Navigation never clears an already-selected boundary; explicit click, Space or Enter can clear it.useTranslatorwith ICU catalog messages.Current specification
Follows the action-groups contract for an experimental Rating in packages/lab. Issue #11058 received a positive Lab-only response from cixzhang, who said a maintainer would help with the component record. That record is not supplied here; please advise on it. The automated review also identifies the controlled radio-group API, allowClear and getStarLabel names, arrow-key model, read-only display and wording, and colour roles as decisions for an engineering owner. I am not claiming that design approval. The earlier core proposal #3696 is separate. I am not claiming production demand counts or acceptance of this exact API.
Public delta and caller burden
New experimental Rating, RatingProps and RatingSize exports from @astryxdesign/lab. The caller owns value/onChange and supplies the group label. Supports max, size, isDisabled, isReadOnly, allowClear and getStarLabel. No half-star input. This pull request changes no Core file. The Core half (three exports on Core's internal touch entry for the group tracker, and the two English Rating catalog messages) landed in #11283. Beyond the Lab exports, it adds the Rating story, the generated CLI discover and route-lock entries with a CLI changeset, and a
lab__Ratingsample for the swizzle proof (Rating has required props). Rating picks the star glyph's size style itself, where it reflectssizeto themes.Review corrections
Second-review corrections
Third-review corrections
Evidence
49 Rating tests (39 component cases and 10 pointer-stream cases) pass in a sandboxed run, plus a Chromium forced-colours trace. The original implementation passed its original 28 tests but fails five first-review reproduction cases: four unwanted boundary clears and a swallowed caller pointer-leave handler. A broader focused run passes 178 tests versus 177 on the previous corrected head, including shared list focus, ButtonGroup and internal/touch. Three second-review assertions fail on head 08d68b5: read-only handlers, internal data attributes and style-only wrappers. Chrome reproduces the hover-gap bug there too. The third-review regression fails on bcb9c7b, where a no-op onChange leaves the tab stop on an unchecked star.
Real Chrome on a temporary page verifies hover expansion to 4, reduction to 1, restoration of committed 3, retention of committed 3 through all four inter-star gaps, boundary no-clear, explicit clear, keyboard focus, inherited RTL horizontal arrows, fractional clipping in both directions, finger slide/lift selection and outside cancellation. An additional Chrome case verifies the no-op onChange tab stop and re-entry against the submitted head and this correction. This is not the repository's Storybook browser workflow or a visual-regression run.
Validation limits
Whole-Lab TypeScript including tests, Lab doc TypeScript, Lab declaration generation, Babel, Core and Lab CSS builds, cross-package StyleX variable checks, no-dev-JSX and fully-specified imports pass. ESLint, Prettier, package boundaries, changesets, SYNC comments, use-client and i18n catalog checks pass. The temporary browser checks were repeated with runtime StyleX injection disabled and the generated Core astryx.css plus Lab lab.css; all interaction and clipping assertions pass. This uses source-built JavaScript and the generated production CSS, not a packed consumer or Storybook build.
CI, Lint and the CLI smoke test pass at this commit. Still unverified: a real screen reader, the Lab readiness audit, and visual regression (Lab has no stable visual stories).
Latest corrections
color, so the disabled style replaces it.RatingForcedColors.interaction.browser.spec.tsasserts all three in Chromium's forced-colors emulation, on a touch page and on a hover-capable mouse page. The mouse-page case fails on the earlier head that lost CanvasText.onChange.onBlurandonPointerMovehandlers still run, read-only included.Unrated outline contrast
An unrated star's outline uses Core's control-edge border colour today (
--color-border-emphasized, about 1.5:1 on white in the Neutral theme), the same token CheckboxInput and RadioList use. That is below WCAG 1.4.11's 3:1 for a control's edge. This pull request waits for Core's 3:1 control-edge colour (--color-border-control, #11658), then adopts it for the unrated outline in one push, so it ships with no known 1.4.11 gap and no Rating-only colour. Real-Chrome stills and measured contrast follow on that head.Real-Chrome stills
These cover Core and Neutral, in light and dark, at 1280 px and at 390 px with touch emulation, at head dce1ab3 (later commits change only forced-colours paint, the paused preview and the tab stop). The states are empty, partial (read-only 4.3), full (reached by tapping star 5), hover preview, keyboard focus, disabled, read-only, and an RTL read-only fraction that fills from the right. Per-state index: https://raw.githubusercontent.com/vjeux/astryx/01edda1564a3401ac7e994e8a1418a9aa532a06b/index.md
Component record
The draft
component:Ratingrecord is in its own records pull request, so this pull request does not wait on its owner approval. A maintainer added the doc'susage.anatomyhere. The record does not yet match this branch on four points, and it gets those updates before it is reviewed:Scope
Components: Rating (Lab exports
Rating,RatingProps,RatingSize), its story, and the generated CLI discover and route-lock entries. The Core half landed in #11283.Patch prepared and tests executed by Instinct, an AI assistant, at my request.
Owner and land path
Owner: the Astryx fix loop, lane 3. Carried by lane 3 for the contributor.
mainis merged in after #11283. Land path: mixed (Lab plus the CLI discover entry, changeset and swizzle sample; no Lab API owner decision is needed): Specs, CodeBunny, real-Chrome stills and green CI; the drain merges.