Repository navigation
Conversation
An accessible star rating input for capturing or displaying a score. - Controlled and uncontrolled value (value / defaultValue) - Half-icon precision (hasHalfIcons) and fractional read-only display - Read-only (isReadOnly) and disabled (isDisabled) states - Configurable max, size (sm/md/lg), and color (warning/accent/neutral) - Custom filled/empty icons; defaults to a star glyph - Optional value label and custom formatter - Hidden input for native form submission (htmlName) Accessibility: interactive ratings use the WAI-ARIA slider role with arrow-key / Home / End support; read-only ratings use role="img" with a descriptive label — mirroring the existing Slider component. Includes colocated tests (16), typed docs (docs/docsZh/docsDense), Storybook stories, and a CLI showcase block.
|
@leomega1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
Make Rating a single source of truth for scores across products. - Modes: interactive (slider) and display (read-only img) - Configurable max and precision (1, 0.5, 0.25, 0.1) with clean fractional values - Icons from the project icon system (solid filled clipped over outline empty); default star vendored from Heroicons; custom filled/empty/partial supported - Semantic colors (gold/brand/warning/positive/neutral) or any CSS color - Label placement (top/bottom/left/right/hidden), value text, review count, descriptive labels (Poor…Excellent), tooltips - Density (compact/comfortable/spacious) and animations (fill/scale/bounce) - States incl. loading skeleton; RTL-aware fill and pointer math - Full a11y: slider role, arrows/Home/End/Space/Enter, aria-value*, live region - Forwards pass-through props (id/data-*/aria-*); onChange fires only on change Grouped config (icons) and enums keep the API clean. Colocated tests (25), typed docs, and Storybook stories covering every variant.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for this, @leomega1 — and welcome. There's genuinely careful work here: the Slider-modeled slider/img a11y, colocated tests, controlled/uncontrolled handling, and a changeset. Strong first-contribution instinct.
I can't merge a new @astryxdesign/core component from a PR alone, though. Every new core component goes through a specification protocol before code is written — issue first, API agreed in the thread, then build. This isn't a formality: core API decisions need cross-codebase usage evidence (which props are actually used and how often, how the concept maps across the systems we're converging, where the industry has settled). A finished PR skips the step where that shaping happens, and the API shape is the expensive thing to get wrong once it's public and versioned. (See Contributing with AI Assistants → "Building components without prior discussion" and the Component Specification Protocol.)
If you'd like to pursue a Rating component, the path that lands:
- File an issue describing the problem, not the solution — who needs a rating input, on what surfaces, how it's handled today, and any usage evidence. (There's no tracking issue for this yet.)
- Once the API is agreed in that thread, the build is the easy part — and much of what you've already written should transfer.
Would you like to go through that process? If so, open the issue and I'm happy to help shape the spec. If we don't hear back we'll let this PR close out, but the door's open either way.
Thanks again for the effort.
|
It's been some time so closing for now. Please file an issue if you'd like to collaborate on a new component! |
Summary
Adds a new
Ratingcomponent to@astryxdesign/core— an accessible star rating input for capturing or displaying a score. This fills a genuine gap in the library (no rating/score input existed;Collapsible/CollapsibleGroupalready cover accordions, so that was ruled out).What it does
value/defaultValue)hasHalfIcons) plus continuous fractional rendering in read-only mode (e.g.4.3)isReadOnlydisplay mode andisDisabledstatemax,size(sm/md/lg), andcolor(warning/accent/neutral)icon/emptyIcon(defaults to a star glyph)hasValueLabel) with a customformatValueLabelhtmlName)Accessibility
sliderrole (single tab stop;←/→/↑/↓adjust,Home/Endjump to bounds) witharia-valuemin/max/now/text.role="img"with a descriptivearia-label.Slidercomponent's a11y conventions.:hoverguarded under@media (hover: hover); respectsprefers-reduced-motion.Conventions followed
themeProps('rating', …)theme target (astryx-rating, visual propssize/color, statesreadonly/disabled).displayNameset; StyleX styling; React 19ref-as-prop.Testing
Rating.test.tsx).pnpm -F @astryxdesign/core build,eslint(0 warnings),pnpm check:changesets, andpnpm sync:exports:checkall pass.Included
packages/core/src/Rating/— component, tests, typed docs (docs/docsZh/docsDense),index.tsapps/storybook/stories/Rating.stories.tsx— Default, HalfStars, ReadOnly, Sizes, Colors, Disabled, WithHiddenLabelpackages/cli/templates/blocks/components/Rating/— CLI showcase block.changeset/rating-component.md—[component]categoryScreenshots
Rendered locally in the doc site at
/components/Rating— add a screenshot here.