Skip to content

Commit 502449d

Browse files
committed
fix(ui-rating): add text value to Rating examples
Also remove a not needed div and make the icon aria-hidden because VO reads sometimes a lots of empty groups closes: INSTUI-4307
1 parent a31cd49 commit 502449d

File tree

2 files changed

+77
-55
lines changed

2 files changed

+77
-55
lines changed

packages/ui-rating/src/Rating/README.md

Lines changed: 70 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,32 @@ this feature using the `animateFill` prop.
2020
---
2121
type: example
2222
---
23-
<div>
24-
<Rating
25-
formatValueText={function (currentRating, maxRating) {
26-
return currentRating + ' out of ' + maxRating
27-
}}
28-
label="Overall rating of freshman year experience"
29-
valueNow={68.45}
30-
valueMax={100}
31-
/>
32-
<br />
33-
<Rating
34-
animateFill
35-
formatValueText={function (currentRating, maxRating) {
36-
return currentRating + ' out of ' + maxRating
37-
}}
38-
label="Overall rating of freshman year experience"
39-
iconCount={5}
40-
valueNow={68.45}
41-
valueMax={100}
42-
/>
43-
</div>
23+
<Flex gap="large">
24+
<Flex gap="x-small">
25+
<Rating
26+
formatValueText={function (currentRating, maxRating) {
27+
return currentRating + ' out of ' + maxRating
28+
}}
29+
label="Overall rating of freshman year experience"
30+
valueNow={68.45}
31+
valueMax={100}
32+
/>
33+
<div>2/3</div>
34+
</Flex>
35+
<Flex gap="x-small">
36+
<Rating
37+
animateFill
38+
formatValueText={function (currentRating, maxRating) {
39+
return currentRating + ' out of ' + maxRating
40+
}}
41+
label="Overall rating of freshman year experience"
42+
iconCount={5}
43+
valueNow={68.45}
44+
valueMax={100}
45+
/>
46+
<div>3/5</div>
47+
</Flex>
48+
</Flex>
4449
```
4550

4651
### Sizes
@@ -52,30 +57,48 @@ space around the actual rating.
5257
---
5358
type: example
5459
---
55-
<div>
56-
<Rating
57-
label="Product rating"
58-
size="small"
59-
iconCount={5}
60-
valueNow={3.76}
61-
valueMax={5}
62-
margin="x-small medium xx-small none"
63-
/>
64-
<Rating
65-
label="Overall rating of college experience"
66-
iconCount={5}
67-
valueNow={30}
68-
valueMax={100}
69-
margin="x-small xx-large"
70-
/>
71-
<Rating
72-
animateFill
73-
label="Rating of professor"
74-
size="large"
75-
iconCount={5}
76-
valueNow={8}
77-
valueMax={8}
78-
margin="medium"
79-
/>
80-
</div>
60+
<Flex gap="large">
61+
<Flex>
62+
<Rating
63+
label="Product rating"
64+
size="small"
65+
iconCount={5}
66+
valueNow={3.76}
67+
valueMax={5}
68+
margin="small"/>
69+
<div>4/5</div>
70+
</Flex>
71+
<Flex>
72+
<Rating
73+
label="Overall rating of college experience"
74+
iconCount={5}
75+
valueNow={30}
76+
valueMax={100}
77+
margin="small"
78+
/>
79+
<div>2/5</div>
80+
</Flex>
81+
<Flex>
82+
<Rating
83+
animateFill
84+
label="Rating of professor"
85+
size="large"
86+
iconCount={5}
87+
valueNow={8}
88+
valueMax={8}
89+
margin="small"/>
90+
<div>5/5</div>
91+
</Flex>
92+
</Flex>
93+
```
94+
95+
```js
96+
---
97+
type: embed
98+
---
99+
<Guidelines>
100+
<Figure recommendation="a11y" title="Accessibility">
101+
<Figure.Item>Display a textual value for the rating to meet WCAG 2.1 Use of Color standards. "Non-text information within controls that uses a change of hue alone to convey the value or state of an input, such as a 1-5 star indicator where state depends on whether it's filled or empty is likely to fail the Use of color criterion"</Figure.Item>
102+
</Figure>
103+
</Guidelines>
81104
```

packages/ui-rating/src/RatingIcon/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,19 @@ class RatingIcon extends Component<RatingIconProps, RatingIconState> {
110110

111111
return (
112112
<span
113+
aria-hidden="true"
113114
css={this.props.styles?.ratingIcon}
114115
ref={(el) => {
115116
this.ref = el
116117
}}
117118
>
118-
<span>
119-
{this.state.filled && animateFill ? (
120-
<Transition in transitionOnMount type="scale">
121-
<Icon css={this.props.styles?.icon} />
122-
</Transition>
123-
) : (
119+
{this.state.filled && animateFill ? (
120+
<Transition in transitionOnMount type="scale">
124121
<Icon css={this.props.styles?.icon} />
125-
)}
126-
</span>
122+
</Transition>
123+
) : (
124+
<Icon css={this.props.styles?.icon} />
125+
)}
127126
</span>
128127
)
129128
}

0 commit comments

Comments
 (0)