Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookes committed Sep 25, 2020
1 parent ed5d023 commit 6e9b256
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
37 changes: 23 additions & 14 deletions docs/src/pages/components/rating/rating.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ waiAria: https://www.w3.org/WAI/tutorials/forms/custom-controls/#a-star-rating

# Rating

<p class="description">Ratings provide insight regarding others’ opinions and experiences with a product. Users can also rate products they’ve purchased.</p>
<p class="description">Ratings provide insight regarding others’ opinions and experiences, and can allow the user to submit a rating of thier own.</p>

{{"component": "modules/components/ComponentLinkHeader.js"}}

## Simple ratings
## Basic rating

{{"demo": "pages/components/rating/SimpleRating.js"}}
{{"demo": "pages/components/rating/BasicRating.js"}}

## Customized ratings
## Customized rating

Here are some examples of customizing the component. You can learn more about this in the
[overrides documentation page](/customization/components/).
Expand All @@ -24,12 +24,12 @@ Here are some examples of customizing the component. You can learn more about th

## Hover feedback

You can display a label on hover to help users pick the correct rating value.
You can display a label on hover to help the user pick the correct rating value.
The demo uses the `onChangeActive` prop.

{{"demo": "pages/components/rating/HoverRating.js"}}

## Half ratings
## Rating precision

The rating can display any float number with the `value` prop.
Use the `precision` prop to define the minimum increment value change allowed.
Expand All @@ -38,22 +38,31 @@ Use the `precision` prop to define the minimum increment value change allowed.

## Sizes

Fancy larger or smaller ratings? Use the `size` prop.
For larger or smaller ratings use the `size` prop.

{{"demo": "pages/components/rating/RatingSize.js"}}

## Accessibility

(WAI tutorial: https://www.w3.org/WAI/tutorials/forms/custom-controls/#a-star-rating)
([WAI tutorial](https://www.w3.org/WAI/tutorials/forms/custom-controls/#a-star-rating))

The accessibility of this component relies on:

- A radio group is used with its fields visually hidden.
It contains six radio buttons, one for each star and another for 0 stars, which is checked by default. Make sure you are providing a `name` prop that is unique to the parent form.
- The labels for the radio buttons contain actual text (“1 Star”, “2 Stars”, …), make sure you provide a `getLabelText` prop when the page language is not English.
- A radio group with its fields visually hidden.
It contains six radio buttons, one for each star, and another for 0 stars that is checked by default. Be sure to provide a value for the `name` prop that is unique to the parent form.
- Labels for the radio buttons containing actual text (“1 Star”, “2 Stars”, …).
Be sure to provide a suitable function to the `getLabelText` prop when the page is in a language other than English.
- A visually distinct appearance for the rating icons.
By default, the rating component uses both a difference of color and shape (filled and empty icons)to indicate the value. In the event that you are using color as the only means to indicate the value, the information should also be also displayed as text, as in this demo. This is important to match [success Criterion 1.4.1](https://www.w3.org/TR/WCAG21/#use-of-color) of WCAG2.1.

By default, the rating component uses both a difference of color and shape between the filled and empty icons to indicate the value.
{{"demo": "pages/components/rating/TextRating.js"}}

In the event that you are using color as the only means to indicate the value, the information should also be also displayed as text, as in this demo. This is important to match [success Criterion 1.4.1](https://www.w3.org/TR/WCAG21/#use-of-color) of WCAG2.1.
### ARIA

{{"demo": "pages/components/rating/TextRating.js"}}
The read only rating has a role of "img", and an aria-label that describes the displayed rating.

### Keyboard

Because the rating component uses radio buttons, keyboard interaction follows the native broser behavior. Tab will focus the current rating, and cursor keys control the selected rating.

The read only rating is not focusable.
4 changes: 2 additions & 2 deletions docs/src/pages/guides/migration-v4/migration-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ const theme = createMuitheme({
- Move the component from the lab to the core. The component is now stable.

```diff
-import Alert from '@material-ui/lab/Rating';
+import Alert from '@material-ui/core/Rating';
-import Rating from '@material-ui/lab/Rating';
+import Rating from '@material-ui/core/Rating';
```

- Change the default empty icon to improve accessibility.
Expand Down

0 comments on commit 6e9b256

Please sign in to comment.