@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 +5 -2
- package/es/ColorPreset/index.js +4 -1
- package/es/ColorPreset/props.js +2 -1
- package/lib/ColorPreset/index.js +4 -1
- package/lib/ColorPreset/props.js +2 -1
- package/package.json +25 -25
- package/src/ColorPreset/README.md +20 -0
- package/src/ColorPreset/index.tsx +42 -34
- package/src/ColorPreset/props.ts +15 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ColorPreset/index.d.ts +2 -0
- package/types/ColorPreset/index.d.ts.map +1 -1
- package/types/ColorPreset/props.d.ts +12 -0
- package/types/ColorPreset/props.d.ts.map +1 -1
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-
|
|
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
|
-
|
|
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
|
|
package/es/ColorPreset/index.js
CHANGED
|
@@ -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,
|
package/es/ColorPreset/props.js
CHANGED
|
@@ -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 };
|
package/lib/ColorPreset/index.js
CHANGED
|
@@ -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,
|
package/lib/ColorPreset/props.js
CHANGED
|
@@ -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-
|
|
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-
|
|
28
|
-
"@instructure/emotion": "10.20.2-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.20.2-snapshot-
|
|
30
|
-
"@instructure/ui-a11y-content": "10.20.2-snapshot-
|
|
31
|
-
"@instructure/ui-buttons": "10.20.2-snapshot-
|
|
32
|
-
"@instructure/ui-color-utils": "10.20.2-snapshot-
|
|
33
|
-
"@instructure/ui-dom-utils": "10.20.2-snapshot-
|
|
34
|
-
"@instructure/ui-drilldown": "10.20.2-snapshot-
|
|
35
|
-
"@instructure/ui-form-field": "10.20.2-snapshot-
|
|
36
|
-
"@instructure/ui-icons": "10.20.2-snapshot-
|
|
37
|
-
"@instructure/ui-pill": "10.20.2-snapshot-
|
|
38
|
-
"@instructure/ui-popover": "10.20.2-snapshot-
|
|
39
|
-
"@instructure/ui-react-utils": "10.20.2-snapshot-
|
|
40
|
-
"@instructure/ui-testable": "10.20.2-snapshot-
|
|
41
|
-
"@instructure/ui-text": "10.20.2-snapshot-
|
|
42
|
-
"@instructure/ui-text-input": "10.20.2-snapshot-
|
|
43
|
-
"@instructure/ui-themes": "10.20.2-snapshot-
|
|
44
|
-
"@instructure/ui-tooltip": "10.20.2-snapshot-
|
|
45
|
-
"@instructure/ui-utils": "10.20.2-snapshot-
|
|
46
|
-
"@instructure/ui-view": "10.20.2-snapshot-
|
|
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-
|
|
51
|
-
"@instructure/ui-babel-preset": "10.20.2-snapshot-
|
|
52
|
-
"@instructure/ui-scripts": "10.20.2-snapshot-
|
|
53
|
-
"@instructure/ui-test-utils": "10.20.2-snapshot-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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 (
|
package/src/ColorPreset/props.ts
CHANGED
|
@@ -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 {
|