@instructure/ui-progress 8.36.1-snapshot-18 → 8.36.1-snapshot-24
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 +10 -2
- package/es/ProgressBar/__examples__/ProgressBar.examples.js +1 -0
- package/es/ProgressBar/index.js +11 -5
- package/es/ProgressBar/props.js +2 -1
- package/es/ProgressBar/styles.js +35 -34
- package/lib/ProgressBar/__examples__/ProgressBar.examples.js +1 -0
- package/lib/ProgressBar/index.js +10 -5
- package/lib/ProgressBar/props.js +2 -1
- package/lib/ProgressBar/styles.js +35 -34
- package/package.json +13 -13
- package/src/ProgressBar/README.md +106 -0
- package/src/ProgressBar/__examples__/ProgressBar.examples.tsx +1 -0
- package/src/ProgressBar/index.tsx +8 -4
- package/src/ProgressBar/props.ts +23 -1
- package/src/ProgressBar/styles.ts +44 -39
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ProgressBar/__examples__/ProgressBar.examples.d.ts.map +1 -1
- package/types/ProgressBar/index.d.ts +3 -0
- package/types/ProgressBar/index.d.ts.map +1 -1
- package/types/ProgressBar/props.d.ts +5 -1
- package/types/ProgressBar/props.d.ts.map +1 -1
- package/types/ProgressBar/styles.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,17 @@
|
|
|
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
|
-
## [8.36.1-snapshot-
|
|
6
|
+
## [8.36.1-snapshot-24](https://github.com/instructure/instructure-ui/compare/v8.36.0...v8.36.1-snapshot-24) (2023-04-21)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-progress:** fix ProgressBar `info` and `success` color in inverse mode ([920fa49](https://github.com/instructure/instructure-ui/commit/920fa49e89f7796faf8a527781a44c6f63f26bac))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **ui-progress:** add `shouldAnimate` prop to ProgressBar ([c528956](https://github.com/instructure/instructure-ui/commit/c528956f81c96df52b07b9dc59ae1e137307c780))
|
|
9
17
|
|
|
10
18
|
|
|
11
19
|
|
package/es/ProgressBar/index.js
CHANGED
|
@@ -24,6 +24,7 @@ var _dec, _dec2, _class, _class2;
|
|
|
24
24
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
|
+
|
|
27
28
|
/** @jsx jsx */
|
|
28
29
|
import { Component } from 'react';
|
|
29
30
|
import { View } from '@instructure/ui-view';
|
|
@@ -93,10 +94,8 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
93
94
|
elementRef: this.handleRef
|
|
94
95
|
}), jsx("span", {
|
|
95
96
|
css: styles === null || styles === void 0 ? void 0 : styles.trackLayout
|
|
96
|
-
}, jsx("
|
|
97
|
-
css: styles === null || styles === void 0 ? void 0 : styles.
|
|
98
|
-
}), jsx("progress", {
|
|
99
|
-
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
97
|
+
}, jsx("progress", {
|
|
98
|
+
css: styles === null || styles === void 0 ? void 0 : styles.htmlProgress,
|
|
100
99
|
max: valueMax,
|
|
101
100
|
value: valueNow,
|
|
102
101
|
role: "progressbar",
|
|
@@ -104,7 +103,13 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
104
103
|
"aria-valuenow": valueNow,
|
|
105
104
|
"aria-valuemax": valueMax,
|
|
106
105
|
"aria-label": labelAndValueText
|
|
107
|
-
})
|
|
106
|
+
}), jsx("span", {
|
|
107
|
+
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
108
|
+
role: "presentation",
|
|
109
|
+
"aria-hidden": "true"
|
|
110
|
+
}, jsx("span", {
|
|
111
|
+
css: styles === null || styles === void 0 ? void 0 : styles.trackValue
|
|
112
|
+
}))), value && jsx("span", {
|
|
108
113
|
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
109
114
|
"aria-hidden": "true"
|
|
110
115
|
}, value));
|
|
@@ -120,6 +125,7 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
120
125
|
valueNow: 0,
|
|
121
126
|
as: 'div',
|
|
122
127
|
color: 'primary',
|
|
128
|
+
shouldAnimate: false,
|
|
123
129
|
// default to showing `success` color on completion
|
|
124
130
|
meterColor: _ref2 => {
|
|
125
131
|
let valueNow = _ref2.valueNow,
|
package/es/ProgressBar/props.js
CHANGED
|
@@ -32,9 +32,10 @@ const propTypes = {
|
|
|
32
32
|
renderValue: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
33
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
34
34
|
meterColor: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])]),
|
|
35
|
+
shouldAnimate: PropTypes.bool,
|
|
35
36
|
margin: ThemeablePropTypes.spacing,
|
|
36
37
|
elementRef: PropTypes.func,
|
|
37
38
|
as: PropTypes.elementType
|
|
38
39
|
};
|
|
39
|
-
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'margin', 'elementRef', 'as'];
|
|
40
|
+
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'shouldAnimate', 'margin', 'elementRef', 'as'];
|
|
40
41
|
export { propTypes, allowedProps };
|
package/es/ProgressBar/styles.js
CHANGED
|
@@ -39,11 +39,14 @@ const generateStyle = (componentTheme, props) => {
|
|
|
39
39
|
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax,
|
|
40
40
|
size = props.size,
|
|
41
41
|
color = props.color,
|
|
42
|
-
meterColor = props.meterColor
|
|
42
|
+
meterColor = props.meterColor,
|
|
43
|
+
shouldAnimate = props.shouldAnimate;
|
|
43
44
|
const meterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
44
45
|
valueNow,
|
|
45
46
|
valueMax
|
|
46
47
|
}) : meterColor;
|
|
48
|
+
const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
|
|
49
|
+
const currentValuePercent = `${currentValue / valueMax * 100}%`;
|
|
47
50
|
const sizeVariants = {
|
|
48
51
|
'x-small': {
|
|
49
52
|
track: {
|
|
@@ -123,9 +126,11 @@ const generateStyle = (componentTheme, props) => {
|
|
|
123
126
|
background: componentTheme.meterColorBrandInverse
|
|
124
127
|
},
|
|
125
128
|
info: {
|
|
129
|
+
background: componentTheme.meterColorInfoInverse
|
|
130
|
+
},
|
|
131
|
+
success: {
|
|
126
132
|
background: componentTheme.meterColorSuccessInverse
|
|
127
133
|
},
|
|
128
|
-
success: {},
|
|
129
134
|
danger: {
|
|
130
135
|
background: componentTheme.meterColorDangerInverse
|
|
131
136
|
},
|
|
@@ -153,44 +158,28 @@ const generateStyle = (componentTheme, props) => {
|
|
|
153
158
|
flex: 1,
|
|
154
159
|
...colorVariants[color].trackLayout
|
|
155
160
|
},
|
|
156
|
-
|
|
157
|
-
label: '
|
|
161
|
+
track: {
|
|
162
|
+
label: 'progressBar__track',
|
|
158
163
|
display: 'block',
|
|
159
|
-
position: 'absolute',
|
|
160
|
-
top: '0',
|
|
161
|
-
left: '0',
|
|
162
|
-
width: '100%',
|
|
163
|
-
height: '100%',
|
|
164
164
|
boxSizing: 'border-box',
|
|
165
|
+
width: '100%',
|
|
165
166
|
borderBottomWidth: componentTheme.trackBottomBorderWidth,
|
|
166
167
|
borderBottomStyle: 'solid',
|
|
168
|
+
background: 'transparent',
|
|
169
|
+
...sizeVariants[size].track,
|
|
167
170
|
...colorVariants[color].trackBorder
|
|
168
171
|
},
|
|
169
|
-
|
|
170
|
-
label: '
|
|
171
|
-
'
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
'&::-webkit-progress-bar': {
|
|
181
|
-
background: 'transparent'
|
|
182
|
-
},
|
|
183
|
-
'&::-webkit-progress-value': {
|
|
184
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
185
|
-
},
|
|
186
|
-
'&::-moz-progress-bar': {
|
|
187
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
188
|
-
},
|
|
189
|
-
'&::-ms-fill': {
|
|
190
|
-
border: 'none',
|
|
191
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
192
|
-
}
|
|
193
|
-
}
|
|
172
|
+
trackValue: {
|
|
173
|
+
label: 'progressBar__trackValue',
|
|
174
|
+
display: 'block',
|
|
175
|
+
boxSizing: 'border-box',
|
|
176
|
+
height: '100%',
|
|
177
|
+
width: currentValuePercent,
|
|
178
|
+
maxWidth: '100%',
|
|
179
|
+
...(shouldAnimate && {
|
|
180
|
+
transition: 'all 0.5s'
|
|
181
|
+
}),
|
|
182
|
+
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
194
183
|
},
|
|
195
184
|
value: {
|
|
196
185
|
label: 'progressBar__value',
|
|
@@ -199,6 +188,18 @@ const generateStyle = (componentTheme, props) => {
|
|
|
199
188
|
paddingInlineStart: componentTheme.valuePadding,
|
|
200
189
|
flex: '0 0 5.625rem',
|
|
201
190
|
...sizeVariants[size].value
|
|
191
|
+
},
|
|
192
|
+
htmlProgress: {
|
|
193
|
+
label: 'progressBar__htmlProgress',
|
|
194
|
+
display: 'block',
|
|
195
|
+
position: 'absolute',
|
|
196
|
+
top: '0',
|
|
197
|
+
left: '0',
|
|
198
|
+
width: '100%',
|
|
199
|
+
height: '100%',
|
|
200
|
+
boxSizing: 'border-box',
|
|
201
|
+
zIndex: -1,
|
|
202
|
+
opacity: 0
|
|
202
203
|
}
|
|
203
204
|
};
|
|
204
205
|
};
|
package/lib/ProgressBar/index.js
CHANGED
|
@@ -100,10 +100,8 @@ let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
100
100
|
elementRef: this.handleRef
|
|
101
101
|
}), (0, _emotion.jsx)("span", {
|
|
102
102
|
css: styles === null || styles === void 0 ? void 0 : styles.trackLayout
|
|
103
|
-
}, (0, _emotion.jsx)("
|
|
104
|
-
css: styles === null || styles === void 0 ? void 0 : styles.
|
|
105
|
-
}), (0, _emotion.jsx)("progress", {
|
|
106
|
-
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
103
|
+
}, (0, _emotion.jsx)("progress", {
|
|
104
|
+
css: styles === null || styles === void 0 ? void 0 : styles.htmlProgress,
|
|
107
105
|
max: valueMax,
|
|
108
106
|
value: valueNow,
|
|
109
107
|
role: "progressbar",
|
|
@@ -111,7 +109,13 @@ let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
111
109
|
"aria-valuenow": valueNow,
|
|
112
110
|
"aria-valuemax": valueMax,
|
|
113
111
|
"aria-label": labelAndValueText
|
|
114
|
-
})
|
|
112
|
+
}), (0, _emotion.jsx)("span", {
|
|
113
|
+
css: styles === null || styles === void 0 ? void 0 : styles.track,
|
|
114
|
+
role: "presentation",
|
|
115
|
+
"aria-hidden": "true"
|
|
116
|
+
}, (0, _emotion.jsx)("span", {
|
|
117
|
+
css: styles === null || styles === void 0 ? void 0 : styles.trackValue
|
|
118
|
+
}))), value && (0, _emotion.jsx)("span", {
|
|
115
119
|
css: styles === null || styles === void 0 ? void 0 : styles.value,
|
|
116
120
|
"aria-hidden": "true"
|
|
117
121
|
}, value));
|
|
@@ -127,6 +131,7 @@ let ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
|
|
|
127
131
|
valueNow: 0,
|
|
128
132
|
as: 'div',
|
|
129
133
|
color: 'primary',
|
|
134
|
+
shouldAnimate: false,
|
|
130
135
|
// default to showing `success` color on completion
|
|
131
136
|
meterColor: _ref2 => {
|
|
132
137
|
let valueNow = _ref2.valueNow,
|
package/lib/ProgressBar/props.js
CHANGED
|
@@ -40,10 +40,11 @@ const propTypes = {
|
|
|
40
40
|
renderValue: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
|
41
41
|
color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
|
|
42
42
|
meterColor: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])]),
|
|
43
|
+
shouldAnimate: _propTypes.default.bool,
|
|
43
44
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
44
45
|
elementRef: _propTypes.default.func,
|
|
45
46
|
as: _propTypes.default.elementType
|
|
46
47
|
};
|
|
47
48
|
exports.propTypes = propTypes;
|
|
48
|
-
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'margin', 'elementRef', 'as'];
|
|
49
|
+
const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'shouldAnimate', 'margin', 'elementRef', 'as'];
|
|
49
50
|
exports.allowedProps = allowedProps;
|
|
@@ -45,11 +45,14 @@ const generateStyle = (componentTheme, props) => {
|
|
|
45
45
|
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax,
|
|
46
46
|
size = props.size,
|
|
47
47
|
color = props.color,
|
|
48
|
-
meterColor = props.meterColor
|
|
48
|
+
meterColor = props.meterColor,
|
|
49
|
+
shouldAnimate = props.shouldAnimate;
|
|
49
50
|
const meterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
50
51
|
valueNow,
|
|
51
52
|
valueMax
|
|
52
53
|
}) : meterColor;
|
|
54
|
+
const currentValue = valueNow > valueMax ? valueMax : valueNow < 0 ? 0 : valueNow;
|
|
55
|
+
const currentValuePercent = `${currentValue / valueMax * 100}%`;
|
|
53
56
|
const sizeVariants = {
|
|
54
57
|
'x-small': {
|
|
55
58
|
track: {
|
|
@@ -129,9 +132,11 @@ const generateStyle = (componentTheme, props) => {
|
|
|
129
132
|
background: componentTheme.meterColorBrandInverse
|
|
130
133
|
},
|
|
131
134
|
info: {
|
|
135
|
+
background: componentTheme.meterColorInfoInverse
|
|
136
|
+
},
|
|
137
|
+
success: {
|
|
132
138
|
background: componentTheme.meterColorSuccessInverse
|
|
133
139
|
},
|
|
134
|
-
success: {},
|
|
135
140
|
danger: {
|
|
136
141
|
background: componentTheme.meterColorDangerInverse
|
|
137
142
|
},
|
|
@@ -159,44 +164,28 @@ const generateStyle = (componentTheme, props) => {
|
|
|
159
164
|
flex: 1,
|
|
160
165
|
...colorVariants[color].trackLayout
|
|
161
166
|
},
|
|
162
|
-
|
|
163
|
-
label: '
|
|
167
|
+
track: {
|
|
168
|
+
label: 'progressBar__track',
|
|
164
169
|
display: 'block',
|
|
165
|
-
position: 'absolute',
|
|
166
|
-
top: '0',
|
|
167
|
-
left: '0',
|
|
168
|
-
width: '100%',
|
|
169
|
-
height: '100%',
|
|
170
170
|
boxSizing: 'border-box',
|
|
171
|
+
width: '100%',
|
|
171
172
|
borderBottomWidth: componentTheme.trackBottomBorderWidth,
|
|
172
173
|
borderBottomStyle: 'solid',
|
|
174
|
+
background: 'transparent',
|
|
175
|
+
...sizeVariants[size].track,
|
|
173
176
|
...colorVariants[color].trackBorder
|
|
174
177
|
},
|
|
175
|
-
|
|
176
|
-
label: '
|
|
177
|
-
'
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'&::-webkit-progress-bar': {
|
|
187
|
-
background: 'transparent'
|
|
188
|
-
},
|
|
189
|
-
'&::-webkit-progress-value': {
|
|
190
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
191
|
-
},
|
|
192
|
-
'&::-moz-progress-bar': {
|
|
193
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
194
|
-
},
|
|
195
|
-
'&::-ms-fill': {
|
|
196
|
-
border: 'none',
|
|
197
|
-
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
198
|
-
}
|
|
199
|
-
}
|
|
178
|
+
trackValue: {
|
|
179
|
+
label: 'progressBar__trackValue',
|
|
180
|
+
display: 'block',
|
|
181
|
+
boxSizing: 'border-box',
|
|
182
|
+
height: '100%',
|
|
183
|
+
width: currentValuePercent,
|
|
184
|
+
maxWidth: '100%',
|
|
185
|
+
...(shouldAnimate && {
|
|
186
|
+
transition: 'all 0.5s'
|
|
187
|
+
}),
|
|
188
|
+
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
200
189
|
},
|
|
201
190
|
value: {
|
|
202
191
|
label: 'progressBar__value',
|
|
@@ -205,6 +194,18 @@ const generateStyle = (componentTheme, props) => {
|
|
|
205
194
|
paddingInlineStart: componentTheme.valuePadding,
|
|
206
195
|
flex: '0 0 5.625rem',
|
|
207
196
|
...sizeVariants[size].value
|
|
197
|
+
},
|
|
198
|
+
htmlProgress: {
|
|
199
|
+
label: 'progressBar__htmlProgress',
|
|
200
|
+
display: 'block',
|
|
201
|
+
position: 'absolute',
|
|
202
|
+
top: '0',
|
|
203
|
+
left: '0',
|
|
204
|
+
width: '100%',
|
|
205
|
+
height: '100%',
|
|
206
|
+
boxSizing: 'border-box',
|
|
207
|
+
zIndex: -1,
|
|
208
|
+
opacity: 0
|
|
208
209
|
}
|
|
209
210
|
};
|
|
210
211
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-progress",
|
|
3
|
-
"version": "8.36.1-snapshot-
|
|
3
|
+
"version": "8.36.1-snapshot-24",
|
|
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.21.0",
|
|
27
|
-
"@instructure/console": "8.36.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "8.36.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "8.36.1-snapshot-
|
|
30
|
-
"@instructure/ui-a11y-content": "8.36.1-snapshot-
|
|
31
|
-
"@instructure/ui-color-utils": "8.36.1-snapshot-
|
|
32
|
-
"@instructure/ui-react-utils": "8.36.1-snapshot-
|
|
33
|
-
"@instructure/ui-testable": "8.36.1-snapshot-
|
|
34
|
-
"@instructure/ui-view": "8.36.1-snapshot-
|
|
27
|
+
"@instructure/console": "8.36.1-snapshot-24",
|
|
28
|
+
"@instructure/emotion": "8.36.1-snapshot-24",
|
|
29
|
+
"@instructure/shared-types": "8.36.1-snapshot-24",
|
|
30
|
+
"@instructure/ui-a11y-content": "8.36.1-snapshot-24",
|
|
31
|
+
"@instructure/ui-color-utils": "8.36.1-snapshot-24",
|
|
32
|
+
"@instructure/ui-react-utils": "8.36.1-snapshot-24",
|
|
33
|
+
"@instructure/ui-testable": "8.36.1-snapshot-24",
|
|
34
|
+
"@instructure/ui-view": "8.36.1-snapshot-24",
|
|
35
35
|
"prop-types": "^15.8.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@instructure/ui-babel-preset": "8.36.1-snapshot-
|
|
39
|
-
"@instructure/ui-test-locator": "8.36.1-snapshot-
|
|
40
|
-
"@instructure/ui-test-utils": "8.36.1-snapshot-
|
|
41
|
-
"@instructure/ui-themes": "8.36.1-snapshot-
|
|
38
|
+
"@instructure/ui-babel-preset": "8.36.1-snapshot-24",
|
|
39
|
+
"@instructure/ui-test-locator": "8.36.1-snapshot-24",
|
|
40
|
+
"@instructure/ui-test-utils": "8.36.1-snapshot-24",
|
|
41
|
+
"@instructure/ui-themes": "8.36.1-snapshot-24"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.8 <=18"
|
|
@@ -162,3 +162,109 @@ example: true
|
|
|
162
162
|
valueNow={33}
|
|
163
163
|
/>
|
|
164
164
|
```
|
|
165
|
+
|
|
166
|
+
### `shouldAnimate`
|
|
167
|
+
|
|
168
|
+
The `shouldAnimate` prop makes the progress bar animate the transition between value changes, giving it a smoother look.
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
---
|
|
172
|
+
example: true
|
|
173
|
+
render: false
|
|
174
|
+
---
|
|
175
|
+
class Example extends React.Component {
|
|
176
|
+
MIN = 0
|
|
177
|
+
MAX = 100
|
|
178
|
+
|
|
179
|
+
state = {
|
|
180
|
+
value: 25,
|
|
181
|
+
shouldAnimate: true
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
bound (n) {
|
|
185
|
+
if (n < this.MIN) return this.MIN
|
|
186
|
+
if (n > this.MAX) return this.MAX
|
|
187
|
+
return n
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
setNumber (n) {
|
|
191
|
+
return { value: this.bound(n) }
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
handleChange = (event, value) => {
|
|
195
|
+
const newValue = Number(value)
|
|
196
|
+
|
|
197
|
+
if (isNaN(newValue)) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.setState({
|
|
202
|
+
value: newValue
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
handleDecrement = (event) => this.setState(({ value }) => {
|
|
207
|
+
if (Number.isInteger(value)) {
|
|
208
|
+
return this.setNumber(value - 1)
|
|
209
|
+
}
|
|
210
|
+
return this.setNumber(Math.floor(value))
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
handleIncrement = (event) => this.setState(({ value }) => {
|
|
214
|
+
if (Number.isInteger(value)) {
|
|
215
|
+
return this.setNumber(value + 1)
|
|
216
|
+
}
|
|
217
|
+
return this.setNumber(Math.ceil(value))
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
handleBlur = (event) => this.setState(({ value }) => {
|
|
221
|
+
return this.setNumber(Math.round(value))
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
render() {
|
|
225
|
+
return (
|
|
226
|
+
<div>
|
|
227
|
+
<View
|
|
228
|
+
as="div"
|
|
229
|
+
background="primary"
|
|
230
|
+
padding="medium"
|
|
231
|
+
margin="0 0 large 0"
|
|
232
|
+
>
|
|
233
|
+
<FormFieldGroup
|
|
234
|
+
description={<ScreenReaderContent>Settings</ScreenReaderContent>}
|
|
235
|
+
>
|
|
236
|
+
<Checkbox
|
|
237
|
+
label="Should animate"
|
|
238
|
+
checked={this.state.shouldAnimate}
|
|
239
|
+
onChange={() => {
|
|
240
|
+
this.setState({ shouldAnimate: !this.state.shouldAnimate })
|
|
241
|
+
}}
|
|
242
|
+
variant="toggle"
|
|
243
|
+
/>
|
|
244
|
+
|
|
245
|
+
<NumberInput
|
|
246
|
+
renderLabel={`ProgressBar value (${this.MIN}-${this.MAX})`}
|
|
247
|
+
display="inline-block"
|
|
248
|
+
onBlur={this.handleBlur}
|
|
249
|
+
onChange={this.handleChange}
|
|
250
|
+
onDecrement={this.handleDecrement}
|
|
251
|
+
onIncrement={this.handleIncrement}
|
|
252
|
+
showArrows
|
|
253
|
+
value={this.state.value}
|
|
254
|
+
/>
|
|
255
|
+
</FormFieldGroup>
|
|
256
|
+
</View>
|
|
257
|
+
|
|
258
|
+
<ProgressBar
|
|
259
|
+
screenReaderLabel="Loading completion"
|
|
260
|
+
valueNow={this.state.value}
|
|
261
|
+
valueMax={this.MAX}
|
|
262
|
+
shouldAnimate={this.state.shouldAnimate}
|
|
263
|
+
/>
|
|
264
|
+
</div>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
render(<Example />)
|
|
270
|
+
```
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
/** @jsx jsx */
|
|
25
26
|
import { Component } from 'react'
|
|
26
27
|
|
|
@@ -32,6 +33,7 @@ import { withStyle, jsx } from '@instructure/emotion'
|
|
|
32
33
|
|
|
33
34
|
import generateStyle from './styles'
|
|
34
35
|
import generateComponentTheme from './theme'
|
|
36
|
+
|
|
35
37
|
import type { ProgressBarProps, Values } from './props'
|
|
36
38
|
import { allowedProps, propTypes } from './props'
|
|
37
39
|
|
|
@@ -57,6 +59,7 @@ class ProgressBar extends Component<ProgressBarProps> {
|
|
|
57
59
|
valueNow: 0,
|
|
58
60
|
as: 'div',
|
|
59
61
|
color: 'primary',
|
|
62
|
+
shouldAnimate: false,
|
|
60
63
|
|
|
61
64
|
// default to showing `success` color on completion
|
|
62
65
|
meterColor: ({ valueNow, valueMax }: Values) =>
|
|
@@ -121,11 +124,8 @@ class ProgressBar extends Component<ProgressBarProps> {
|
|
|
121
124
|
elementRef={this.handleRef}
|
|
122
125
|
>
|
|
123
126
|
<span css={styles?.trackLayout}>
|
|
124
|
-
{/* creates bottom border effect - <progress /> hard to style x-browser */}
|
|
125
|
-
<span css={styles?.trackBorder}></span>
|
|
126
|
-
|
|
127
127
|
<progress
|
|
128
|
-
css={styles?.
|
|
128
|
+
css={styles?.htmlProgress}
|
|
129
129
|
max={valueMax}
|
|
130
130
|
value={valueNow}
|
|
131
131
|
role="progressbar"
|
|
@@ -134,6 +134,10 @@ class ProgressBar extends Component<ProgressBarProps> {
|
|
|
134
134
|
aria-valuemax={valueMax}
|
|
135
135
|
aria-label={labelAndValueText}
|
|
136
136
|
/>
|
|
137
|
+
|
|
138
|
+
<span css={styles?.track} role="presentation" aria-hidden="true">
|
|
139
|
+
<span css={styles?.trackValue}></span>
|
|
140
|
+
</span>
|
|
137
141
|
</span>
|
|
138
142
|
|
|
139
143
|
{value && (
|
package/src/ProgressBar/props.ts
CHANGED
|
@@ -53,31 +53,38 @@ type ProgressBarOwnProps = {
|
|
|
53
53
|
* A label is required for accessibility
|
|
54
54
|
*/
|
|
55
55
|
screenReaderLabel: string
|
|
56
|
+
|
|
56
57
|
/**
|
|
57
58
|
* Control the height of the progress bar
|
|
58
59
|
*/
|
|
59
60
|
size?: 'x-small' | 'small' | 'medium' | 'large'
|
|
61
|
+
|
|
60
62
|
/**
|
|
61
63
|
* Maximum value (defaults to 100)
|
|
62
64
|
*/
|
|
63
65
|
valueMax?: Values['valueMax']
|
|
66
|
+
|
|
64
67
|
/**
|
|
65
68
|
* Receives the progress of the event
|
|
66
69
|
*/
|
|
67
70
|
valueNow?: Values['valueNow']
|
|
71
|
+
|
|
68
72
|
/**
|
|
69
73
|
* A function for formatting the text provided to screen readers via `aria-valuenow`
|
|
70
74
|
*/
|
|
71
75
|
formatScreenReaderValue?: (values: Values) => string
|
|
76
|
+
|
|
72
77
|
/**
|
|
73
78
|
* A function to format the displayed value. If null the value will not display.
|
|
74
79
|
* Takes `valueNow` and `valueMax` as parameters.
|
|
75
80
|
*/
|
|
76
81
|
renderValue?: Renderable<Values>
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
84
|
* Controls the overall color scheme of the component
|
|
79
85
|
*/
|
|
80
86
|
color?: 'primary' | 'primary-inverse'
|
|
87
|
+
|
|
81
88
|
/**
|
|
82
89
|
* Control the color of the progress meter. Defaults to showing theme success
|
|
83
90
|
* color on completion, based on `valueNow` and `valueMax`.
|
|
@@ -85,16 +92,24 @@ type ProgressBarOwnProps = {
|
|
|
85
92
|
meterColor?:
|
|
86
93
|
| ((values: Values) => ProgressBarMeterColor)
|
|
87
94
|
| ProgressBarMeterColor
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Whether the change of value should have a transition
|
|
98
|
+
*/
|
|
99
|
+
shouldAnimate?: boolean
|
|
100
|
+
|
|
88
101
|
/**
|
|
89
102
|
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
90
103
|
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
91
104
|
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
92
105
|
*/
|
|
93
106
|
margin?: Spacing
|
|
107
|
+
|
|
94
108
|
/**
|
|
95
109
|
* Provides a reference to the component's root HTML element
|
|
96
110
|
*/
|
|
97
111
|
elementRef?: (element: Element | null) => void
|
|
112
|
+
|
|
98
113
|
/**
|
|
99
114
|
* Set the element type of the component's root
|
|
100
115
|
*/
|
|
@@ -110,7 +125,12 @@ type ProgressBarProps = ProgressBarOwnProps &
|
|
|
110
125
|
OtherHTMLAttributes<ProgressBarOwnProps>
|
|
111
126
|
|
|
112
127
|
type ProgressBarStyle = ComponentStyle<
|
|
113
|
-
|
|
128
|
+
| 'progressBar'
|
|
129
|
+
| 'trackLayout'
|
|
130
|
+
| 'track'
|
|
131
|
+
| 'trackValue'
|
|
132
|
+
| 'value'
|
|
133
|
+
| 'htmlProgress'
|
|
114
134
|
>
|
|
115
135
|
|
|
116
136
|
const propTypes: PropValidators<PropKeys> = {
|
|
@@ -125,6 +145,7 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
125
145
|
PropTypes.func,
|
|
126
146
|
PropTypes.oneOf(['info', 'warning', 'danger', 'alert', 'success', 'brand'])
|
|
127
147
|
]),
|
|
148
|
+
shouldAnimate: PropTypes.bool,
|
|
128
149
|
margin: ThemeablePropTypes.spacing,
|
|
129
150
|
elementRef: PropTypes.func,
|
|
130
151
|
as: PropTypes.elementType
|
|
@@ -139,6 +160,7 @@ const allowedProps: AllowedPropKeys = [
|
|
|
139
160
|
'renderValue',
|
|
140
161
|
'color',
|
|
141
162
|
'meterColor',
|
|
163
|
+
'shouldAnimate',
|
|
142
164
|
'margin',
|
|
143
165
|
'elementRef',
|
|
144
166
|
'as'
|