@instructure/ui-progress 10.7.0 → 10.7.1-snapshot-1

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 CHANGED
@@ -3,6 +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
+ ## [10.7.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.7.0...v10.7.1-snapshot-1) (2024-12-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * **shared-types,ui-progress:** add customization options for progressbar ([56308de](https://github.com/instructure/instructure-ui/commit/56308de9aa4b84a9f9f6fb7096b4916014c56b5b))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.7.0](https://github.com/instructure/instructure-ui/compare/v10.6.1...v10.7.0) (2024-12-03)
7
18
 
8
19
  **Note:** Version bump only for package @instructure/ui-progress
@@ -75,4 +75,30 @@ describe('<ProgressBar />', () => {
75
75
  const axeCheck = await runAxeCheck(container);
76
76
  expect(axeCheck).toBe(true);
77
77
  });
78
+ it('should not render the value inside when the prop is set to false', () => {
79
+ const valueNow = 33;
80
+ const _render5 = render(/*#__PURE__*/React.createElement(ProgressBar, {
81
+ screenReaderLabel: "Chapters read",
82
+ valueMax: 100,
83
+ valueNow: valueNow,
84
+ renderValueInside: false,
85
+ renderValue: `${valueNow}%`
86
+ })),
87
+ container = _render5.container;
88
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]');
89
+ expect(progressMeter).not.toHaveTextContent('33%');
90
+ });
91
+ it('should render the value inside when the prop is set', () => {
92
+ const valueNow = 33;
93
+ const _render6 = render(/*#__PURE__*/React.createElement(ProgressBar, {
94
+ screenReaderLabel: "Chapters read",
95
+ valueMax: 100,
96
+ valueNow: valueNow,
97
+ renderValueInside: true,
98
+ renderValue: `${valueNow}%`
99
+ })),
100
+ container = _render6.container;
101
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]');
102
+ expect(progressMeter).toHaveTextContent('33%');
103
+ });
78
104
  });
@@ -1,5 +1,5 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "styles"];
2
+ const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "renderValueInside", "styles"];
3
3
  var _dec, _dec2, _class, _ProgressBar;
4
4
  /*
5
5
  * The MIT License (MIT)
@@ -70,6 +70,7 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
70
70
  size = _this$props3.size,
71
71
  color = _this$props3.color,
72
72
  meterColor = _this$props3.meterColor,
73
+ renderValueInside = _this$props3.renderValueInside,
73
74
  styles = _this$props3.styles,
74
75
  props = _objectWithoutProperties(_this$props3, _excluded);
75
76
  const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
@@ -102,7 +103,7 @@ let ProgressBar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
102
103
  "aria-hidden": "true"
103
104
  }, jsx("span", {
104
105
  css: styles === null || styles === void 0 ? void 0 : styles.trackValue
105
- }))), value && jsx("span", {
106
+ }, renderValueInside && value))), value && !renderValueInside && jsx("span", {
106
107
  css: styles === null || styles === void 0 ? void 0 : styles.value,
107
108
  "aria-hidden": "true"
108
109
  }, value));
@@ -35,7 +35,8 @@ const propTypes = {
35
35
  shouldAnimate: PropTypes.bool,
36
36
  margin: ThemeablePropTypes.spacing,
37
37
  elementRef: PropTypes.func,
38
- as: PropTypes.elementType
38
+ as: PropTypes.elementType,
39
+ renderValueInside: PropTypes.bool
39
40
  };
40
41
  const allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'shouldAnimate', 'margin', 'elementRef', 'as'];
41
42
  export { propTypes, allowedProps };
@@ -150,12 +150,14 @@ const generateStyle = (componentTheme, props) => {
150
150
  fontFamily: componentTheme.fontFamily,
151
151
  fontWeight: componentTheme.fontWeight,
152
152
  lineHeight: componentTheme.lineHeight,
153
- fontSize: componentTheme.fontSize
153
+ fontSize: componentTheme.fontSize,
154
+ borderRadius: componentTheme.borderRadius
154
155
  },
155
156
  trackLayout: {
156
157
  label: 'progressBar__trackLayout',
157
158
  position: 'relative',
158
159
  flex: 1,
160
+ borderRadius: 'inherit',
159
161
  ...colorVariants[color].trackLayout
160
162
  },
161
163
  track: {
@@ -166,6 +168,7 @@ const generateStyle = (componentTheme, props) => {
166
168
  borderBottomWidth: componentTheme.trackBottomBorderWidth,
167
169
  borderBottomStyle: 'solid',
168
170
  background: 'transparent',
171
+ borderRadius: 'inherit',
169
172
  ...sizeVariants[size].track,
170
173
  ...colorVariants[color].trackBorder
171
174
  },
@@ -176,6 +179,7 @@ const generateStyle = (componentTheme, props) => {
176
179
  height: '100%',
177
180
  width: currentValuePercent,
178
181
  maxWidth: '100%',
182
+ borderRadius: 'inherit',
179
183
  ...(shouldAnimate && {
180
184
  transition: 'all 0.5s'
181
185
  }),
@@ -82,7 +82,8 @@ const generateComponentTheme = theme => {
82
82
  trackColorInverse: 'transparent',
83
83
  trackBottomBorderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
84
84
  trackBottomBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts20 = colors.contrasts) === null || _colors$contrasts20 === void 0 ? void 0 : _colors$contrasts20.grey3045,
85
- trackBottomBorderColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.white1010
85
+ trackBottomBorderColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.white1010,
86
+ borderRadius: '0px'
86
87
  };
87
88
  return {
88
89
  ...componentVariables,
@@ -77,4 +77,30 @@ describe('<ProgressBar />', () => {
77
77
  const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
78
78
  expect(axeCheck).toBe(true);
79
79
  });
80
+ it('should not render the value inside when the prop is set to false', () => {
81
+ const valueNow = 33;
82
+ const _render5 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.ProgressBar, {
83
+ screenReaderLabel: "Chapters read",
84
+ valueMax: 100,
85
+ valueNow: valueNow,
86
+ renderValueInside: false,
87
+ renderValue: `${valueNow}%`
88
+ })),
89
+ container = _render5.container;
90
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]');
91
+ expect(progressMeter).not.toHaveTextContent('33%');
92
+ });
93
+ it('should render the value inside when the prop is set', () => {
94
+ const valueNow = 33;
95
+ const _render6 = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_index.ProgressBar, {
96
+ screenReaderLabel: "Chapters read",
97
+ valueMax: 100,
98
+ valueNow: valueNow,
99
+ renderValueInside: true,
100
+ renderValue: `${valueNow}%`
101
+ })),
102
+ container = _render6.container;
103
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]');
104
+ expect(progressMeter).toHaveTextContent('33%');
105
+ });
80
106
  });
@@ -15,7 +15,7 @@ var _emotion = require("@instructure/emotion");
15
15
  var _styles = _interopRequireDefault(require("./styles"));
16
16
  var _theme = _interopRequireDefault(require("./theme"));
17
17
  var _props = require("./props");
18
- const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "styles"];
18
+ const _excluded = ["renderValue", "formatScreenReaderValue", "valueNow", "valueMax", "screenReaderLabel", "size", "color", "meterColor", "renderValueInside", "styles"];
19
19
  var _dec, _dec2, _class, _ProgressBar;
20
20
  /*
21
21
  * The MIT License (MIT)
@@ -76,6 +76,7 @@ let ProgressBar = exports.ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.
76
76
  size = _this$props3.size,
77
77
  color = _this$props3.color,
78
78
  meterColor = _this$props3.meterColor,
79
+ renderValueInside = _this$props3.renderValueInside,
79
80
  styles = _this$props3.styles,
80
81
  props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
81
82
  const valueText = typeof formatScreenReaderValue === 'function' ? formatScreenReaderValue({
@@ -108,7 +109,7 @@ let ProgressBar = exports.ProgressBar = (_dec = (0, _emotion.withStyle)(_styles.
108
109
  "aria-hidden": "true"
109
110
  }, (0, _emotion.jsx)("span", {
110
111
  css: styles === null || styles === void 0 ? void 0 : styles.trackValue
111
- }))), value && (0, _emotion.jsx)("span", {
112
+ }, renderValueInside && value))), value && !renderValueInside && (0, _emotion.jsx)("span", {
112
113
  css: styles === null || styles === void 0 ? void 0 : styles.value,
113
114
  "aria-hidden": "true"
114
115
  }, value));
@@ -43,6 +43,7 @@ const propTypes = exports.propTypes = {
43
43
  shouldAnimate: _propTypes.default.bool,
44
44
  margin: _emotion.ThemeablePropTypes.spacing,
45
45
  elementRef: _propTypes.default.func,
46
- as: _propTypes.default.elementType
46
+ as: _propTypes.default.elementType,
47
+ renderValueInside: _propTypes.default.bool
47
48
  };
48
49
  const allowedProps = exports.allowedProps = ['screenReaderLabel', 'size', 'valueMax', 'valueNow', 'formatScreenReaderValue', 'renderValue', 'color', 'meterColor', 'shouldAnimate', 'margin', 'elementRef', 'as'];
@@ -156,12 +156,14 @@ const generateStyle = (componentTheme, props) => {
156
156
  fontFamily: componentTheme.fontFamily,
157
157
  fontWeight: componentTheme.fontWeight,
158
158
  lineHeight: componentTheme.lineHeight,
159
- fontSize: componentTheme.fontSize
159
+ fontSize: componentTheme.fontSize,
160
+ borderRadius: componentTheme.borderRadius
160
161
  },
161
162
  trackLayout: {
162
163
  label: 'progressBar__trackLayout',
163
164
  position: 'relative',
164
165
  flex: 1,
166
+ borderRadius: 'inherit',
165
167
  ...colorVariants[color].trackLayout
166
168
  },
167
169
  track: {
@@ -172,6 +174,7 @@ const generateStyle = (componentTheme, props) => {
172
174
  borderBottomWidth: componentTheme.trackBottomBorderWidth,
173
175
  borderBottomStyle: 'solid',
174
176
  background: 'transparent',
177
+ borderRadius: 'inherit',
175
178
  ...sizeVariants[size].track,
176
179
  ...colorVariants[color].trackBorder
177
180
  },
@@ -182,6 +185,7 @@ const generateStyle = (componentTheme, props) => {
182
185
  height: '100%',
183
186
  width: currentValuePercent,
184
187
  maxWidth: '100%',
188
+ borderRadius: 'inherit',
185
189
  ...(shouldAnimate && {
186
190
  transition: 'all 0.5s'
187
191
  }),
@@ -88,7 +88,8 @@ const generateComponentTheme = theme => {
88
88
  trackColorInverse: 'transparent',
89
89
  trackBottomBorderWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
90
90
  trackBottomBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts20 = colors.contrasts) === null || _colors$contrasts20 === void 0 ? void 0 : _colors$contrasts20.grey3045,
91
- trackBottomBorderColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.white1010
91
+ trackBottomBorderColorInverse: colors === null || colors === void 0 ? void 0 : (_colors$contrasts21 = colors.contrasts) === null || _colors$contrasts21 === void 0 ? void 0 : _colors$contrasts21.white1010,
92
+ borderRadius: '0px'
92
93
  };
93
94
  return {
94
95
  ...componentVariables,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-progress",
3
- "version": "10.7.0",
3
+ "version": "10.7.1-snapshot-1",
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.25.6",
27
- "@instructure/console": "10.7.0",
28
- "@instructure/emotion": "10.7.0",
29
- "@instructure/shared-types": "10.7.0",
30
- "@instructure/ui-a11y-content": "10.7.0",
31
- "@instructure/ui-color-utils": "10.7.0",
32
- "@instructure/ui-react-utils": "10.7.0",
33
- "@instructure/ui-testable": "10.7.0",
34
- "@instructure/ui-view": "10.7.0",
27
+ "@instructure/console": "10.7.1-snapshot-1",
28
+ "@instructure/emotion": "10.7.1-snapshot-1",
29
+ "@instructure/shared-types": "10.7.1-snapshot-1",
30
+ "@instructure/ui-a11y-content": "10.7.1-snapshot-1",
31
+ "@instructure/ui-color-utils": "10.7.1-snapshot-1",
32
+ "@instructure/ui-react-utils": "10.7.1-snapshot-1",
33
+ "@instructure/ui-testable": "10.7.1-snapshot-1",
34
+ "@instructure/ui-view": "10.7.1-snapshot-1",
35
35
  "prop-types": "^15.8.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@instructure/ui-axe-check": "10.7.0",
39
- "@instructure/ui-babel-preset": "10.7.0",
40
- "@instructure/ui-test-utils": "10.7.0",
41
- "@instructure/ui-themes": "10.7.0",
38
+ "@instructure/ui-axe-check": "10.7.1-snapshot-1",
39
+ "@instructure/ui-babel-preset": "10.7.1-snapshot-1",
40
+ "@instructure/ui-test-utils": "10.7.1-snapshot-1",
41
+ "@instructure/ui-themes": "10.7.1-snapshot-1",
42
42
  "@testing-library/jest-dom": "^6.4.6",
43
43
  "@testing-library/react": "^16.0.1",
44
44
  "vitest": "^2.1.1"
@@ -83,4 +83,36 @@ describe('<ProgressBar />', () => {
83
83
  const axeCheck = await runAxeCheck(container)
84
84
  expect(axeCheck).toBe(true)
85
85
  })
86
+
87
+ it('should not render the value inside when the prop is set to false', () => {
88
+ const valueNow = 33
89
+ const { container } = render(
90
+ <ProgressBar
91
+ screenReaderLabel="Chapters read"
92
+ valueMax={100}
93
+ valueNow={valueNow}
94
+ renderValueInside={false}
95
+ renderValue={`${valueNow}%`}
96
+ />
97
+ )
98
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]')
99
+
100
+ expect(progressMeter).not.toHaveTextContent('33%')
101
+ })
102
+
103
+ it('should render the value inside when the prop is set', () => {
104
+ const valueNow = 33
105
+ const { container } = render(
106
+ <ProgressBar
107
+ screenReaderLabel="Chapters read"
108
+ valueMax={100}
109
+ valueNow={valueNow}
110
+ renderValueInside
111
+ renderValue={`${valueNow}%`}
112
+ />
113
+ )
114
+ const progressMeter = container.querySelector('[class$="-progressBar__trackValue"]')
115
+
116
+ expect(progressMeter).toHaveTextContent('33%')
117
+ })
86
118
  })
@@ -95,6 +95,7 @@ class ProgressBar extends Component<ProgressBarProps> {
95
95
  size,
96
96
  color,
97
97
  meterColor,
98
+ renderValueInside,
98
99
  styles,
99
100
  ...props
100
101
  } = this.props
@@ -130,11 +131,11 @@ class ProgressBar extends Component<ProgressBarProps> {
130
131
  />
131
132
 
132
133
  <span css={styles?.track} role="presentation" aria-hidden="true">
133
- <span css={styles?.trackValue}></span>
134
+ <span css={styles?.trackValue}>{renderValueInside && value}</span>
134
135
  </span>
135
136
  </span>
136
137
 
137
- {value && (
138
+ {value && !renderValueInside && (
138
139
  <span css={styles?.value} aria-hidden="true">
139
140
  {value}
140
141
  </span>
@@ -114,6 +114,14 @@ type ProgressBarOwnProps = {
114
114
  * Set the element type of the component's root
115
115
  */
116
116
  as?: AsElementType
117
+
118
+ /**
119
+ * If true, displays the `renderValue` inside the progress meter for customization.
120
+ *
121
+ * Note: This should not be used in most cases. When enabled, ensure `renderValue` is styled for proper
122
+ * legibility and alignment across themes and sizes.
123
+ */
124
+ renderValueInside?: boolean
117
125
  }
118
126
 
119
127
  type PropKeys = keyof ProgressBarOwnProps
@@ -148,7 +156,8 @@ const propTypes: PropValidators<PropKeys> = {
148
156
  shouldAnimate: PropTypes.bool,
149
157
  margin: ThemeablePropTypes.spacing,
150
158
  elementRef: PropTypes.func,
151
- as: PropTypes.elementType
159
+ as: PropTypes.elementType,
160
+ renderValueInside: PropTypes.bool,
152
161
  }
153
162
 
154
163
  const allowedProps: AllowedPropKeys = [
@@ -119,13 +119,15 @@ const generateStyle = (
119
119
  fontFamily: componentTheme.fontFamily,
120
120
  fontWeight: componentTheme.fontWeight,
121
121
  lineHeight: componentTheme.lineHeight,
122
- fontSize: componentTheme.fontSize
122
+ fontSize: componentTheme.fontSize,
123
+ borderRadius: componentTheme.borderRadius
123
124
  },
124
125
 
125
126
  trackLayout: {
126
127
  label: 'progressBar__trackLayout',
127
128
  position: 'relative',
128
129
  flex: 1,
130
+ borderRadius: 'inherit',
129
131
 
130
132
  ...colorVariants[color!].trackLayout
131
133
  },
@@ -138,6 +140,7 @@ const generateStyle = (
138
140
  borderBottomWidth: componentTheme.trackBottomBorderWidth,
139
141
  borderBottomStyle: 'solid',
140
142
  background: 'transparent',
143
+ borderRadius: 'inherit',
141
144
 
142
145
  ...sizeVariants[size!].track,
143
146
  ...colorVariants[color!].trackBorder
@@ -150,6 +153,7 @@ const generateStyle = (
150
153
  height: '100%',
151
154
  width: currentValuePercent,
152
155
  maxWidth: '100%',
156
+ borderRadius: 'inherit',
153
157
 
154
158
  ...(shouldAnimate && { transition: 'all 0.5s' }),
155
159
  ...(meterColorClassName &&
@@ -94,7 +94,9 @@ const generateComponentTheme = (theme: Theme): ProgressBarTheme => {
94
94
  trackColorInverse: 'transparent',
95
95
  trackBottomBorderWidth: borders?.widthSmall,
96
96
  trackBottomBorderColor: colors?.contrasts?.grey3045,
97
- trackBottomBorderColorInverse: colors?.contrasts?.white1010
97
+ trackBottomBorderColorInverse: colors?.contrasts?.white1010,
98
+
99
+ borderRadius: '0px'
98
100
  }
99
101
 
100
102
  return {