Repository navigation
feat(lab): add Rating, a star rating input and read-only display - #11082
Rajatendu1 wants to merge 15 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 cla@meta.com. 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.
…view While focus is inside the group, the focused star holds the tab stop, and a blur out of the group hands it back to the checked star, so a caller that ignores onChange no longer makes Tab stop on the checked star first. A key choice ends the hover preview until the pointer moves, so the preview never paints a count other than the value. Caller onBlur and onPointerMove handlers still run, read-only included.
|
/approve-spec c48db6d |
There was a problem hiding this comment.
Thanks for carrying this through: the Rating contract is approved by an engineering owner at this head, and the earlier hover-preview and Tab-hop notes are fixed. Two things still need changing before this can be approved.
Blocking
- A disabled Rating still paints its filled stars in
Highlightunder forced colours, becausefilled's own top-level forced-colours rule (Rating.tsx:94) outranks the new arm infilledDisabled, so please write the forced-colours arms offilledandemptyin the property form (color: {default: …, '@media (forced-colors: active)': 'Highlight'}) so thatfilledDisabledreplaces them. - The description no longer matches the code: "Latest correction" says a disabled Rating now paints
GrayTextin forced colours, "Third-review corrections" says the checked star stays the only tab stop when a caller ignoresonChange(the focused star now holds it while focus is inside), "Evidence" counts 47 tests where there are 48, the hover bullet omits the new pause state, and the opening note leaves out the generated route-lock entry, so please update those sentences and describe the Tab and hover-pause change.
Non-blocking
- Space and Enter do not pause the hover preview the way the arrow keys now do, so with the mouse resting on another star the preview keeps painting that star's count after a key choice.
CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: the Core half landed separately and the base branch is merged in: verified.
- Claim: the pull request changes only Lab, its story and the CLI discover list: false (the route-lock entry also changes).
- Claim: controlled whole-star radio group with one tab stop, shared list navigation without wrapping, Home/End, Space/Enter and optional clear: verified.
- Claim: horizontal arrows follow text direction, Down advances and Up retreats, and navigation never clears a selected boundary: verified.
- Claim: touch selects only the lifted star, leaving, cancelling or a second finger selects nothing, coarse targets grow toward 44 px, mouse presses stay native: verified.
- Claim: the hover preview uses scoped CSS, not React state: partly stale (a state now pauses it).
- Claim: the read-only display is one named image with inline-start fractional fill and catalog-backed names: verified.
- Claim: new Lab exports and props, no half-star input, no Core file changed, story and generated discover and route-lock entries added: verified.
- Claims from the first and second review rounds (navigation-only selection, boundary no-op, caller handlers, one SVG per star, gap hover, no internal data attribute, native activation, read-only handler forwarding, no wrapper spans): verified.
- Claim: when a caller ignores
onChangethe checked star stays the only tab stop, and the regression verifies an unchanged tab stop: false. - Claim: 47 Rating tests (37 component, 10 pointer-stream): false (48: 38 and 10).
- Claim: Lab typecheck, builds, lint, formatting, boundaries, changesets, SYNC, use-client and catalog checks pass; full CI not yet run: verified.
- Claim: a disabled Rating now paints
GrayTextin forced colours: false for filled stars. - Claim: the draft component record lives in its own pull request and a maintainer added the doc's anatomy: verified.
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified. - Files:
.changeset/cli-discover-rating.md,apps/storybook/stories/Rating.stories.tsx,internal/shadcn-registry/routes.lock.json,packages/cli/assets/discover/official-packages.json,Rating.doc.mjs,Rating.test.tsx,RatingTracking.test.tsx,Rating/index.ts,rating.stylex.ts,packages/lab/src/index.ts: clear. - File:
Rating.tsx: the forced-colours finding above, and the non-blocking Space/Enter note.
The forced-colours colours of the empty and filled stars are now arms of their color property, so the disabled style's arm replaces them. Before, the top-level media rule outranked it and filled stars stayed Highlight.
|
/approve-spec 183554d |
The interactive star's colour now has its own forced-colours arm: Highlight for a checked star, CanvasText for the others. Without it, empty stars took the emphasized border colour, which is not a system colour and is nearly invisible in a high-contrast theme.
A Chromium forced-colors trace of the States story: a checked star is Highlight, an empty star CanvasText, and a disabled rating's stars GrayText.
|
/approve-spec 405db39 |
There was a problem hiding this comment.
Thanks for the forced-colours fixes: a disabled Rating now paints every star in GrayText, an enabled one keeps Highlight and CanvasText, and an engineering owner approved the Rating contract at this head. Two things still need changing before this can be approved.
Blocking
- A Space or Enter choice does not pause the hover preview, because only the arrow keys, Home and End reach
setPreviewsHover(false)inRating.tsx, so with the mouse resting on star 4, Space on star 1 sets the rating to 1 while four stars stay filled; this contradicts the description's "a key choice pauses the hover preview" and the comment abovepreviewsHover, so please pause the preview for Space and Enter too (with a test), or narrow both texts to arrow, Home and End choices. - The description's third-review bullet still says the regression "verifies the unchanged checked/tab-stop state", while the test now asserts that the focused star holds the tab stop while focus is inside (
Rating.test.tsx:66), so please reword that bullet.
Non-blocking
- The forced-colours arms of
--rating-colorininteractiveStarandinteractiveStarStillno longer reach any paint, becauseinteractivePath's forced arm reads--rating-selected-colordirectly.
CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: the Core half (touch re-exports and two catalog messages) landed separately and the base branch is merged in: verified.
- Claim: the pull request changes only Lab, its story, the CLI discover list and the generated route-lock entry: verified.
- Claim: controlled whole-star radio group with one tab stop, shared list navigation without wrapping, Home/End, Space/Enter and optional clear: verified.
- Claim: horizontal arrows follow text direction, Down advances and Up retreats, and navigation never clears a selected boundary: verified.
- Claim: touch selects only the lifted star, leaving, cancelling or a second finger selects nothing, coarse targets grow toward 44 px, mouse presses stay native: verified.
- Claim: the hover preview is scoped CSS, and an arrow, Home or End choice pauses it so it paints the value: verified.
- Claim: the read-only display is one named image with inline-start fractional fill and catalog-backed names: verified.
- Claim: the linked issue got a positive Lab-only owner response and the component record is not supplied here: verified.
- Claim: new Lab exports and props, no half-star input, no Core file changed, story and generated entries added: verified.
- Claims from the first and second review rounds (navigation-only selection, boundary no-op, caller handlers, one SVG per star, gap hover, no internal data attribute, native activation, read-only handler forwarding, no wrapper spans): verified.
- Claim: Rating owns its value-derived tab stop, the focused star holds it while focus is inside, and Tab re-entry returns to the checked star: verified.
- Claim: the third-round regression verifies an unchanged tab stop: false (the test asserts the stop moves to the focused star while focus is inside).
- Claim: 48 Rating tests (38 component, 10 pointer-stream) pass: verified.
- Claims about earlier heads (earlier test counts and reproduction failures, temporary-page browser checks): historical, not re-run.
- Claim: Lab typecheck, builds, lint, formatting, boundaries, changesets, SYNC, use-client and catalog checks pass; full CI not yet run: verified.
- Claim: under forced colours a checked star is Highlight, an empty star CanvasText and every disabled star GrayText, and the new browser spec asserts it: verified.
- Claim: a key choice pauses the hover preview until the pointer moves: false for Space and Enter.
- Claim: caller blur and pointer-move handlers still run, read-only included: verified.
- Claim: later commits change only forced-colours paint, the paused preview and the tab stop, so the earlier stills hold: verified.
- Claim: real-Chrome stills cover Core and Neutral, light and dark, desktop and touch widths: not checked (hosted outside this repository).
- Claim: the draft component record lives in its own pull request and the doc's anatomy was added: verified.
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified. - Files:
.changeset/cli-discover-rating.md,apps/storybook/stories/Rating.stories.tsx,internal/shadcn-registry/routes.lock.json,packages/cli/assets/discover/official-packages.json,Rating.doc.mjs,RatingTracking.test.tsx,RatingForcedColors.interaction.browser.spec.ts,Rating/index.ts,rating.stylex.ts,packages/lab/src/index.ts: clear. - File:
Rating.test.tsx: clear (the stale description bullet concerns it). - File:
Rating.tsx: the Space/Enter finding above, and the non-blocking forced-colours note.
Hover-guarded rules apply only under a hover-capable pointer, so the phone page alone cannot see a regression there. The proof now runs on the touch page and on a mouse page.
|
/approve-spec 71650ab |
There was a problem hiding this comment.
This still needs changes before it can be approved: an engineering owner approved the Rating contract at this head, but the two points from the last review are still open.
Blocking
- A Space or Enter choice does not pause the hover preview, because only the arrow keys, Home and End reach
setPreviewsHover(false)inRating.tsx, so with the mouse resting on star 4, Space or Enter on star 1 sets the rating to 1 while four stars stay filled; this contradicts the description's "a key choice pauses the hover preview" and the comment abovepreviewsHover, so please pause the preview for Space and Enter too (with a test), or narrow both texts to arrow, Home and End choices. - The description's third-review bullet still says the regression "verifies the unchanged checked/tab-stop state", while the test asserts that the focused star holds the tab stop while focus is inside (
Rating.test.tsx:66), so please reword that bullet.
Non-blocking
- The forced-colours arms of
--rating-colorininteractiveStarandinteractiveStarStillreach no paint, becauseinteractivePath's forced arm reads--rating-selected-colordirectly.
CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
Claims and files checked
Review mode: same-head; reason: none
- Claim: the Core half (touch re-exports and two catalog messages) landed separately and the base branch is merged in: verified.
- Claim: the pull request changes only Lab, its story, the CLI discover list and the generated route-lock entry: verified.
- Claim: controlled whole-star radio group with one tab stop, shared list navigation without wrapping, Home/End, Space/Enter and optional clear: verified.
- Claim: horizontal arrows follow text direction, Down advances and Up retreats, and navigation never clears a selected boundary while explicit activation can: verified.
- Claim: touch selects only the lifted star; leaving, cancelling or a second finger selects nothing; coarse targets grow toward 44 px; mouse presses stay native: verified.
- Claim: the hover preview is scoped CSS, and an arrow, Home or End choice pauses it until the pointer moves: verified.
- Claim: a key choice pauses the hover preview until the pointer moves: false for Space and Enter.
- Claim: the read-only display is one named image with inline-start fractional fill, a label callback that receives fractions, and catalog-backed names: verified.
- Claim: the linked issue got a positive Lab-only owner response, the earlier core proposal is separate, and the component record is not supplied here: verified.
- Claim: new Lab exports and props, no half-star input, no Core file changed, story and generated entries added: verified.
- Claims from the first and second review rounds (navigation-only selection, boundary no-op, caller handlers, one SVG per star, gap hover, no internal data attribute, native activation, read-only handler forwarding, no wrapper spans): verified.
- Claim: Rating owns its value-derived tab stop, the focused star holds it while focus is inside, and Tab re-entry returns to the checked star: verified.
- Claim: the third-round regression verifies an unchanged tab stop: false (the test asserts the stop moves to the focused star while focus is inside).
- Claim: 48 Rating tests (38 component, 10 pointer-stream) pass: verified.
- Claims about earlier heads (earlier test counts, reproduction failures, temporary-page browser checks): historical, not re-run.
- Claim: Lab typecheck, builds, lint, formatting, boundaries, changesets, SYNC, use-client, catalog, no-dev-JSX and fully-specified checks pass, and full CI has not run: verified.
- Claim: under forced colours a checked star is Highlight, an empty star CanvasText and every disabled star GrayText, each set as an arm of the colour: verified.
- Claim: the browser spec asserts all three on a touch page and on a hover-capable mouse page, and the mouse-page case fails on the earlier head that lost CanvasText: verified.
- Claim: caller blur and pointer-move handlers still run, read-only included: verified.
- Claim: later commits change only forced-colours paint, the paused preview and the tab stop, so the earlier stills hold: verified.
- Claim: real-browser stills cover Core and Neutral, light and dark, desktop and touch widths: not checked (hosted outside this repository).
- Claim: the draft component record lives in its own pull request and the doc's anatomy was added: verified.
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified. - Files: the changeset, the story, the route lock, the discover list,
Rating.doc.mjs,RatingTracking.test.tsx, the forced-colours browser spec,Rating/index.ts,rating.stylex.tsandpackages/lab/src/index.ts: clear. - File:
Rating.test.tsx: clear (the stale description bullet concerns it). - File:
Rating.tsx: the Space/Enter finding above, and the non-blocking forced-colours note.
A choice by Space or Enter now ends the hover preview until the pointer moves, as an arrow key does. The unused forced-colours arms of --rating-color are gone; the star path reads the selected colour directly there.
|
/approve-spec 0fdb1b5 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label for it to run.
An engineering owner approved Rating's contract at this exact head, and the last issue from the previous review is fixed: Space and Enter now pause the hover preview, a new test covers it, and in Chromium the preview stays off until the pointer moves again. Thanks for carrying this through every round.
Claims and files checked
Review mode: full; reason: author-not-engowner
Claims:
- Core's half (internal touch exports and the two catalog messages) is already on main, and this pull request changes only Lab, its story, the discover list and the route lock, plus a changeset: verified (base internal touch entry and English catalog; the 12-file diff).
- Controlled whole-star radio group with one tab stop, shared list focus without wrapping, Home/End, Space/Enter and optional clear: verified (
Rating.tsx:266-273,:336-416; tests). - Horizontal arrows follow text direction; Down advances and Up retreats: verified (right-to-left test; Chromium right-to-left run).
- Navigation never clears a selected boundary; an explicit click, Space or Enter can: verified (boundary and clear tests).
- Touch chooses the lifted star; leaving, cancelling or a second finger chooses nothing; coarse targets grow toward 44 px; a mouse stays native: verified (
RatingTracking.test.tsx; Chromium phone profile). - Hover preview is scoped CSS; an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx:150-159,:352-353,:362-366;Rating.test.tsx:75-89; Chromium). - Hovering a gap between stars keeps the committed rating: verified (Chromium, all four gaps).
- Read-only is one named image with an inline-start fractional fill and a label callback that receives fractions, and names come from catalog messages: verified (tests; Chromium clip in both directions).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (tests;
Rating.tsx:303-306,:362-370). - Rating owns the tab stop: the focused star holds it inside the group and Tab re-enters on the checked star, as the regression test describes: verified (
Rating.tsx:410;Rating.test.tsx:47-73). - Forced colours paint checked stars Highlight, empty stars CanvasText and a disabled rating GrayText, with a browser spec on a touch and a mouse page: verified (Chromium probe; spec read, not run here).
- 49 Rating tests (39 component, 10 pointer-stream) pass: verified (sandboxed run).
- ESLint, package boundaries, changesets, SYNC, use-client and i18n catalog checks and Lab TypeScript pass: verified (sandboxed run).
- Counts and failures reported for earlier heads: describe earlier heads; not rechecked.
- Full CI, the Storybook browser workflow, visual regression, other browsers and a screen reader are unverified: accurate (CI waits for a maintainer).
- Commits after the stills' head change only forced-colours paint, the paused preview and the tab stop: verified (commit history).
- Changeset:
astryx discoverlists the experimental Rating from Lab: verified (Lab entry in the official list; generator check current).
Files (each clear):
.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/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 45bcb74 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this commit yet, so a maintainer needs to add the ci:run label for it to run.
An engineering owner approved Rating's contract for this exact commit, and the merge of main leaves Rating working: its tests pass on the merged tree and both generated entries regenerate exactly.
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 this pull request changes only Lab, its story, the discover list and the route lock, plus a changeset: verified (the 12-file diff;mainhistory). - 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; tests; Chromium keyboard capture). - Horizontal arrows follow text direction, Down advances and Up retreats: verified (right-to-left and key tests).
- Navigation never clears a selected boundary, while a click, Space or Enter can: verified (boundary and clear tests).
- Touch chooses the lifted star, leaving, cancelling or a second finger chooses nothing, coarse targets grow toward 44 px and a mouse stays native: verified (pointer-stream tests; Chromium finger slide).
- The hover preview is scoped CSS, and an arrow, Home, End, Space or Enter choice pauses it until the pointer moves: verified (
Rating.tsx; 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 names and right-to-left clip).
- Caller pointer-leave, key, focus, blur and pointer-move handlers still run, read-only included: verified (
Rating.tsx; handler tests). - The focused star holds the tab stop inside the group, and Tab re-enters on the checked star: verified (tab-stop test; Chromium keyboard capture).
- Forced colours paint checked stars Highlight, empty ones CanvasText and a disabled rating GrayText, with a browser spec on a touch and a mouse page: verified (Chromium probe; spec read, not run).
- 49 Rating tests (39 component, 10 pointer-stream) pass: verified (sandboxed run with
mainmerged in). - ESLint, SYNC, changesets, use-client, i18n catalog and package-boundary checks pass: verified (sandboxed run).
- Counts and failures stated for earlier commits: they describe earlier commits and were not rechecked.
- 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 thread; no record on
main). - Changeset:
astryx discoverlists the experimental Rating from Lab: verified (Lab entry in the official list; generator check current).
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/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
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| lab/Rating · Storybook | 65.1 kB (new) · 949 B CSS (new) | 397 (new) |
Package size: @astryxdesign/cli 5.59 MB packed (+7 B); no new dependencies.
Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Current run: CI concluded failure; parts of this report may be missing.
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 |
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 and the generated CLI discover and route-lock entries.
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.
Full CI, whole-repository tests, built Storybook/browser specs, visual regression, other browsers, a real screen reader and Lab readiness audit remain unverified. Repository workflows still need maintainer approval. No maintainer design/spec approval is claimed.
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.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 Lab-only pull request does not wait on its owner approval. The record states the contract this branch implements. A maintainer added the doc'susage.anatomyhere.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. Lab-only: Specs, CodeBunny, real-Chrome stills and green CI; the drain merges.