@instructure/ui-color-picker 8.44.1-snapshot-2 → 8.44.1-snapshot-3

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
- ## [8.44.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v8.44.0...v8.44.1-snapshot-2) (2023-09-28)
6
+ ## [8.44.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v8.44.0...v8.44.1-snapshot-3) (2023-09-29)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-color-picker
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-color-picker:** add a padding to colorpicker button ([de420dd](https://github.com/instructure/instructure-ui/commit/de420ddd06328b58789474c47121d15894c958a1))
9
12
 
10
13
 
11
14
 
@@ -62,6 +62,19 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
62
62
  elementRef(el);
63
63
  }
64
64
  };
65
+ this.inputContainerRef = null;
66
+ this.handleInputContainerRef = el => {
67
+ this.inputContainerRef = el;
68
+ this.setLabelHeight();
69
+ };
70
+ this.setLabelHeight = () => {
71
+ if (this.inputContainerRef) {
72
+ var _this$inputContainerR;
73
+ this.setState({
74
+ labelHeight: this.inputContainerRef.getBoundingClientRect().y - (((_this$inputContainerR = this.inputContainerRef.parentElement) === null || _this$inputContainerR === void 0 ? void 0 : _this$inputContainerR.getBoundingClientRect().y) || 0)
75
+ });
76
+ }
77
+ };
65
78
  this.checkSettings = () => {
66
79
  if (this.props.children && this.props.colorMixerSettings) {
67
80
  warn(false, 'You should either use children, colorMixerSettings or neither, not both. In this case, the colorMixerSettings will be ignored.', '');
@@ -190,7 +203,8 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
190
203
  hexCode: '',
191
204
  showHelperErrorMessages: false,
192
205
  openColorPicker: false,
193
- mixedColor: ''
206
+ mixedColor: '',
207
+ labelHeight: 0
194
208
  };
195
209
  }
196
210
  componentDidMount() {
@@ -400,13 +414,17 @@ let ColorPicker = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
400
414
  },
401
415
  renderAfterInput: this.renderAfterInput(),
402
416
  renderBeforeInput: this.renderBeforeInput(),
417
+ inputContainerRef: this.handleInputContainerRef,
403
418
  value: this.state.hexCode,
404
419
  onChange: (event, value) => this.handleOnChange(event, value),
405
420
  onPaste: event => this.handleOnPaste(event),
406
421
  onBlur: () => this.handleOnBlur(),
407
422
  messages: this.renderMessages()
408
423
  }), !this.isSimple && jsx("div", {
409
- css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.colorMixerButtonContainer
424
+ css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.colorMixerButtonContainer,
425
+ style: {
426
+ paddingTop: this.state.labelHeight
427
+ }
410
428
  }, jsx("div", {
411
429
  css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.colorMixerButtonWrapper
412
430
  }, this.renderPopover())));
@@ -102,7 +102,7 @@ const generateStyle = (componentTheme, props, state) => {
102
102
  },
103
103
  colorMixerButtonContainer: {
104
104
  label: 'colorPicker__colorMixerButtonContainer',
105
- alignSelf: 'flex-end',
105
+ alignSelf: 'flex-start',
106
106
  marginInlineStart: componentTheme.colorMixerButtonContainerLeftMargin
107
107
  },
108
108
  popoverContentContainer: {
@@ -74,6 +74,19 @@ let ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
74
74
  elementRef(el);
75
75
  }
76
76
  };
77
+ this.inputContainerRef = null;
78
+ this.handleInputContainerRef = el => {
79
+ this.inputContainerRef = el;
80
+ this.setLabelHeight();
81
+ };
82
+ this.setLabelHeight = () => {
83
+ if (this.inputContainerRef) {
84
+ var _this$inputContainerR;
85
+ this.setState({
86
+ labelHeight: this.inputContainerRef.getBoundingClientRect().y - (((_this$inputContainerR = this.inputContainerRef.parentElement) === null || _this$inputContainerR === void 0 ? void 0 : _this$inputContainerR.getBoundingClientRect().y) || 0)
87
+ });
88
+ }
89
+ };
77
90
  this.checkSettings = () => {
78
91
  if (this.props.children && this.props.colorMixerSettings) {
79
92
  (0, _console.warn)(false, 'You should either use children, colorMixerSettings or neither, not both. In this case, the colorMixerSettings will be ignored.', '');
@@ -202,7 +215,8 @@ let ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
202
215
  hexCode: '',
203
216
  showHelperErrorMessages: false,
204
217
  openColorPicker: false,
205
- mixedColor: ''
218
+ mixedColor: '',
219
+ labelHeight: 0
206
220
  };
207
221
  }
208
222
  componentDidMount() {
@@ -412,13 +426,17 @@ let ColorPicker = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defaul
412
426
  },
413
427
  renderAfterInput: this.renderAfterInput(),
414
428
  renderBeforeInput: this.renderBeforeInput(),
429
+ inputContainerRef: this.handleInputContainerRef,
415
430
  value: this.state.hexCode,
416
431
  onChange: (event, value) => this.handleOnChange(event, value),
417
432
  onPaste: event => this.handleOnPaste(event),
418
433
  onBlur: () => this.handleOnBlur(),
419
434
  messages: this.renderMessages()
420
435
  }), !this.isSimple && (0, _emotion.jsx)("div", {
421
- css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.colorMixerButtonContainer
436
+ css: (_this$props$styles7 = this.props.styles) === null || _this$props$styles7 === void 0 ? void 0 : _this$props$styles7.colorMixerButtonContainer,
437
+ style: {
438
+ paddingTop: this.state.labelHeight
439
+ }
422
440
  }, (0, _emotion.jsx)("div", {
423
441
  css: (_this$props$styles8 = this.props.styles) === null || _this$props$styles8 === void 0 ? void 0 : _this$props$styles8.colorMixerButtonWrapper
424
442
  }, this.renderPopover())));
@@ -108,7 +108,7 @@ const generateStyle = (componentTheme, props, state) => {
108
108
  },
109
109
  colorMixerButtonContainer: {
110
110
  label: 'colorPicker__colorMixerButtonContainer',
111
- alignSelf: 'flex-end',
111
+ alignSelf: 'flex-start',
112
112
  marginInlineStart: componentTheme.colorMixerButtonContainerLeftMargin
113
113
  },
114
114
  popoverContentContainer: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-color-picker",
3
- "version": "8.44.1-snapshot-2",
3
+ "version": "8.44.1-snapshot-3",
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.22.15",
27
- "@instructure/console": "8.44.1-snapshot-2",
28
- "@instructure/emotion": "8.44.1-snapshot-2",
29
- "@instructure/shared-types": "8.44.1-snapshot-2",
30
- "@instructure/ui-a11y-content": "8.44.1-snapshot-2",
31
- "@instructure/ui-buttons": "8.44.1-snapshot-2",
32
- "@instructure/ui-color-utils": "8.44.1-snapshot-2",
33
- "@instructure/ui-dom-utils": "8.44.1-snapshot-2",
34
- "@instructure/ui-drilldown": "8.44.1-snapshot-2",
35
- "@instructure/ui-form-field": "8.44.1-snapshot-2",
36
- "@instructure/ui-icons": "8.44.1-snapshot-2",
37
- "@instructure/ui-pill": "8.44.1-snapshot-2",
38
- "@instructure/ui-popover": "8.44.1-snapshot-2",
39
- "@instructure/ui-react-utils": "8.44.1-snapshot-2",
40
- "@instructure/ui-testable": "8.44.1-snapshot-2",
41
- "@instructure/ui-text": "8.44.1-snapshot-2",
42
- "@instructure/ui-text-input": "8.44.1-snapshot-2",
43
- "@instructure/ui-themes": "8.44.1-snapshot-2",
44
- "@instructure/ui-tooltip": "8.44.1-snapshot-2",
45
- "@instructure/ui-utils": "8.44.1-snapshot-2",
46
- "@instructure/ui-view": "8.44.1-snapshot-2",
27
+ "@instructure/console": "8.44.1-snapshot-3",
28
+ "@instructure/emotion": "8.44.1-snapshot-3",
29
+ "@instructure/shared-types": "8.44.1-snapshot-3",
30
+ "@instructure/ui-a11y-content": "8.44.1-snapshot-3",
31
+ "@instructure/ui-buttons": "8.44.1-snapshot-3",
32
+ "@instructure/ui-color-utils": "8.44.1-snapshot-3",
33
+ "@instructure/ui-dom-utils": "8.44.1-snapshot-3",
34
+ "@instructure/ui-drilldown": "8.44.1-snapshot-3",
35
+ "@instructure/ui-form-field": "8.44.1-snapshot-3",
36
+ "@instructure/ui-icons": "8.44.1-snapshot-3",
37
+ "@instructure/ui-pill": "8.44.1-snapshot-3",
38
+ "@instructure/ui-popover": "8.44.1-snapshot-3",
39
+ "@instructure/ui-react-utils": "8.44.1-snapshot-3",
40
+ "@instructure/ui-testable": "8.44.1-snapshot-3",
41
+ "@instructure/ui-text": "8.44.1-snapshot-3",
42
+ "@instructure/ui-text-input": "8.44.1-snapshot-3",
43
+ "@instructure/ui-themes": "8.44.1-snapshot-3",
44
+ "@instructure/ui-tooltip": "8.44.1-snapshot-3",
45
+ "@instructure/ui-utils": "8.44.1-snapshot-3",
46
+ "@instructure/ui-view": "8.44.1-snapshot-3",
47
47
  "prop-types": "^15.8.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@instructure/ui-babel-preset": "8.44.1-snapshot-2",
51
- "@instructure/ui-test-locator": "8.44.1-snapshot-2",
52
- "@instructure/ui-test-queries": "8.44.1-snapshot-2",
53
- "@instructure/ui-test-utils": "8.44.1-snapshot-2"
50
+ "@instructure/ui-babel-preset": "8.44.1-snapshot-3",
51
+ "@instructure/ui-test-locator": "8.44.1-snapshot-3",
52
+ "@instructure/ui-test-queries": "8.44.1-snapshot-3",
53
+ "@instructure/ui-test-utils": "8.44.1-snapshot-3"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": ">=16.8 <=18"
@@ -116,7 +116,8 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
116
116
  hexCode: '',
117
117
  showHelperErrorMessages: false,
118
118
  openColorPicker: false,
119
- mixedColor: ''
119
+ mixedColor: '',
120
+ labelHeight: 0
120
121
  }
121
122
  }
122
123
 
@@ -132,6 +133,23 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
132
133
  }
133
134
  }
134
135
 
136
+ inputContainerRef: Element | null = null
137
+
138
+ handleInputContainerRef = (el: Element | null) => {
139
+ this.inputContainerRef = el
140
+ this.setLabelHeight()
141
+ }
142
+
143
+ setLabelHeight = () => {
144
+ if (this.inputContainerRef) {
145
+ this.setState({
146
+ labelHeight:
147
+ this.inputContainerRef.getBoundingClientRect().y -
148
+ (this.inputContainerRef.parentElement?.getBoundingClientRect().y || 0)
149
+ })
150
+ }
151
+ }
152
+
135
153
  componentDidMount() {
136
154
  this.props.makeStyles?.({ ...this.state, isSimple: this.isSimple })
137
155
  this.checkSettings()
@@ -591,6 +609,7 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
591
609
  themeOverride={{ padding: '' }}
592
610
  renderAfterInput={this.renderAfterInput()}
593
611
  renderBeforeInput={this.renderBeforeInput()}
612
+ inputContainerRef={this.handleInputContainerRef}
594
613
  value={this.state.hexCode}
595
614
  onChange={(event, value) => this.handleOnChange(event, value)}
596
615
  onPaste={(event) => this.handleOnPaste(event)}
@@ -598,7 +617,10 @@ class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
598
617
  messages={this.renderMessages()}
599
618
  />
600
619
  {!this.isSimple && (
601
- <div css={this.props.styles?.colorMixerButtonContainer}>
620
+ <div
621
+ css={this.props.styles?.colorMixerButtonContainer}
622
+ style={{ paddingTop: this.state.labelHeight }}
623
+ >
602
624
  <div css={this.props.styles?.colorMixerButtonWrapper}>
603
625
  {this.renderPopover()}
604
626
  </div>
@@ -225,6 +225,7 @@ type ColorPickerState = {
225
225
  showHelperErrorMessages: boolean
226
226
  openColorPicker: boolean
227
227
  mixedColor: string
228
+ labelHeight: number
228
229
  }
229
230
 
230
231
  type PropKeys = keyof ColorPickerOwnProps
@@ -114,7 +114,7 @@ const generateStyle = (
114
114
  },
115
115
  colorMixerButtonContainer: {
116
116
  label: 'colorPicker__colorMixerButtonContainer',
117
- alignSelf: 'flex-end',
117
+ alignSelf: 'flex-start',
118
118
  marginInlineStart: componentTheme.colorMixerButtonContainerLeftMargin
119
119
  },
120
120
  popoverContentContainer: {