[Feature request] Star rating component (Rating)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
Hướng nghiên cứu
Start with src/radio-group/internal.tsx to see how RadioGroup reads ariaLabelledby and ariaDescribedby from src/internal/context/form-field-context.ts. The API decisions are still open, including whether users can clear a star, so agree the design with the maintainers before writing code. Done means a Rating component that works inside FormField, with keyboard, screen-reader and target-size behaviour that matches the issue's accessibility list.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
What we ask for
Cloudscape has no rating component. At Amazon, many teams make a star rating control with the Cloudscape star icons. We ask the Cloudscape team to add a Rating component that operates in a FormField, the same as RadioGroup.
Where we use a star rating
Event Surveys (P530017185) is a new part of AWS Builder Center. After an event, Builder Center shows a short survey to the user. The first item in the survey is a 1 to 5 star rating of the event.
Our solution and its problems
We made a StarRating component (CR-313119797). It uses HTML radio inputs in a fieldset with a legend. This solution has three problems:
- We cannot connect our component to FormField. FormField gives
controlId,ariaLabelledby,ariaDescribedby,invalid, andwarningto its control throughFormFieldContext(form-field-context.ts). For example, RadioGroup getsariaLabelledbyandariaDescribedbyfrom this context (radio-group/internal.tsx). This context is not part of the Cloudscape public API. Thus, our component shows its label and its error text without FormField. - Our label and error text are a copy of FormField. They use the same font weight and error icon as FormField. When Cloudscape changes FormField, our component does not change. To set the label font weight, our code has a stylelint disable comment.
- We wrote all the accessibility code and its tests. This code includes the radio group, the star labels for screen readers, the arrow keys, the focus ring, and the error text. Many other teams write this code again (see "Other teams at Amazon").
When a Cloudscape Rating component is available, we will replace our component with it.
Example API
This API is only an example. The Cloudscape team makes the last decision about the API.
<FormField label="Star rating" errorText={errorText}>
<Rating
value={value}
onChange={({ detail }) => setValue(detail.value)}
i18nStrings={{ valueLabel: (value, max) => `${value} of ${max} stars` }}
/>
</FormField>
<Rating readOnly value={4.5} ariaLabel="Rating of the event" />
Properties:
value: the selected number, from 1 tomax. If the user did not select a star, the value isnull.onChange: a non-cancelable event.detail.valuecontains the new value.max: the number of stars. If you do not setmax, the number of stars is 5.readOnly: the component shows the value, and the user cannot change it. In this mode, the component can show a value of 4.5 with thestar-halficon.disabledinvalidandwarning: FormField sets these properties, the same as for other controls.ariaLabel,ariaLabelledby,ariaDescribedby, andariaRequiredi18nStrings.valueLabel: the name that screen readers read for each star, for example "3 of 5 stars".size(optional): the dimensions of the stars, for example the same values as the Iconsizeproperty.
Decision for the Cloudscape team: can the user remove the value, for example with a second click on the selected star?
Accessibility
These items are necessary. We found most of them when we made and examined our component.
- Each star is a radio (
role="radio"or an HTML radio input). The stars are in a group that has a name. - Tab moves the focus into the group. The arrow keys change the value.
- The focus ring is the same as in other Cloudscape controls.
- The target of each star is a minimum of 24 × 24 CSS pixels (WCAG 2.5.8 Target Size (Minimum)).
- Selected stars and other stars have different shapes, not only different colors (WCAG 1.4.1 Use of Color).
- When the pointer is on a star, that star and the stars before it show as selected. The value does not change.
- Screen readers read the error text when it shows, and when the focus moves into the group.
aria-invalidis not applicable torole="radio". - The component operates correctly on right-to-left pages and in forced-colors mode.
We can help
We can give our StarRating code and tests to the Cloudscape team.
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate requests
- Ngôn ngữ chính
- TypeScript
- Star
- 2.7k
- Fork
- 248
- Merge trung bình
- 3 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 83
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudscape-design/components
-
[Bug]: Circular app layout navigation and help icons are shifted upward in the official demoĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
cloudscape-design/components#5184 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
cloudscape-design/components#5152 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
cloudscape-design/components#5117 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
cloudscape-design/components#5106 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug/Feature Request]: `usePerformanceMarks` has ID generation incompatible with Next.js Partial PrerenderingCó thể đã có người làm @amanabiy đã nhận 27 ngày trước. Đang mởenhancement
cloudscape-design/components#5023 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của cloudscape-design/components
Issue tương tự
-
Add: MahdawiounTV HDĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
iptv-org/iptv#56890 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
franciscoBSalgueiro/en-croissant#1061 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
S: triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp/desktop desktop/shell os/windows P3 tool/file type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NousResearch/hermes-agent#145928 ·
Maintainer thường phản hồi trong vòng 1 ngày