Skip to content

Commit f1b4172

Browse files
committed
docs(ui-progress): add renderValue and formatScreenreaderValue to each example in ProgressBar
Closes: INSTUI-4283
1 parent 56308de commit f1b4172

File tree

1 file changed

+122
-0
lines changed
  • packages/ui-progress/src/ProgressBar

1 file changed

+122
-0
lines changed

packages/ui-progress/src/ProgressBar/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,65 @@ type: example
1818
valueNow={40}
1919
valueMax={60}
2020
margin="0 0 small"
21+
renderValue={({ valueNow, valueMax }) => {
22+
return (
23+
<Text>
24+
{Math.round(valueNow / valueMax * 100)}%
25+
</Text>
26+
)
27+
}}
28+
formatScreenReaderValue={({ valueNow, valueMax }) => {
29+
return Math.round((valueNow / valueMax * 100)) + ' percent'
30+
}}
2131
/>
2232
<ProgressBar
2333
size="small"
2434
screenReaderLabel="Loading completion"
2535
valueNow={40}
2636
valueMax={60}
2737
margin="0 0 small"
38+
renderValue={({ valueNow, valueMax }) => {
39+
return (
40+
<Text>
41+
{Math.round(valueNow / valueMax * 100)}%
42+
</Text>
43+
)
44+
}}
45+
formatScreenReaderValue={({ valueNow, valueMax }) => {
46+
return Math.round((valueNow / valueMax * 100)) + ' percent'
47+
}}
2848
/>
2949
<ProgressBar
3050
screenReaderLabel="Loading completion"
3151
valueNow={40}
3252
valueMax={60}
3353
margin="0 0 small"
54+
renderValue={({ valueNow, valueMax }) => {
55+
return (
56+
<Text>
57+
{Math.round(valueNow / valueMax * 100)}%
58+
</Text>
59+
)
60+
}}
61+
formatScreenReaderValue={({ valueNow, valueMax }) => {
62+
return Math.round((valueNow / valueMax * 100)) + ' percent'
63+
}}
3464
/>
3565
<ProgressBar
3666
size="large"
3767
screenReaderLabel="Loading completion"
3868
valueNow={40}
3969
valueMax={60}
70+
renderValue={({ valueNow, valueMax }) => {
71+
return (
72+
<Text>
73+
{Math.round(valueNow / valueMax * 100)}%
74+
</Text>
75+
)
76+
}}
77+
formatScreenReaderValue={({ valueNow, valueMax }) => {
78+
return Math.round((valueNow / valueMax * 100)) + ' percent'
79+
}}
4080
/>
4181
</div>
4282
```
@@ -56,6 +96,16 @@ type: example
5696
color="primary-inverse"
5797
valueNow={30}
5898
valueMax={60}
99+
renderValue={({ valueNow, valueMax }) => {
100+
return (
101+
<Text>
102+
{Math.round(valueNow / valueMax * 100)}%
103+
</Text>
104+
)
105+
}}
106+
formatScreenReaderValue={({ valueNow, valueMax }) => {
107+
return Math.round((valueNow / valueMax * 100)) + ' percent'
108+
}}
59109
/>
60110
</View>
61111
```
@@ -75,34 +125,84 @@ type: example
75125
valueNow={40}
76126
valueMax={60}
77127
margin="0 0 small"
128+
renderValue={({ valueNow, valueMax }) => {
129+
return (
130+
<Text>
131+
{Math.round(valueNow / valueMax * 100)}%
132+
</Text>
133+
)
134+
}}
135+
formatScreenReaderValue={({ valueNow, valueMax }) => {
136+
return Math.round((valueNow / valueMax * 100)) + ' percent'
137+
}}
78138
/>
79139
<ProgressBar
80140
screenReaderLabel="Loading completion"
81141
meterColor="success"
82142
valueNow={40}
83143
valueMax={60}
84144
margin="0 0 small"
145+
renderValue={({ valueNow, valueMax }) => {
146+
return (
147+
<Text>
148+
{Math.round(valueNow / valueMax * 100)}%
149+
</Text>
150+
)
151+
}}
152+
formatScreenReaderValue={({ valueNow, valueMax }) => {
153+
return Math.round((valueNow / valueMax * 100)) + ' percent'
154+
}}
85155
/>
86156
<ProgressBar
87157
screenReaderLabel="Loading completion"
88158
meterColor="alert"
89159
valueNow={40}
90160
valueMax={60}
91161
margin="0 0 small"
162+
renderValue={({ valueNow, valueMax }) => {
163+
return (
164+
<Text>
165+
{Math.round(valueNow / valueMax * 100)}%
166+
</Text>
167+
)
168+
}}
169+
formatScreenReaderValue={({ valueNow, valueMax }) => {
170+
return Math.round((valueNow / valueMax * 100)) + ' percent'
171+
}}
92172
/>
93173
<ProgressBar
94174
screenReaderLabel="Loading completion"
95175
meterColor="warning"
96176
valueNow={40}
97177
valueMax={60}
98178
margin="0 0 small"
179+
renderValue={({ valueNow, valueMax }) => {
180+
return (
181+
<Text>
182+
{Math.round(valueNow / valueMax * 100)}%
183+
</Text>
184+
)
185+
}}
186+
formatScreenReaderValue={({ valueNow, valueMax }) => {
187+
return Math.round((valueNow / valueMax * 100)) + ' percent'
188+
}}
99189
/>
100190
<ProgressBar
101191
screenReaderLabel="Loading completion"
102192
meterColor="danger"
103193
valueNow={40}
104194
valueMax={60}
105195
margin="0 0 small"
196+
renderValue={({ valueNow, valueMax }) => {
197+
return (
198+
<Text>
199+
{Math.round(valueNow / valueMax * 100)}%
200+
</Text>
201+
)
202+
}}
203+
formatScreenReaderValue={({ valueNow, valueMax }) => {
204+
return Math.round((valueNow / valueMax * 100)) + ' percent'
205+
}}
106206
/>
107207
</div>
108208
```
@@ -128,6 +228,16 @@ type: example
128228
}}
129229
valueNow={10}
130230
valueMax={60}
231+
renderValue={({ valueNow, valueMax }) => {
232+
return (
233+
<Text>
234+
{Math.round(valueNow / valueMax * 100)}%
235+
</Text>
236+
)
237+
}}
238+
formatScreenReaderValue={({ valueNow, valueMax }) => {
239+
return Math.round((valueNow / valueMax * 100)) + ' percent'
240+
}}
131241
/>
132242
```
133243

@@ -259,6 +369,12 @@ The `shouldAnimate` prop makes the progress bar animate the transition between v
259369
valueNow={this.state.value}
260370
valueMax={this.MAX}
261371
shouldAnimate={this.state.shouldAnimate}
372+
renderValue={({ valueNow, valueMax }) => {
373+
return <Text>{Math.round((valueNow / valueMax) * 100)}%</Text>
374+
}}
375+
formatScreenReaderValue={({ valueNow, valueMax }) => {
376+
return Math.round((valueNow / valueMax) * 100) + ' percent'
377+
}}
262378
/>
263379
</div>
264380
)
@@ -346,6 +462,12 @@ The `shouldAnimate` prop makes the progress bar animate the transition between v
346462
valueNow={value}
347463
valueMax={MAX}
348464
shouldAnimate={shouldAnimate}
465+
renderValue={({ valueNow, valueMax }) => {
466+
return <Text>{Math.round((valueNow / valueMax) * 100)}%</Text>
467+
}}
468+
formatScreenReaderValue={({ valueNow, valueMax }) => {
469+
return Math.round((valueNow / valueMax) * 100) + ' percent'
470+
}}
349471
/>
350472
</div>
351473
)

0 commit comments

Comments
 (0)