@instructure/ui-color-picker 10.20.2-snapshot-7 → 10.20.2-snapshot-9

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,9 +3,12 @@
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.20.2-snapshot-7](https://github.com/instructure/instructure-ui/compare/v10.20.1...v10.20.2-snapshot-7) (2025-06-24)
6
+ ## [10.20.2-snapshot-9](https://github.com/instructure/instructure-ui/compare/v10.20.1...v10.20.2-snapshot-9) (2025-06-24)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-color-picker
8
+
9
+ ### Features
10
+
11
+ * **ui-color-picker:** add colorScreenReaderLabel prop to provide more color information ([6650445](https://github.com/instructure/instructure-ui/commit/6650445d4ae33a0e7b37b6ed6b1d736f030e310b))
9
12
 
10
13
 
11
14
 
@@ -158,6 +158,9 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
158
158
  };
159
159
  this.renderIndicatorBase = (color, selectOnClick) => {
160
160
  var _this$props6, _this$props6$styles;
161
+ const hexCode = color;
162
+ const isSelected = this.isSelectedColor(color);
163
+ const screenReaderLabel = typeof this.props.colorScreenReaderLabel === 'function' ? this.props.colorScreenReaderLabel(hexCode, isSelected) : hexCode;
161
164
  return _jsx(View, {
162
165
  disabled: this.props.disabled,
163
166
  position: "relative",
@@ -171,10 +174,10 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
171
174
  padding: "0",
172
175
  cursor: this.props.disabled ? 'not-allowed' : 'auto',
173
176
  as: "button",
177
+ "aria-label": screenReaderLabel,
174
178
  ...(selectOnClick ? {
175
179
  onClick: () => this.props.onSelect(color)
176
180
  } : {}),
177
- 'aria-label': `${color}${this.isSelectedColor(color) ? ' selected' : ''}`,
178
181
  children: _jsxs("div", {
179
182
  children: [_jsx(ColorIndicator, {
180
183
  color: color,
@@ -31,6 +31,7 @@ const propTypes = {
31
31
  elementRef: PropTypes.func,
32
32
  label: PropTypes.string,
33
33
  popoverScreenReaderLabel: PropTypes.string,
34
+ colorScreenReaderLabel: PropTypes.func,
34
35
  colorMixerSettings: PropTypes.shape({
35
36
  addNewPresetButtonScreenReaderLabel: PropTypes.string.isRequired,
36
37
  selectColorLabel: PropTypes.string.isRequired,
@@ -62,5 +63,5 @@ const propTypes = {
62
63
  })
63
64
  })
64
65
  };
65
- const allowedProps = ['colors', 'disabled', 'elementRef', 'label', 'colorMixerSettings', 'onSelect', 'popoverScreenReaderLabel', 'selected'];
66
+ const allowedProps = ['colors', 'disabled', 'elementRef', 'label', 'colorMixerSettings', 'onSelect', 'popoverScreenReaderLabel', 'selected', 'colorScreenReaderLabel'];
66
67
  export { propTypes, allowedProps };
@@ -165,6 +165,9 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
165
165
  };
166
166
  this.renderIndicatorBase = (color, selectOnClick) => {
167
167
  var _this$props6, _this$props6$styles;
168
+ const hexCode = color;
169
+ const isSelected = this.isSelectedColor(color);
170
+ const screenReaderLabel = typeof this.props.colorScreenReaderLabel === 'function' ? this.props.colorScreenReaderLabel(hexCode, isSelected) : hexCode;
168
171
  return (0, _jsxRuntime.jsx)(_View.View, {
169
172
  disabled: this.props.disabled,
170
173
  position: "relative",
@@ -178,10 +181,10 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
178
181
  padding: "0",
179
182
  cursor: this.props.disabled ? 'not-allowed' : 'auto',
180
183
  as: "button",
184
+ "aria-label": screenReaderLabel,
181
185
  ...(selectOnClick ? {
182
186
  onClick: () => this.props.onSelect(color)
183
187
  } : {}),
184
- 'aria-label': `${color}${this.isSelectedColor(color) ? ' selected' : ''}`,
185
188
  children: (0, _jsxRuntime.jsxs)("div", {
186
189
  children: [(0, _jsxRuntime.jsx)(_ColorIndicator.ColorIndicator, {
187
190
  color: color,
@@ -38,6 +38,7 @@ const propTypes = exports.propTypes = {
38
38
  elementRef: _propTypes.default.func,
39
39
  label: _propTypes.default.string,
40
40
  popoverScreenReaderLabel: _propTypes.default.string,
41
+ colorScreenReaderLabel: _propTypes.default.func,
41
42
  colorMixerSettings: _propTypes.default.shape({
42
43
  addNewPresetButtonScreenReaderLabel: _propTypes.default.string.isRequired,
43
44
  selectColorLabel: _propTypes.default.string.isRequired,
@@ -69,4 +70,4 @@ const propTypes = exports.propTypes = {
69
70
  })
70
71
  })
71
72
  };
72
- const allowedProps = exports.allowedProps = ['colors', 'disabled', 'elementRef', 'label', 'colorMixerSettings', 'onSelect', 'popoverScreenReaderLabel', 'selected'];
73
+ const allowedProps = exports.allowedProps = ['colors', 'disabled', 'elementRef', 'label', 'colorMixerSettings', 'onSelect', 'popoverScreenReaderLabel', 'selected', 'colorScreenReaderLabel'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-color-picker",
3
- "version": "10.20.2-snapshot-7",
3
+ "version": "10.20.2-snapshot-9",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,33 +24,33 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.27.6",
27
- "@instructure/console": "10.20.2-snapshot-7",
28
- "@instructure/emotion": "10.20.2-snapshot-7",
29
- "@instructure/shared-types": "10.20.2-snapshot-7",
30
- "@instructure/ui-a11y-content": "10.20.2-snapshot-7",
31
- "@instructure/ui-buttons": "10.20.2-snapshot-7",
32
- "@instructure/ui-color-utils": "10.20.2-snapshot-7",
33
- "@instructure/ui-dom-utils": "10.20.2-snapshot-7",
34
- "@instructure/ui-drilldown": "10.20.2-snapshot-7",
35
- "@instructure/ui-form-field": "10.20.2-snapshot-7",
36
- "@instructure/ui-icons": "10.20.2-snapshot-7",
37
- "@instructure/ui-pill": "10.20.2-snapshot-7",
38
- "@instructure/ui-popover": "10.20.2-snapshot-7",
39
- "@instructure/ui-react-utils": "10.20.2-snapshot-7",
40
- "@instructure/ui-testable": "10.20.2-snapshot-7",
41
- "@instructure/ui-text": "10.20.2-snapshot-7",
42
- "@instructure/ui-text-input": "10.20.2-snapshot-7",
43
- "@instructure/ui-themes": "10.20.2-snapshot-7",
44
- "@instructure/ui-tooltip": "10.20.2-snapshot-7",
45
- "@instructure/ui-utils": "10.20.2-snapshot-7",
46
- "@instructure/ui-view": "10.20.2-snapshot-7",
27
+ "@instructure/console": "10.20.2-snapshot-9",
28
+ "@instructure/emotion": "10.20.2-snapshot-9",
29
+ "@instructure/shared-types": "10.20.2-snapshot-9",
30
+ "@instructure/ui-a11y-content": "10.20.2-snapshot-9",
31
+ "@instructure/ui-buttons": "10.20.2-snapshot-9",
32
+ "@instructure/ui-color-utils": "10.20.2-snapshot-9",
33
+ "@instructure/ui-dom-utils": "10.20.2-snapshot-9",
34
+ "@instructure/ui-drilldown": "10.20.2-snapshot-9",
35
+ "@instructure/ui-form-field": "10.20.2-snapshot-9",
36
+ "@instructure/ui-icons": "10.20.2-snapshot-9",
37
+ "@instructure/ui-pill": "10.20.2-snapshot-9",
38
+ "@instructure/ui-popover": "10.20.2-snapshot-9",
39
+ "@instructure/ui-react-utils": "10.20.2-snapshot-9",
40
+ "@instructure/ui-testable": "10.20.2-snapshot-9",
41
+ "@instructure/ui-text": "10.20.2-snapshot-9",
42
+ "@instructure/ui-text-input": "10.20.2-snapshot-9",
43
+ "@instructure/ui-themes": "10.20.2-snapshot-9",
44
+ "@instructure/ui-tooltip": "10.20.2-snapshot-9",
45
+ "@instructure/ui-utils": "10.20.2-snapshot-9",
46
+ "@instructure/ui-view": "10.20.2-snapshot-9",
47
47
  "prop-types": "^15.8.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@instructure/ui-axe-check": "10.20.2-snapshot-7",
51
- "@instructure/ui-babel-preset": "10.20.2-snapshot-7",
52
- "@instructure/ui-scripts": "10.20.2-snapshot-7",
53
- "@instructure/ui-test-utils": "10.20.2-snapshot-7",
50
+ "@instructure/ui-axe-check": "10.20.2-snapshot-9",
51
+ "@instructure/ui-babel-preset": "10.20.2-snapshot-9",
52
+ "@instructure/ui-scripts": "10.20.2-snapshot-9",
53
+ "@instructure/ui-test-utils": "10.20.2-snapshot-9",
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.0.1",
56
56
  "@testing-library/user-event": "^14.6.1",
@@ -34,6 +34,11 @@ A component for picking a color from a list of colors. Supports adding new color
34
34
  colors={this.state.colors}
35
35
  selected={this.state.selected}
36
36
  onSelect={(selected) => this.setState({ selected })}
37
+ colorScreenReaderLabel={(hexCode, isSelected) => {
38
+ return `color with hex code ${hexCode}${
39
+ isSelected ? ' selected' : ''
40
+ }`
41
+ }}
37
42
  />
38
43
  </div>
39
44
  )
@@ -65,6 +70,11 @@ A component for picking a color from a list of colors. Supports adding new color
65
70
  colors={colors}
66
71
  selected={selected}
67
72
  onSelect={setSelected}
73
+ colorScreenReaderLabel={(hexCode, isSelected) => {
74
+ return `color with hex code ${hexCode}${
75
+ isSelected ? ' selected' : ''
76
+ }`
77
+ }}
68
78
  />
69
79
  </div>
70
80
  )
@@ -131,6 +141,11 @@ A component for picking a color from a list of colors. Supports adding new color
131
141
  secondColorLabel: 'Foreground'
132
142
  }
133
143
  }}
144
+ colorScreenReaderLabel={(hexCode, isSelected) => {
145
+ return `color with hex code ${hexCode}${
146
+ isSelected ? ' selected' : ''
147
+ }`
148
+ }}
134
149
  />
135
150
  </div>
136
151
  )
@@ -189,6 +204,11 @@ A component for picking a color from a list of colors. Supports adding new color
189
204
  secondColorLabel: 'Foreground'
190
205
  }
191
206
  }}
207
+ colorScreenReaderLabel={(hexCode, isSelected) => {
208
+ return `color with hex code ${hexCode}${
209
+ isSelected ? ' selected' : ''
210
+ }`
211
+ }}
192
212
  />
193
213
  </div>
194
214
  )
@@ -250,40 +250,48 @@ class ColorPreset extends Component<ColorPresetProps, ColorPresetState> {
250
250
  : this.renderIndicatorTooltip(indicatorBase, color)
251
251
  }
252
252
 
253
- renderIndicatorBase = (color: string, selectOnClick?: boolean) => (
254
- <View
255
- disabled={this.props.disabled}
256
- position="relative"
257
- width="2.375rem"
258
- height="2.375rem"
259
- background="transparent"
260
- margin="xx-small"
261
- display="inline-block"
262
- borderRadius="medium"
263
- borderWidth="0"
264
- padding="0"
265
- cursor={this.props.disabled ? 'not-allowed' : 'auto'}
266
- as="button"
267
- {...(selectOnClick ? { onClick: () => this.props.onSelect(color) } : {})}
268
- {...{
269
- 'aria-label': `${color}${
270
- this.isSelectedColor(color) ? ' selected' : ''
271
- }`
272
- }}
273
- >
274
- <div>
275
- <ColorIndicator color={color} shape="rectangle" role="presentation" />
276
- {this.isSelectedColor(color) && (
277
- <div css={this.props?.styles?.selectedIndicator}>
278
- <IconCheckDarkSolid
279
- themeOverride={{ sizeXSmall: '0.8rem' }}
280
- size="x-small"
281
- />
282
- </div>
283
- )}
284
- </div>
285
- </View>
286
- )
253
+ renderIndicatorBase = (color: string, selectOnClick?: boolean) => {
254
+ const hexCode = color
255
+ const isSelected = this.isSelectedColor(color)
256
+
257
+ const screenReaderLabel =
258
+ typeof this.props.colorScreenReaderLabel === 'function'
259
+ ? this.props.colorScreenReaderLabel(hexCode, isSelected)
260
+ : hexCode
261
+
262
+ return (
263
+ <View
264
+ disabled={this.props.disabled}
265
+ position="relative"
266
+ width="2.375rem"
267
+ height="2.375rem"
268
+ background="transparent"
269
+ margin="xx-small"
270
+ display="inline-block"
271
+ borderRadius="medium"
272
+ borderWidth="0"
273
+ padding="0"
274
+ cursor={this.props.disabled ? 'not-allowed' : 'auto'}
275
+ as="button"
276
+ aria-label={screenReaderLabel}
277
+ {...(selectOnClick
278
+ ? { onClick: () => this.props.onSelect(color) }
279
+ : {})}
280
+ >
281
+ <div>
282
+ <ColorIndicator color={color} shape="rectangle" role="presentation" />
283
+ {this.isSelectedColor(color) && (
284
+ <div css={this.props?.styles?.selectedIndicator}>
285
+ <IconCheckDarkSolid
286
+ themeOverride={{ sizeXSmall: '0.8rem' }}
287
+ size="x-small"
288
+ />
289
+ </div>
290
+ )}
291
+ </div>
292
+ </View>
293
+ )
294
+ }
287
295
 
288
296
  renderIndicatorTooltip = (child: React.ReactElement, color: string) => {
289
297
  return (
@@ -103,6 +103,18 @@ type ColorPresetOwnProps = {
103
103
  * The currently selected HEX string
104
104
  */
105
105
  selected?: string
106
+ /**
107
+ * A function for formatting the text provided to screen readers about the color.
108
+ *
109
+ * @param {string} hexCode - The hexadecimal color code (e.g., "#FFFFFF") of the current color option. Provided by the component - treat as read-only.
110
+ *
111
+ * @param {boolean} isSelected - Indicates whether this color is currently selected. Provided by the component - treat as read-only.
112
+ *
113
+ * Sets the aria-label attribute of the color.
114
+ *
115
+ * If not set, aria-label defaults to the hex code of the color.
116
+ */
117
+ colorScreenReaderLabel?: (hexCode: string, isSelected: boolean) => string
106
118
  }
107
119
 
108
120
  type ColorPresetState = {
@@ -138,6 +150,7 @@ const propTypes: PropValidators<PropKeys> = {
138
150
  elementRef: PropTypes.func,
139
151
  label: PropTypes.string,
140
152
  popoverScreenReaderLabel: PropTypes.string,
153
+ colorScreenReaderLabel: PropTypes.func,
141
154
  colorMixerSettings: PropTypes.shape({
142
155
  addNewPresetButtonScreenReaderLabel: PropTypes.string.isRequired,
143
156
  selectColorLabel: PropTypes.string.isRequired,
@@ -181,7 +194,8 @@ const allowedProps: AllowedPropKeys = [
181
194
  'colorMixerSettings',
182
195
  'onSelect',
183
196
  'popoverScreenReaderLabel',
184
- 'selected'
197
+ 'selected',
198
+ 'colorScreenReaderLabel'
185
199
  ]
186
200
 
187
201
  export type {