@instructure/ui-progress 10.2.3-snapshot-2 → 10.2.3-snapshot-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/package.json +13 -13
- package/src/ProgressBar/README.md +140 -54
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.2.3-snapshot-
|
|
6
|
+
## [10.2.3-snapshot-3](https://github.com/instructure/instructure-ui/compare/v10.2.2...v10.2.3-snapshot-3) (2024-09-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-progress
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-progress",
|
|
3
|
-
"version": "10.2.3-snapshot-
|
|
3
|
+
"version": "10.2.3-snapshot-3",
|
|
4
4
|
"description": "Styled HTML <progress /> elements for showing completion of a task",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.24.5",
|
|
27
|
-
"@instructure/console": "10.2.3-snapshot-
|
|
28
|
-
"@instructure/emotion": "10.2.3-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.2.3-snapshot-
|
|
30
|
-
"@instructure/ui-a11y-content": "10.2.3-snapshot-
|
|
31
|
-
"@instructure/ui-color-utils": "10.2.3-snapshot-
|
|
32
|
-
"@instructure/ui-react-utils": "10.2.3-snapshot-
|
|
33
|
-
"@instructure/ui-testable": "10.2.3-snapshot-
|
|
34
|
-
"@instructure/ui-view": "10.2.3-snapshot-
|
|
27
|
+
"@instructure/console": "10.2.3-snapshot-3",
|
|
28
|
+
"@instructure/emotion": "10.2.3-snapshot-3",
|
|
29
|
+
"@instructure/shared-types": "10.2.3-snapshot-3",
|
|
30
|
+
"@instructure/ui-a11y-content": "10.2.3-snapshot-3",
|
|
31
|
+
"@instructure/ui-color-utils": "10.2.3-snapshot-3",
|
|
32
|
+
"@instructure/ui-react-utils": "10.2.3-snapshot-3",
|
|
33
|
+
"@instructure/ui-testable": "10.2.3-snapshot-3",
|
|
34
|
+
"@instructure/ui-view": "10.2.3-snapshot-3",
|
|
35
35
|
"prop-types": "^15.8.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@instructure/ui-babel-preset": "10.2.3-snapshot-
|
|
39
|
-
"@instructure/ui-test-locator": "10.2.3-snapshot-
|
|
40
|
-
"@instructure/ui-test-utils": "10.2.3-snapshot-
|
|
41
|
-
"@instructure/ui-themes": "10.2.3-snapshot-
|
|
38
|
+
"@instructure/ui-babel-preset": "10.2.3-snapshot-3",
|
|
39
|
+
"@instructure/ui-test-locator": "10.2.3-snapshot-3",
|
|
40
|
+
"@instructure/ui-test-utils": "10.2.3-snapshot-3",
|
|
41
|
+
"@instructure/ui-themes": "10.2.3-snapshot-3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8 <=18"
|
|
@@ -167,60 +167,147 @@ type: example
|
|
|
167
167
|
|
|
168
168
|
The `shouldAnimate` prop makes the progress bar animate the transition between value changes, giving it a smoother look.
|
|
169
169
|
|
|
170
|
-
```js
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
- ```js
|
|
171
|
+
class Example extends React.Component {
|
|
172
|
+
MIN = 0
|
|
173
|
+
MAX = 100
|
|
174
|
+
|
|
175
|
+
state = {
|
|
176
|
+
value: 25,
|
|
177
|
+
shouldAnimate: true
|
|
178
|
+
}
|
|
177
179
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
bound(n) {
|
|
181
|
+
if (n < this.MIN) return this.MIN
|
|
182
|
+
if (n > this.MAX) return this.MAX
|
|
183
|
+
return n
|
|
184
|
+
}
|
|
182
185
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return n
|
|
187
|
-
}
|
|
186
|
+
setNumber(n) {
|
|
187
|
+
return { value: this.bound(n) }
|
|
188
|
+
}
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
190
|
+
handleChange = (event, value) => {
|
|
191
|
+
const newValue = Number(value)
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
if (isNaN(newValue)) {
|
|
194
|
+
return
|
|
195
|
+
}
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
this.setState({
|
|
198
|
+
value: newValue
|
|
199
|
+
})
|
|
198
200
|
}
|
|
199
201
|
|
|
200
|
-
|
|
201
|
-
value
|
|
202
|
-
|
|
202
|
+
handleDecrement = (event) =>
|
|
203
|
+
this.setState(({ value }) => {
|
|
204
|
+
if (Number.isInteger(value)) {
|
|
205
|
+
return this.setNumber(value - 1)
|
|
206
|
+
}
|
|
207
|
+
return this.setNumber(Math.floor(value))
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
handleIncrement = (event) =>
|
|
211
|
+
this.setState(({ value }) => {
|
|
212
|
+
if (Number.isInteger(value)) {
|
|
213
|
+
return this.setNumber(value + 1)
|
|
214
|
+
}
|
|
215
|
+
return this.setNumber(Math.ceil(value))
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
handleBlur = (event) =>
|
|
219
|
+
this.setState(({ value }) => {
|
|
220
|
+
return this.setNumber(Math.round(value))
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
render() {
|
|
224
|
+
return (
|
|
225
|
+
<div>
|
|
226
|
+
<View
|
|
227
|
+
as="div"
|
|
228
|
+
background="primary"
|
|
229
|
+
padding="medium"
|
|
230
|
+
margin="0 0 large 0"
|
|
231
|
+
>
|
|
232
|
+
<FormFieldGroup
|
|
233
|
+
description={<ScreenReaderContent>Settings</ScreenReaderContent>}
|
|
234
|
+
>
|
|
235
|
+
<Checkbox
|
|
236
|
+
label="Should animate"
|
|
237
|
+
checked={this.state.shouldAnimate}
|
|
238
|
+
onChange={() => {
|
|
239
|
+
this.setState({ shouldAnimate: !this.state.shouldAnimate })
|
|
240
|
+
}}
|
|
241
|
+
variant="toggle"
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<NumberInput
|
|
245
|
+
renderLabel={`ProgressBar value (${this.MIN}-${this.MAX})`}
|
|
246
|
+
display="inline-block"
|
|
247
|
+
onBlur={this.handleBlur}
|
|
248
|
+
onChange={this.handleChange}
|
|
249
|
+
onDecrement={this.handleDecrement}
|
|
250
|
+
onIncrement={this.handleIncrement}
|
|
251
|
+
showArrows
|
|
252
|
+
value={this.state.value}
|
|
253
|
+
/>
|
|
254
|
+
</FormFieldGroup>
|
|
255
|
+
</View>
|
|
256
|
+
|
|
257
|
+
<ProgressBar
|
|
258
|
+
screenReaderLabel="Loading completion"
|
|
259
|
+
valueNow={this.state.value}
|
|
260
|
+
valueMax={this.MAX}
|
|
261
|
+
shouldAnimate={this.state.shouldAnimate}
|
|
262
|
+
/>
|
|
263
|
+
</div>
|
|
264
|
+
)
|
|
265
|
+
}
|
|
203
266
|
}
|
|
204
267
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
268
|
+
render(<Example />)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
- ```js
|
|
272
|
+
const Example = () => {
|
|
273
|
+
const MIN = 0
|
|
274
|
+
const MAX = 100
|
|
275
|
+
|
|
276
|
+
const [value, setValue] = useState(25)
|
|
277
|
+
const [shouldAnimate, setShouldAnimate] = useState(true)
|
|
278
|
+
|
|
279
|
+
const bound = (n) => {
|
|
280
|
+
if (n < MIN) return MIN
|
|
281
|
+
if (n > MAX) return MAX
|
|
282
|
+
return n
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const handleChange = (event, value) => {
|
|
286
|
+
const newValue = Number(value)
|
|
287
|
+
if (isNaN(newValue)) {
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
setValue(newValue)
|
|
208
291
|
}
|
|
209
|
-
return this.setNumber(Math.floor(value))
|
|
210
|
-
})
|
|
211
292
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
293
|
+
const handleDecrement = () => {
|
|
294
|
+
if (Number.isInteger(value)) {
|
|
295
|
+
setValue((value) => bound(value - 1))
|
|
296
|
+
}
|
|
297
|
+
setValue((value) => bound(Math.floor(value)))
|
|
215
298
|
}
|
|
216
|
-
return this.setNumber(Math.ceil(value))
|
|
217
|
-
})
|
|
218
299
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
300
|
+
const handleIncrement = () => {
|
|
301
|
+
if (Number.isInteger(value)) {
|
|
302
|
+
setValue((value) => bound(value + 1))
|
|
303
|
+
}
|
|
304
|
+
setValue((value) => bound(Math.ceil(value)))
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const handleBlur = () => {
|
|
308
|
+
setValue((value) => bound(Math.round(value)))
|
|
309
|
+
}
|
|
222
310
|
|
|
223
|
-
render() {
|
|
224
311
|
return (
|
|
225
312
|
<div>
|
|
226
313
|
<View
|
|
@@ -234,36 +321,35 @@ class Example extends React.Component {
|
|
|
234
321
|
>
|
|
235
322
|
<Checkbox
|
|
236
323
|
label="Should animate"
|
|
237
|
-
checked={
|
|
324
|
+
checked={shouldAnimate}
|
|
238
325
|
onChange={() => {
|
|
239
|
-
|
|
326
|
+
setShouldAnimate((shouldAnimate) => !shouldAnimate)
|
|
240
327
|
}}
|
|
241
328
|
variant="toggle"
|
|
242
329
|
/>
|
|
243
330
|
|
|
244
331
|
<NumberInput
|
|
245
|
-
renderLabel={`ProgressBar value (${
|
|
332
|
+
renderLabel={`ProgressBar value (${MIN}-${MAX})`}
|
|
246
333
|
display="inline-block"
|
|
247
|
-
onBlur={
|
|
248
|
-
onChange={
|
|
249
|
-
onDecrement={
|
|
250
|
-
onIncrement={
|
|
334
|
+
onBlur={handleBlur}
|
|
335
|
+
onChange={handleChange}
|
|
336
|
+
onDecrement={handleDecrement}
|
|
337
|
+
onIncrement={handleIncrement}
|
|
251
338
|
showArrows
|
|
252
|
-
value={
|
|
339
|
+
value={value}
|
|
253
340
|
/>
|
|
254
341
|
</FormFieldGroup>
|
|
255
342
|
</View>
|
|
256
343
|
|
|
257
344
|
<ProgressBar
|
|
258
345
|
screenReaderLabel="Loading completion"
|
|
259
|
-
valueNow={
|
|
260
|
-
valueMax={
|
|
261
|
-
shouldAnimate={
|
|
346
|
+
valueNow={value}
|
|
347
|
+
valueMax={MAX}
|
|
348
|
+
shouldAnimate={shouldAnimate}
|
|
262
349
|
/>
|
|
263
350
|
</div>
|
|
264
351
|
)
|
|
265
352
|
}
|
|
266
|
-
}
|
|
267
353
|
|
|
268
|
-
render(<Example />)
|
|
269
|
-
```
|
|
354
|
+
render(<Example />)
|
|
355
|
+
```
|