@instructure/ui-color-picker 8.56.0 → 8.56.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
+ ## [8.56.1](https://github.com/instructure/instructure-ui/compare/v8.56.0...v8.56.1) (2024-06-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-color-picker:** add disabled styling for ColorPreset ([5fda291](https://github.com/instructure/instructure-ui/commit/5fda2914d9b0162e88f44073e1353176a16d05ed))
12
+
13
+
14
+
15
+
16
+
6
17
  # [8.56.0](https://github.com/instructure/instructure-ui/compare/v8.55.1...v8.56.0) (2024-05-06)
7
18
 
8
19
  **Note:** Version bump only for package @instructure/ui-color-picker
@@ -145,10 +145,12 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
145
145
  }, (_this$props$colorMixe3 = this.props.colorMixerSettings) === null || _this$props$colorMixe3 === void 0 ? void 0 : _this$props$colorMixe3.popoverCloseButtonLabel)));
146
146
  };
147
147
  this.renderColorIndicator = (color, selectOnClick) => {
148
+ const indicatorBase = this.renderIndicatorBase(color, selectOnClick);
149
+ return this.props.disabled ? indicatorBase : this.renderIndicatorTooltip(indicatorBase, color);
150
+ };
151
+ this.renderIndicatorBase = (color, selectOnClick) => {
148
152
  var _this$props6, _this$props6$styles;
149
- return jsx(Tooltip, {
150
- renderTip: jsx("div", null, color)
151
- }, jsx(View, Object.assign({
153
+ return jsx(View, Object.assign({
152
154
  disabled: this.props.disabled,
153
155
  position: "relative",
154
156
  width: "2.375rem",
@@ -159,6 +161,7 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
159
161
  borderRadius: "medium",
160
162
  borderWidth: "0",
161
163
  padding: "0",
164
+ cursor: this.props.disabled ? 'not-allowed' : 'auto',
162
165
  as: "button"
163
166
  }, selectOnClick ? {
164
167
  onClick: () => this.props.onSelect(color)
@@ -175,8 +178,11 @@ let ColorPreset = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
175
178
  sizeXSmall: '0.8rem'
176
179
  },
177
180
  size: "x-small"
178
- })))));
181
+ }))));
179
182
  };
183
+ this.renderIndicatorTooltip = (child, color) => jsx(Tooltip, {
184
+ renderTip: jsx("div", null, color)
185
+ }, child);
180
186
  this.renderSettingsMenu = (color, index) => jsx(Drilldown, {
181
187
  onSelect: this.onMenuItemSelected(color),
182
188
  trigger: this.renderColorIndicator(color),
@@ -33,13 +33,17 @@
33
33
  * @return {Object} The final style object, which will be used in the component
34
34
  */
35
35
  const generateStyle = (componentTheme, props) => {
36
- const colorMixerSettings = props.colorMixerSettings;
36
+ const colorMixerSettings = props.colorMixerSettings,
37
+ disabled = props.disabled;
37
38
  return {
38
39
  colorPreset: {
39
40
  label: 'colorPreset',
40
41
  display: 'flex',
41
42
  flexWrap: 'wrap',
42
- width: '17rem'
43
+ width: '17rem',
44
+ ...(disabled && {
45
+ opacity: 0.5
46
+ })
43
47
  },
44
48
  addNewPresetButton: {
45
49
  label: 'colorPreset__addNewPresetButton',
@@ -152,10 +152,12 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
152
152
  }, (_this$props$colorMixe3 = this.props.colorMixerSettings) === null || _this$props$colorMixe3 === void 0 ? void 0 : _this$props$colorMixe3.popoverCloseButtonLabel)));
153
153
  };
154
154
  this.renderColorIndicator = (color, selectOnClick) => {
155
+ const indicatorBase = this.renderIndicatorBase(color, selectOnClick);
156
+ return this.props.disabled ? indicatorBase : this.renderIndicatorTooltip(indicatorBase, color);
157
+ };
158
+ this.renderIndicatorBase = (color, selectOnClick) => {
155
159
  var _this$props6, _this$props6$styles;
156
- return (0, _emotion.jsx)(_Tooltip.Tooltip, {
157
- renderTip: (0, _emotion.jsx)("div", null, color)
158
- }, (0, _emotion.jsx)(_View.View, Object.assign({
160
+ return (0, _emotion.jsx)(_View.View, Object.assign({
159
161
  disabled: this.props.disabled,
160
162
  position: "relative",
161
163
  width: "2.375rem",
@@ -166,6 +168,7 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
166
168
  borderRadius: "medium",
167
169
  borderWidth: "0",
168
170
  padding: "0",
171
+ cursor: this.props.disabled ? 'not-allowed' : 'auto',
169
172
  as: "button"
170
173
  }, selectOnClick ? {
171
174
  onClick: () => this.props.onSelect(color)
@@ -182,8 +185,11 @@ let ColorPreset = exports.ColorPreset = (_dec = (0, _emotion.withStyle)(_styles.
182
185
  sizeXSmall: '0.8rem'
183
186
  },
184
187
  size: "x-small"
185
- })))));
188
+ }))));
186
189
  };
190
+ this.renderIndicatorTooltip = (child, color) => (0, _emotion.jsx)(_Tooltip.Tooltip, {
191
+ renderTip: (0, _emotion.jsx)("div", null, color)
192
+ }, child);
187
193
  this.renderSettingsMenu = (color, index) => (0, _emotion.jsx)(_Drilldown.Drilldown, {
188
194
  onSelect: this.onMenuItemSelected(color),
189
195
  trigger: this.renderColorIndicator(color),
@@ -39,13 +39,17 @@ exports.default = void 0;
39
39
  * @return {Object} The final style object, which will be used in the component
40
40
  */
41
41
  const generateStyle = (componentTheme, props) => {
42
- const colorMixerSettings = props.colorMixerSettings;
42
+ const colorMixerSettings = props.colorMixerSettings,
43
+ disabled = props.disabled;
43
44
  return {
44
45
  colorPreset: {
45
46
  label: 'colorPreset',
46
47
  display: 'flex',
47
48
  flexWrap: 'wrap',
48
- width: '17rem'
49
+ width: '17rem',
50
+ ...(disabled && {
51
+ opacity: 0.5
52
+ })
49
53
  },
50
54
  addNewPresetButton: {
51
55
  label: 'colorPreset__addNewPresetButton',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-color-picker",
3
- "version": "8.56.0",
3
+ "version": "8.56.1",
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.23.2",
27
- "@instructure/console": "8.56.0",
28
- "@instructure/emotion": "8.56.0",
29
- "@instructure/shared-types": "8.56.0",
30
- "@instructure/ui-a11y-content": "8.56.0",
31
- "@instructure/ui-buttons": "8.56.0",
32
- "@instructure/ui-color-utils": "8.56.0",
33
- "@instructure/ui-dom-utils": "8.56.0",
34
- "@instructure/ui-drilldown": "8.56.0",
35
- "@instructure/ui-form-field": "8.56.0",
36
- "@instructure/ui-icons": "8.56.0",
37
- "@instructure/ui-pill": "8.56.0",
38
- "@instructure/ui-popover": "8.56.0",
39
- "@instructure/ui-react-utils": "8.56.0",
40
- "@instructure/ui-testable": "8.56.0",
41
- "@instructure/ui-text": "8.56.0",
42
- "@instructure/ui-text-input": "8.56.0",
43
- "@instructure/ui-themes": "8.56.0",
44
- "@instructure/ui-tooltip": "8.56.0",
45
- "@instructure/ui-utils": "8.56.0",
46
- "@instructure/ui-view": "8.56.0",
27
+ "@instructure/console": "8.56.1",
28
+ "@instructure/emotion": "8.56.1",
29
+ "@instructure/shared-types": "8.56.1",
30
+ "@instructure/ui-a11y-content": "8.56.1",
31
+ "@instructure/ui-buttons": "8.56.1",
32
+ "@instructure/ui-color-utils": "8.56.1",
33
+ "@instructure/ui-dom-utils": "8.56.1",
34
+ "@instructure/ui-drilldown": "8.56.1",
35
+ "@instructure/ui-form-field": "8.56.1",
36
+ "@instructure/ui-icons": "8.56.1",
37
+ "@instructure/ui-pill": "8.56.1",
38
+ "@instructure/ui-popover": "8.56.1",
39
+ "@instructure/ui-react-utils": "8.56.1",
40
+ "@instructure/ui-testable": "8.56.1",
41
+ "@instructure/ui-text": "8.56.1",
42
+ "@instructure/ui-text-input": "8.56.1",
43
+ "@instructure/ui-themes": "8.56.1",
44
+ "@instructure/ui-tooltip": "8.56.1",
45
+ "@instructure/ui-utils": "8.56.1",
46
+ "@instructure/ui-view": "8.56.1",
47
47
  "prop-types": "^15.8.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@instructure/ui-babel-preset": "8.56.0",
51
- "@instructure/ui-test-locator": "8.56.0",
52
- "@instructure/ui-test-queries": "8.56.0",
53
- "@instructure/ui-test-utils": "8.56.0"
50
+ "@instructure/ui-babel-preset": "8.56.1",
51
+ "@instructure/ui-test-locator": "8.56.1",
52
+ "@instructure/ui-test-queries": "8.56.1",
53
+ "@instructure/ui-test-utils": "8.56.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": ">=16.8 <=18"
@@ -241,38 +241,46 @@ class ColorPreset extends Component<ColorPresetProps, ColorPresetState> {
241
241
  </Popover>
242
242
  )
243
243
 
244
- renderColorIndicator = (color: string, selectOnClick?: boolean) => (
245
- <Tooltip renderTip={<div>{color}</div>}>
246
- <View
247
- disabled={this.props.disabled}
248
- position="relative"
249
- width="2.375rem"
250
- height="2.375rem"
251
- background="transparent"
252
- margin="xx-small"
253
- display="inline-block"
254
- borderRadius="medium"
255
- borderWidth="0"
256
- padding="0"
257
- as="button"
258
- {...(selectOnClick
259
- ? { onClick: () => this.props.onSelect(color) }
260
- : {})}
261
- {...(this.isSelectedColor(color) ? { 'aria-label': 'selected' } : {})}
262
- >
263
- <div>
264
- <ColorIndicator color={color} shape="rectangle" role="presentation" />
265
- {this.isSelectedColor(color) && (
266
- <div css={this.props?.styles?.selectedIndicator}>
267
- <IconCheckDarkSolid
268
- themeOverride={{ sizeXSmall: '0.8rem' }}
269
- size="x-small"
270
- />
271
- </div>
272
- )}
273
- </div>
274
- </View>
275
- </Tooltip>
244
+ renderColorIndicator = (color: string, selectOnClick?: boolean) => {
245
+ const indicatorBase = this.renderIndicatorBase(color, selectOnClick)
246
+ return this.props.disabled
247
+ ? indicatorBase
248
+ : this.renderIndicatorTooltip(indicatorBase, color)
249
+ }
250
+
251
+ renderIndicatorBase = (color: string, selectOnClick?: boolean) => (
252
+ <View
253
+ disabled={this.props.disabled}
254
+ position="relative"
255
+ width="2.375rem"
256
+ height="2.375rem"
257
+ background="transparent"
258
+ margin="xx-small"
259
+ display="inline-block"
260
+ borderRadius="medium"
261
+ borderWidth="0"
262
+ padding="0"
263
+ cursor={this.props.disabled ? 'not-allowed' : 'auto'}
264
+ as="button"
265
+ {...(selectOnClick ? { onClick: () => this.props.onSelect(color) } : {})}
266
+ {...(this.isSelectedColor(color) ? { 'aria-label': 'selected' } : {})}
267
+ >
268
+ <div>
269
+ <ColorIndicator color={color} shape="rectangle" role="presentation" />
270
+ {this.isSelectedColor(color) && (
271
+ <div css={this.props?.styles?.selectedIndicator}>
272
+ <IconCheckDarkSolid
273
+ themeOverride={{ sizeXSmall: '0.8rem' }}
274
+ size="x-small"
275
+ />
276
+ </div>
277
+ )}
278
+ </div>
279
+ </View>
280
+ )
281
+
282
+ renderIndicatorTooltip = (child: React.ReactElement, color: string) => (
283
+ <Tooltip renderTip={<div>{color}</div>}>{child}</Tooltip>
276
284
  )
277
285
 
278
286
  renderSettingsMenu = (color: string, index: number) => (
@@ -38,13 +38,16 @@ const generateStyle = (
38
38
  componentTheme: ColorPresetTheme,
39
39
  props: ColorPresetProps
40
40
  ) => {
41
- const { colorMixerSettings } = props
41
+ const { colorMixerSettings, disabled } = props
42
42
  return {
43
43
  colorPreset: {
44
44
  label: 'colorPreset',
45
45
  display: 'flex',
46
46
  flexWrap: 'wrap',
47
- width: '17rem'
47
+ width: '17rem',
48
+ ...(disabled && {
49
+ opacity: 0.5
50
+ })
48
51
  },
49
52
  addNewPresetButton: {
50
53
  label: 'colorPreset__addNewPresetButton',