@instructure/ui-progress 8.33.1 → 8.33.2-snapshot-5
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 +8 -0
- package/es/ProgressBar/ProgressBarLocator.js +2 -1
- package/es/ProgressBar/__examples__/ProgressBar.examples.js +2 -1
- package/es/ProgressBar/index.js +16 -28
- package/es/ProgressBar/styles.js +10 -9
- package/es/ProgressBar/theme.js +6 -6
- package/es/ProgressCircle/ProgressCircleLocator.js +2 -1
- package/es/ProgressCircle/__examples__/ProgressCircle.examples.js +2 -1
- package/es/ProgressCircle/index.js +15 -31
- package/es/ProgressCircle/styles.js +11 -17
- package/es/ProgressCircle/theme.js +9 -10
- package/es/index.js +1 -0
- package/lib/ProgressBar/ProgressBarLocator.js +1 -3
- package/lib/ProgressBar/__examples__/ProgressBar.examples.js +2 -4
- package/lib/ProgressBar/index.js +15 -37
- package/lib/ProgressBar/locator.js +0 -2
- package/lib/ProgressBar/props.js +1 -4
- package/lib/ProgressBar/styles.js +10 -10
- package/lib/ProgressBar/theme.js +6 -7
- package/lib/ProgressCircle/ProgressCircleLocator.js +1 -3
- package/lib/ProgressCircle/__examples__/ProgressCircle.examples.js +2 -4
- package/lib/ProgressCircle/index.js +14 -42
- package/lib/ProgressCircle/locator.js +0 -2
- package/lib/ProgressCircle/props.js +1 -4
- package/lib/ProgressCircle/styles.js +11 -18
- package/lib/ProgressCircle/theme.js +9 -11
- package/lib/index.js +0 -2
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.33.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-5) (2023-01-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-progress
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-progress
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { ProgressBar } from './index';
|
|
25
|
+
import { ProgressBar } from './index';
|
|
26
26
|
|
|
27
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
28
|
export const ProgressBarLocator = locator(ProgressBar.selector);
|
|
@@ -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
|
import React from 'react';
|
|
25
26
|
const valueMax = 100;
|
|
26
27
|
export default {
|
|
@@ -29,7 +30,7 @@ export default {
|
|
|
29
30
|
valueNow: [0, 40, 80, 100],
|
|
30
31
|
renderValue: [null, _ref => {
|
|
31
32
|
let valueNow = _ref.valueNow,
|
|
32
|
-
|
|
33
|
+
valueMax = _ref.valueMax;
|
|
33
34
|
return /*#__PURE__*/React.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
34
35
|
}]
|
|
35
36
|
},
|
package/es/ProgressBar/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "styles"];
|
|
3
|
-
|
|
4
3
|
var _dec, _dec2, _class, _class2;
|
|
5
|
-
|
|
6
4
|
/*
|
|
7
5
|
* The MIT License (MIT)
|
|
8
6
|
*
|
|
@@ -26,7 +24,6 @@ var _dec, _dec2, _class, _class2;
|
|
|
26
24
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
25
|
* SOFTWARE.
|
|
28
26
|
*/
|
|
29
|
-
|
|
30
27
|
/** @jsx jsx */
|
|
31
28
|
import { Component } from 'react';
|
|
32
29
|
import { View } from '@instructure/ui-view';
|
|
@@ -36,67 +33,59 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
36
33
|
import generateStyle from './styles';
|
|
37
34
|
import generateComponentTheme from './theme';
|
|
38
35
|
import { allowedProps, propTypes } from './props';
|
|
36
|
+
|
|
39
37
|
/**
|
|
40
38
|
---
|
|
41
39
|
category: components
|
|
42
40
|
---
|
|
43
41
|
@tsProps
|
|
44
42
|
**/
|
|
45
|
-
|
|
46
43
|
let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ProgressBar extends Component {
|
|
47
44
|
constructor() {
|
|
48
45
|
super(...arguments);
|
|
49
46
|
this.ref = null;
|
|
50
|
-
|
|
51
47
|
this.handleRef = el => {
|
|
52
48
|
const elementRef = this.props.elementRef;
|
|
53
49
|
this.ref = el;
|
|
54
|
-
|
|
55
50
|
if (typeof elementRef === 'function') {
|
|
56
51
|
elementRef(el);
|
|
57
52
|
}
|
|
58
53
|
};
|
|
59
54
|
}
|
|
60
|
-
|
|
61
55
|
componentDidMount() {
|
|
62
56
|
var _this$props$makeStyle, _this$props;
|
|
63
|
-
|
|
64
57
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
65
58
|
}
|
|
66
|
-
|
|
67
59
|
componentDidUpdate() {
|
|
68
60
|
var _this$props$makeStyle2, _this$props2;
|
|
69
|
-
|
|
70
61
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
71
62
|
}
|
|
72
|
-
|
|
73
63
|
render() {
|
|
74
64
|
const _this$props3 = this.props,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
65
|
+
renderValue = _this$props3.renderValue,
|
|
66
|
+
formatScreenReaderValue = _this$props3.formatScreenReaderValue,
|
|
67
|
+
valueNow = _this$props3.valueNow,
|
|
68
|
+
valueMax = _this$props3.valueMax,
|
|
69
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
70
|
+
size = _this$props3.size,
|
|
71
|
+
color = _this$props3.color,
|
|
72
|
+
meterColor = _this$props3.meterColor,
|
|
73
|
+
styles = _this$props3.styles,
|
|
74
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
86
75
|
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
87
76
|
valueNow: valueNow,
|
|
88
77
|
valueMax: valueMax
|
|
89
|
-
}) : void 0;
|
|
78
|
+
}) : void 0;
|
|
79
|
+
// consolidating the label and aria-valuetext to put in aria-label because
|
|
90
80
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
91
81
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
92
|
-
|
|
93
82
|
const labelAndValueText = `${screenReaderLabel} ${valueText}`;
|
|
94
83
|
const value = callRenderProp(renderValue, {
|
|
95
84
|
valueNow: valueNow,
|
|
96
85
|
valueMax: valueMax
|
|
97
86
|
});
|
|
98
|
-
/* eslint-disable jsx-a11y/no-redundant-roles, jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
99
87
|
|
|
88
|
+
/* eslint-disable jsx-a11y/no-redundant-roles, jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
100
89
|
return jsx(View, Object.assign({}, passthroughProps(props), {
|
|
101
90
|
as: this.props.as,
|
|
102
91
|
css: styles === null || styles === void 0 ? void 0 : styles.progressBar,
|
|
@@ -120,11 +109,10 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
120
109
|
"aria-hidden": "true"
|
|
121
110
|
}, value));
|
|
122
111
|
}
|
|
123
|
-
|
|
124
112
|
}, _class2.displayName = "ProgressBar", _class2.componentId = 'ProgressBar', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
125
113
|
formatScreenReaderValue: _ref => {
|
|
126
114
|
let valueNow = _ref.valueNow,
|
|
127
|
-
|
|
115
|
+
valueMax = _ref.valueMax;
|
|
128
116
|
return `${valueNow} / ${valueMax}`;
|
|
129
117
|
},
|
|
130
118
|
size: 'medium',
|
|
@@ -135,7 +123,7 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
135
123
|
// default to showing `success` color on completion
|
|
136
124
|
meterColor: _ref2 => {
|
|
137
125
|
let valueNow = _ref2.valueNow,
|
|
138
|
-
|
|
126
|
+
valueMax = _ref2.valueMax;
|
|
139
127
|
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
140
128
|
}
|
|
141
129
|
}, _class2)) || _class) || _class);
|
package/es/ProgressBar/styles.js
CHANGED
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const _props$valueNow = props.valueNow,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
valueNow = _props$valueNow === void 0 ? 0 : _props$valueNow,
|
|
38
|
+
_props$valueMax = props.valueMax,
|
|
39
|
+
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax,
|
|
40
|
+
size = props.size,
|
|
41
|
+
color = props.color,
|
|
42
|
+
meterColor = props.meterColor;
|
|
43
43
|
const meterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
44
44
|
valueNow,
|
|
45
45
|
valueMax
|
|
@@ -180,9 +180,11 @@ const generateStyle = (componentTheme, props) => {
|
|
|
180
180
|
'&::-webkit-progress-bar': {
|
|
181
181
|
background: 'transparent'
|
|
182
182
|
},
|
|
183
|
-
'&::-webkit-progress-value': {
|
|
183
|
+
'&::-webkit-progress-value': {
|
|
184
|
+
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
184
185
|
},
|
|
185
|
-
'&::-moz-progress-bar': {
|
|
186
|
+
'&::-moz-progress-bar': {
|
|
187
|
+
...(meterColorClassName && trackBackgroundVariants[color][meterColorClassName])
|
|
186
188
|
},
|
|
187
189
|
'&::-ms-fill': {
|
|
188
190
|
border: 'none',
|
|
@@ -200,5 +202,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
200
202
|
}
|
|
201
203
|
};
|
|
202
204
|
};
|
|
203
|
-
|
|
204
205
|
export default generateStyle;
|
package/es/ProgressBar/theme.js
CHANGED
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const borders = theme.borders,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
colors = theme.colors,
|
|
33
|
+
spacing = theme.spacing,
|
|
34
|
+
typography = theme.typography,
|
|
35
|
+
themeName = theme.key;
|
|
36
36
|
const themeSpecificStyle = {
|
|
37
37
|
canvas: {
|
|
38
38
|
meterColorBrand: theme['ic-brand-primary']
|
|
@@ -83,9 +83,9 @@ const generateComponentTheme = theme => {
|
|
|
83
83
|
trackBottomBorderColor: colors === null || colors === void 0 ? void 0 : colors.borderMedium,
|
|
84
84
|
trackBottomBorderColorInverse: colors === null || colors === void 0 ? void 0 : colors.borderLightest
|
|
85
85
|
};
|
|
86
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
...componentVariables,
|
|
87
88
|
...themeSpecificStyle[themeName]
|
|
88
89
|
};
|
|
89
90
|
};
|
|
90
|
-
|
|
91
91
|
export default generateComponentTheme;
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { ProgressCircle } from './index';
|
|
25
|
+
import { ProgressCircle } from './index';
|
|
26
26
|
|
|
27
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
28
|
export const ProgressCircleLocator = locator(ProgressCircle.selector);
|
|
@@ -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
|
import React from 'react';
|
|
25
26
|
const valueMax = 100;
|
|
26
27
|
export default {
|
|
@@ -29,7 +30,7 @@ export default {
|
|
|
29
30
|
valueNow: [0, 40, 80, 100],
|
|
30
31
|
renderValue: [null, _ref => {
|
|
31
32
|
let valueNow = _ref.valueNow,
|
|
32
|
-
|
|
33
|
+
valueMax = _ref.valueMax;
|
|
33
34
|
return /*#__PURE__*/React.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
34
35
|
}]
|
|
35
36
|
},
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["color", "renderValue", "formatScreenReaderValue", "meterColor", "valueNow", "valueMax", "screenReaderLabel", "size", "styles"];
|
|
3
|
-
|
|
4
3
|
var _dec, _dec2, _class, _class2;
|
|
5
|
-
|
|
6
4
|
/*
|
|
7
5
|
* The MIT License (MIT)
|
|
8
6
|
*
|
|
@@ -37,42 +35,36 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
37
35
|
import generateStyle from './styles';
|
|
38
36
|
import generateComponentTheme from './theme';
|
|
39
37
|
import { allowedProps, propTypes } from './props';
|
|
38
|
+
|
|
40
39
|
/**
|
|
41
40
|
---
|
|
42
41
|
category: components
|
|
43
42
|
---
|
|
44
43
|
@tsProps
|
|
45
44
|
**/
|
|
46
|
-
|
|
47
45
|
let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class ProgressCircle extends Component {
|
|
48
46
|
constructor(props) {
|
|
49
47
|
super(props);
|
|
50
48
|
this._timeouts = [];
|
|
51
49
|
this.ref = null;
|
|
52
|
-
|
|
53
50
|
this.handleRef = el => {
|
|
54
51
|
const elementRef = this.props.elementRef;
|
|
55
52
|
this.ref = el;
|
|
56
|
-
|
|
57
53
|
if (typeof elementRef === 'function') {
|
|
58
54
|
elementRef(el);
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
|
-
|
|
62
57
|
this.state = {
|
|
63
58
|
shouldAnimateOnMount: props.shouldAnimateOnMount
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
|
-
|
|
67
61
|
get makeStylesVariables() {
|
|
68
62
|
return {
|
|
69
63
|
shouldAnimateOnMount: this.state.shouldAnimateOnMount
|
|
70
64
|
};
|
|
71
65
|
}
|
|
72
|
-
|
|
73
66
|
componentDidMount() {
|
|
74
67
|
var _this$props$makeStyle, _this$props;
|
|
75
|
-
|
|
76
68
|
if (this.state.shouldAnimateOnMount) {
|
|
77
69
|
this._timeouts.push(setTimeout(() => {
|
|
78
70
|
this.setState({
|
|
@@ -80,42 +72,35 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
80
72
|
});
|
|
81
73
|
}, this.props.animationDelay || 500));
|
|
82
74
|
}
|
|
83
|
-
|
|
84
75
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
|
|
85
76
|
}
|
|
86
|
-
|
|
87
77
|
componentDidUpdate() {
|
|
88
78
|
var _this$props$makeStyle2, _this$props2;
|
|
89
|
-
|
|
90
79
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
|
|
91
80
|
}
|
|
92
|
-
|
|
93
81
|
componentWillUnmount() {
|
|
94
82
|
this._timeouts.forEach(timeout => clearTimeout(timeout));
|
|
95
83
|
}
|
|
96
|
-
|
|
97
84
|
render() {
|
|
98
85
|
var _styles$radii, _styles$radii2, _styles$radii3;
|
|
99
|
-
|
|
100
86
|
const _this$props3 = this.props,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
87
|
+
color = _this$props3.color,
|
|
88
|
+
renderValue = _this$props3.renderValue,
|
|
89
|
+
formatScreenReaderValue = _this$props3.formatScreenReaderValue,
|
|
90
|
+
meterColor = _this$props3.meterColor,
|
|
91
|
+
valueNow = _this$props3.valueNow,
|
|
92
|
+
valueMax = _this$props3.valueMax,
|
|
93
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
94
|
+
size = _this$props3.size,
|
|
95
|
+
styles = _this$props3.styles,
|
|
96
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
112
97
|
const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
|
|
113
98
|
valueNow: valueNow,
|
|
114
99
|
valueMax: valueMax
|
|
115
|
-
}) : void 0;
|
|
100
|
+
}) : void 0;
|
|
101
|
+
// consolidating the label and aria-valuetext to put in aria-label because
|
|
116
102
|
// NVDA does not read aria-valuetext: https://github.com/nvaccess/nvda/issues/913
|
|
117
103
|
// But leaving aria-valuetext because JAWS ignores aria-label
|
|
118
|
-
|
|
119
104
|
const labelAndValueText = `${screenReaderLabel} ${valueText}`;
|
|
120
105
|
const value = callRenderProp(renderValue, {
|
|
121
106
|
valueNow: valueNow,
|
|
@@ -166,11 +151,10 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
166
151
|
r: styles === null || styles === void 0 ? void 0 : (_styles$radii3 = styles.radii) === null || _styles$radii3 === void 0 ? void 0 : _styles$radii3.radius
|
|
167
152
|
})));
|
|
168
153
|
}
|
|
169
|
-
|
|
170
154
|
}, _class2.displayName = "ProgressCircle", _class2.componentId = 'ProgressCircle', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
171
155
|
formatScreenReaderValue: _ref => {
|
|
172
156
|
let valueNow = _ref.valueNow,
|
|
173
|
-
|
|
157
|
+
valueMax = _ref.valueMax;
|
|
174
158
|
return `${valueNow} / ${valueMax}`;
|
|
175
159
|
},
|
|
176
160
|
size: 'medium',
|
|
@@ -182,7 +166,7 @@ let ProgressCircle = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
182
166
|
// default to showing `success` color on completion
|
|
183
167
|
meterColor: _ref2 => {
|
|
184
168
|
let valueNow = _ref2.valueNow,
|
|
185
|
-
|
|
169
|
+
valueMax = _ref2.valueMax;
|
|
186
170
|
return valueNow / valueMax >= 1 ? 'success' : 'brand';
|
|
187
171
|
}
|
|
188
172
|
}, _class2)) || _class) || _class);
|
|
@@ -34,24 +34,22 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
36
|
const size = props.size,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
color = props.color,
|
|
38
|
+
meterColor = props.meterColor,
|
|
39
|
+
_props$valueNow = props.valueNow,
|
|
40
|
+
valueNow = _props$valueNow === void 0 ? 0 : _props$valueNow,
|
|
41
|
+
_props$valueMax = props.valueMax,
|
|
42
|
+
valueMax = _props$valueMax === void 0 ? 100 : _props$valueMax;
|
|
43
43
|
const shouldAnimateOnMount = state.shouldAnimateOnMount;
|
|
44
44
|
const getMeterColorClassName = typeof meterColor === 'function' ? meterColor({
|
|
45
45
|
valueNow,
|
|
46
46
|
valueMax
|
|
47
47
|
}) : meterColor;
|
|
48
|
-
|
|
49
48
|
const getCircumference = () => {
|
|
50
|
-
const camelSize = size === 'x-small' ? 'xSmall' : size;
|
|
51
|
-
|
|
49
|
+
const camelSize = size === 'x-small' ? 'xSmall' : size;
|
|
50
|
+
// get the circumference of the meter circle
|
|
52
51
|
return parseFloat(componentTheme[`${camelSize}Circumference`]);
|
|
53
52
|
};
|
|
54
|
-
|
|
55
53
|
const getRadii = () => {
|
|
56
54
|
const camelSize = size === 'x-small' ? 'xSmall' : size;
|
|
57
55
|
return {
|
|
@@ -59,25 +57,23 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
59
57
|
borderOffsetRadius: componentTheme[`${camelSize}BorderOffset`]
|
|
60
58
|
};
|
|
61
59
|
};
|
|
62
|
-
|
|
63
60
|
const getDashOffset = () => {
|
|
64
61
|
// send the stroke-dashoffset to the meter circle, checking
|
|
65
62
|
// to make sure current value doesn't exceed max value
|
|
66
63
|
if (valueNow < valueMax) {
|
|
67
|
-
const circumference = getCircumference();
|
|
68
|
-
|
|
64
|
+
const circumference = getCircumference();
|
|
65
|
+
// figure out how much offset to give the stroke to show the % complete
|
|
69
66
|
return circumference - valueNow / valueMax * circumference;
|
|
70
67
|
} else {
|
|
71
68
|
return 0;
|
|
72
69
|
}
|
|
73
70
|
};
|
|
71
|
+
|
|
74
72
|
/*
|
|
75
73
|
Using !important on the meter shouldAnimateOnMount versions
|
|
76
74
|
to guarantee that the bars will start showing 0 if the
|
|
77
75
|
animateOnMount prop is set
|
|
78
76
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
77
|
const sizeVariants = {
|
|
82
78
|
'x-small': {
|
|
83
79
|
progressCircle: {
|
|
@@ -255,7 +251,6 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
255
251
|
verticalAlign: 'middle',
|
|
256
252
|
position: 'relative',
|
|
257
253
|
overflow: 'hidden',
|
|
258
|
-
|
|
259
254
|
/*
|
|
260
255
|
Seems like a good idea to reset font-size because
|
|
261
256
|
the SVG uses ems and might inherit a container's
|
|
@@ -351,5 +346,4 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
351
346
|
dashOffset: getDashOffset()
|
|
352
347
|
};
|
|
353
348
|
};
|
|
354
|
-
|
|
355
349
|
export default generateStyle;
|
|
@@ -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
|
const radius = {
|
|
25
26
|
xSmall: 1,
|
|
26
27
|
small: 1.8,
|
|
@@ -38,10 +39,11 @@ const strokeWidth = {
|
|
|
38
39
|
small: 0.5,
|
|
39
40
|
medium: 0.625,
|
|
40
41
|
large: 0.875
|
|
41
|
-
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Necessary to get the 1px border line to go "under" the meter
|
|
42
45
|
// strokeWidth is divided in half because SVG strokeWidth is
|
|
43
46
|
// centered along the path of the stroke, unlike CSS
|
|
44
|
-
|
|
45
47
|
const borderWidth = 0.0625;
|
|
46
48
|
const borderOffsetRadius = {
|
|
47
49
|
xSmall: radius.xSmall - strokeWidth.xSmall / 2 + borderWidth,
|
|
@@ -49,25 +51,22 @@ const borderOffsetRadius = {
|
|
|
49
51
|
medium: radius.medium - strokeWidth.medium / 2 + borderWidth,
|
|
50
52
|
large: radius.large - strokeWidth.large / 2 + borderWidth
|
|
51
53
|
};
|
|
52
|
-
|
|
53
54
|
const circumference = function (r) {
|
|
54
55
|
return (2 * Math.PI * r).toFixed(3);
|
|
55
56
|
};
|
|
56
|
-
|
|
57
57
|
const transform = function (s) {
|
|
58
58
|
return s / 2;
|
|
59
59
|
};
|
|
60
|
+
|
|
60
61
|
/**
|
|
61
62
|
* Generates the theme object for the component from the theme and provided additional information
|
|
62
63
|
* @param {Object} theme The actual theme object.
|
|
63
64
|
* @return {Object} The final theme object with the overrides and component variables
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
66
|
const generateComponentTheme = theme => {
|
|
68
67
|
const colors = theme.colors,
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
typography = theme.typography,
|
|
69
|
+
themeName = theme.key;
|
|
71
70
|
const themeSpecificStyle = {
|
|
72
71
|
canvas: {
|
|
73
72
|
color: theme['ic-brand-font-color-dark'],
|
|
@@ -131,9 +130,9 @@ const generateComponentTheme = theme => {
|
|
|
131
130
|
meterColorWarning: colors === null || colors === void 0 ? void 0 : colors.backgroundWarning,
|
|
132
131
|
meterColorWarningInverse: colors === null || colors === void 0 ? void 0 : colors.backgroundWarning
|
|
133
132
|
};
|
|
134
|
-
return {
|
|
133
|
+
return {
|
|
134
|
+
...componentVariables,
|
|
135
135
|
...themeSpecificStyle[themeName]
|
|
136
136
|
};
|
|
137
137
|
};
|
|
138
|
-
|
|
139
138
|
export default generateComponentTheme;
|
package/es/index.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ProgressBarLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
36
34
|
const ProgressBarLocator = (0, _locator.locator)(_index.ProgressBar.selector);
|
|
37
35
|
exports.ProgressBarLocator = ProgressBarLocator;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
const valueMax = 100;
|
|
36
34
|
var _default = {
|
|
37
35
|
sectionProp: 'color',
|
|
@@ -39,7 +37,7 @@ var _default = {
|
|
|
39
37
|
valueNow: [0, 40, 80, 100],
|
|
40
38
|
renderValue: [null, _ref => {
|
|
41
39
|
let valueNow = _ref.valueNow,
|
|
42
|
-
|
|
40
|
+
valueMax = _ref.valueMax;
|
|
43
41
|
return /*#__PURE__*/_react.default.createElement("span", null, Math.round(valueNow / valueMax * 100));
|
|
44
42
|
}]
|
|
45
43
|
},
|