@instructure/ui-color-picker 8.28.2 → 8.28.3-snapshot-5
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 +8 -0
- package/es/ColorMixer/ColorPalette/index.js +14 -8
- package/es/ColorMixer/ColorPalette/styles.js +2 -1
- package/es/ColorMixer/ColorPalette/theme.js +2 -1
- package/lib/ColorMixer/ColorPalette/index.js +15 -8
- package/lib/ColorMixer/ColorPalette/styles.js +2 -1
- package/lib/ColorMixer/ColorPalette/theme.js +2 -1
- package/package.json +25 -25
- package/src/ColorMixer/ColorPalette/index.tsx +9 -6
- package/src/ColorMixer/ColorPalette/props.ts +1 -1
- package/src/ColorMixer/ColorPalette/styles.ts +2 -1
- package/src/ColorMixer/ColorPalette/theme.ts +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ColorMixer/ColorPalette/index.d.ts +1 -0
- package/types/ColorMixer/ColorPalette/index.d.ts.map +1 -1
- package/types/ColorMixer/ColorPalette/props.d.ts +1 -1
- package/types/ColorMixer/ColorPalette/props.d.ts.map +1 -1
- package/types/ColorMixer/ColorPalette/styles.d.ts.map +1 -1
- package/types/ColorMixer/ColorPalette/theme.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.28.3-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.28.2...v8.28.3-snapshot-5) (2022-09-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-color-picker
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.28.2](https://github.com/instructure/instructure-ui/compare/v8.28.0...v8.28.2) (2022-09-16)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-color-picker
|
|
@@ -33,6 +33,7 @@ import shallowCompare from '../utils/shallowCompare';
|
|
|
33
33
|
import { propTypes, allowedProps } from './props';
|
|
34
34
|
import generateStyle from './styles';
|
|
35
35
|
import generateComponentTheme from './theme';
|
|
36
|
+
import { px } from '@instructure/ui-utils';
|
|
36
37
|
/**
|
|
37
38
|
---
|
|
38
39
|
private: true
|
|
@@ -42,11 +43,14 @@ private: true
|
|
|
42
43
|
|
|
43
44
|
let ColorPalette = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = (_class2 = class ColorPalette extends Component {
|
|
44
45
|
constructor(props) {
|
|
46
|
+
var _this$props$styles;
|
|
47
|
+
|
|
45
48
|
super(props);
|
|
46
49
|
this.ref = null;
|
|
47
50
|
this._paletteRef = null;
|
|
48
51
|
this._mouseMoveListener = void 0;
|
|
49
52
|
this._mouseUpListener = void 0;
|
|
53
|
+
this._paletteOffset = px((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.paletteOffset);
|
|
50
54
|
|
|
51
55
|
this.handleRef = el => {
|
|
52
56
|
const elementRef = this.props.elementRef;
|
|
@@ -121,19 +125,21 @@ let ColorPalette = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
get paletteWidth() {
|
|
124
|
-
return this._paletteRef.getBoundingClientRect().width;
|
|
128
|
+
return this._paletteRef.getBoundingClientRect().width - this._paletteOffset;
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
get paletteHeight() {
|
|
128
|
-
return this._paletteRef.getBoundingClientRect().height;
|
|
132
|
+
return this._paletteRef.getBoundingClientRect().height - this._paletteOffset;
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
calcPositionFromColor(hsv) {
|
|
132
136
|
const s = hsv.s,
|
|
133
137
|
v = hsv.v;
|
|
138
|
+
const x = s * this.paletteWidth;
|
|
139
|
+
const y = (1 - v) * this.paletteHeight;
|
|
134
140
|
return {
|
|
135
|
-
x
|
|
136
|
-
y
|
|
141
|
+
x,
|
|
142
|
+
y
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
145
|
|
|
@@ -226,7 +232,7 @@ let ColorPalette = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
226
232
|
}
|
|
227
233
|
|
|
228
234
|
render() {
|
|
229
|
-
var _this$props$
|
|
235
|
+
var _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
230
236
|
|
|
231
237
|
return jsx(View, {
|
|
232
238
|
elementRef: this.handleRef,
|
|
@@ -243,11 +249,11 @@ let ColorPalette = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
243
249
|
onMouseDown: e => this.handlePaletteMouseDown(e),
|
|
244
250
|
"aria-label": this.props.navigationExplanationScreenReaderLabel
|
|
245
251
|
}, jsx("div", {
|
|
246
|
-
css: (_this$props$
|
|
252
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.indicator
|
|
247
253
|
}), this.props.disabled && jsx("div", {
|
|
248
|
-
css: (_this$props$
|
|
254
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.disabledOverlay
|
|
249
255
|
}), jsx("div", {
|
|
250
|
-
css: (_this$props$
|
|
256
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.palette,
|
|
251
257
|
ref: ref => {
|
|
252
258
|
this._paletteRef = ref;
|
|
253
259
|
}
|
|
@@ -39,7 +39,8 @@ const generateComponentTheme = theme => {
|
|
|
39
39
|
indicatorBorderWidth: borders.widthSmall,
|
|
40
40
|
paletteBorderRadius: borders.radiusMedium,
|
|
41
41
|
paletteBorderWidth: borders.widthSmall,
|
|
42
|
-
disabledOverlayZIndex: stacking.topmost
|
|
42
|
+
disabledOverlayZIndex: stacking.topmost,
|
|
43
|
+
paletteOffset: '0.125rem'
|
|
43
44
|
};
|
|
44
45
|
return { ...componentVariables
|
|
45
46
|
};
|
|
@@ -25,6 +25,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
25
25
|
|
|
26
26
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
27
27
|
|
|
28
|
+
var _px = require("@instructure/ui-utils/lib/px.js");
|
|
29
|
+
|
|
28
30
|
var _dec, _class, _class2;
|
|
29
31
|
|
|
30
32
|
/**
|
|
@@ -35,11 +37,14 @@ private: true
|
|
|
35
37
|
**/
|
|
36
38
|
let ColorPalette = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_class2 = class ColorPalette extends _react.Component {
|
|
37
39
|
constructor(props) {
|
|
40
|
+
var _this$props$styles;
|
|
41
|
+
|
|
38
42
|
super(props);
|
|
39
43
|
this.ref = null;
|
|
40
44
|
this._paletteRef = null;
|
|
41
45
|
this._mouseMoveListener = void 0;
|
|
42
46
|
this._mouseUpListener = void 0;
|
|
47
|
+
this._paletteOffset = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.paletteOffset);
|
|
43
48
|
|
|
44
49
|
this.handleRef = el => {
|
|
45
50
|
const elementRef = this.props.elementRef;
|
|
@@ -114,19 +119,21 @@ let ColorPalette = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
get paletteWidth() {
|
|
117
|
-
return this._paletteRef.getBoundingClientRect().width;
|
|
122
|
+
return this._paletteRef.getBoundingClientRect().width - this._paletteOffset;
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
get paletteHeight() {
|
|
121
|
-
return this._paletteRef.getBoundingClientRect().height;
|
|
126
|
+
return this._paletteRef.getBoundingClientRect().height - this._paletteOffset;
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
calcPositionFromColor(hsv) {
|
|
125
130
|
const s = hsv.s,
|
|
126
131
|
v = hsv.v;
|
|
132
|
+
const x = s * this.paletteWidth;
|
|
133
|
+
const y = (1 - v) * this.paletteHeight;
|
|
127
134
|
return {
|
|
128
|
-
x
|
|
129
|
-
y
|
|
135
|
+
x,
|
|
136
|
+
y
|
|
130
137
|
};
|
|
131
138
|
}
|
|
132
139
|
|
|
@@ -219,7 +226,7 @@ let ColorPalette = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
render() {
|
|
222
|
-
var _this$props$
|
|
229
|
+
var _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
223
230
|
|
|
224
231
|
return (0, _emotion.jsx)(_View.View, {
|
|
225
232
|
elementRef: this.handleRef,
|
|
@@ -236,11 +243,11 @@ let ColorPalette = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
236
243
|
onMouseDown: e => this.handlePaletteMouseDown(e),
|
|
237
244
|
"aria-label": this.props.navigationExplanationScreenReaderLabel
|
|
238
245
|
}, (0, _emotion.jsx)("div", {
|
|
239
|
-
css: (_this$props$
|
|
246
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.indicator
|
|
240
247
|
}), this.props.disabled && (0, _emotion.jsx)("div", {
|
|
241
|
-
css: (_this$props$
|
|
248
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.disabledOverlay
|
|
242
249
|
}), (0, _emotion.jsx)("div", {
|
|
243
|
-
css: (_this$props$
|
|
250
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.palette,
|
|
244
251
|
ref: ref => {
|
|
245
252
|
this._paletteRef = ref;
|
|
246
253
|
}
|
|
@@ -47,7 +47,8 @@ const generateComponentTheme = theme => {
|
|
|
47
47
|
indicatorBorderWidth: borders.widthSmall,
|
|
48
48
|
paletteBorderRadius: borders.radiusMedium,
|
|
49
49
|
paletteBorderWidth: borders.widthSmall,
|
|
50
|
-
disabledOverlayZIndex: stacking.topmost
|
|
50
|
+
disabledOverlayZIndex: stacking.topmost,
|
|
51
|
+
paletteOffset: '0.125rem'
|
|
51
52
|
};
|
|
52
53
|
return { ...componentVariables
|
|
53
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-color-picker",
|
|
3
|
-
"version": "8.28.
|
|
3
|
+
"version": "8.28.3-snapshot-5",
|
|
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.13.10",
|
|
27
|
-
"@instructure/console": "8.28.
|
|
28
|
-
"@instructure/emotion": "8.28.
|
|
29
|
-
"@instructure/shared-types": "8.28.
|
|
30
|
-
"@instructure/ui-a11y-content": "8.28.
|
|
31
|
-
"@instructure/ui-buttons": "8.28.
|
|
32
|
-
"@instructure/ui-color-utils": "8.28.
|
|
33
|
-
"@instructure/ui-dom-utils": "8.28.
|
|
34
|
-
"@instructure/ui-drilldown": "8.28.
|
|
35
|
-
"@instructure/ui-form-field": "8.28.
|
|
36
|
-
"@instructure/ui-icons": "8.28.
|
|
37
|
-
"@instructure/ui-pill": "8.28.
|
|
38
|
-
"@instructure/ui-popover": "8.28.
|
|
39
|
-
"@instructure/ui-react-utils": "8.28.
|
|
40
|
-
"@instructure/ui-testable": "8.28.
|
|
41
|
-
"@instructure/ui-text": "8.28.
|
|
42
|
-
"@instructure/ui-text-input": "8.28.
|
|
43
|
-
"@instructure/ui-themes": "8.28.
|
|
44
|
-
"@instructure/ui-tooltip": "8.28.
|
|
45
|
-
"@instructure/ui-utils": "8.28.
|
|
46
|
-
"@instructure/ui-view": "8.28.
|
|
27
|
+
"@instructure/console": "8.28.3-snapshot-5",
|
|
28
|
+
"@instructure/emotion": "8.28.3-snapshot-5",
|
|
29
|
+
"@instructure/shared-types": "8.28.3-snapshot-5",
|
|
30
|
+
"@instructure/ui-a11y-content": "8.28.3-snapshot-5",
|
|
31
|
+
"@instructure/ui-buttons": "8.28.3-snapshot-5",
|
|
32
|
+
"@instructure/ui-color-utils": "8.28.3-snapshot-5",
|
|
33
|
+
"@instructure/ui-dom-utils": "8.28.3-snapshot-5",
|
|
34
|
+
"@instructure/ui-drilldown": "8.28.3-snapshot-5",
|
|
35
|
+
"@instructure/ui-form-field": "8.28.3-snapshot-5",
|
|
36
|
+
"@instructure/ui-icons": "8.28.3-snapshot-5",
|
|
37
|
+
"@instructure/ui-pill": "8.28.3-snapshot-5",
|
|
38
|
+
"@instructure/ui-popover": "8.28.3-snapshot-5",
|
|
39
|
+
"@instructure/ui-react-utils": "8.28.3-snapshot-5",
|
|
40
|
+
"@instructure/ui-testable": "8.28.3-snapshot-5",
|
|
41
|
+
"@instructure/ui-text": "8.28.3-snapshot-5",
|
|
42
|
+
"@instructure/ui-text-input": "8.28.3-snapshot-5",
|
|
43
|
+
"@instructure/ui-themes": "8.28.3-snapshot-5",
|
|
44
|
+
"@instructure/ui-tooltip": "8.28.3-snapshot-5",
|
|
45
|
+
"@instructure/ui-utils": "8.28.3-snapshot-5",
|
|
46
|
+
"@instructure/ui-view": "8.28.3-snapshot-5",
|
|
47
47
|
"prop-types": "^15"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@instructure/ui-babel-preset": "8.28.
|
|
51
|
-
"@instructure/ui-test-locator": "8.28.
|
|
52
|
-
"@instructure/ui-test-queries": "8.28.
|
|
53
|
-
"@instructure/ui-test-utils": "8.28.
|
|
50
|
+
"@instructure/ui-babel-preset": "8.28.3-snapshot-5",
|
|
51
|
+
"@instructure/ui-test-locator": "8.28.3-snapshot-5",
|
|
52
|
+
"@instructure/ui-test-queries": "8.28.3-snapshot-5",
|
|
53
|
+
"@instructure/ui-test-utils": "8.28.3-snapshot-5"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": ">=16.8 <=18"
|
|
@@ -39,6 +39,7 @@ import type { ColorPaletteProps, ColorPaletteState } from './props'
|
|
|
39
39
|
|
|
40
40
|
import generateStyle from './styles'
|
|
41
41
|
import generateComponentTheme from './theme'
|
|
42
|
+
import { px } from '@instructure/ui-utils'
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
---
|
|
@@ -63,6 +64,7 @@ class ColorPalette extends Component<ColorPaletteProps, ColorPaletteState> {
|
|
|
63
64
|
private _paletteRef: HTMLDivElement | null = null
|
|
64
65
|
private _mouseMoveListener?: { remove(): void }
|
|
65
66
|
private _mouseUpListener?: { remove(): void }
|
|
67
|
+
private _paletteOffset = px(this.props.styles?.paletteOffset as string)
|
|
66
68
|
|
|
67
69
|
handleRef = (el: Element | null) => {
|
|
68
70
|
const { elementRef } = this.props
|
|
@@ -95,11 +97,13 @@ class ColorPalette extends Component<ColorPaletteProps, ColorPaletteState> {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
get paletteWidth() {
|
|
98
|
-
return this._paletteRef!.getBoundingClientRect().width
|
|
100
|
+
return this._paletteRef!.getBoundingClientRect().width - this._paletteOffset
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
get paletteHeight() {
|
|
102
|
-
return
|
|
104
|
+
return (
|
|
105
|
+
this._paletteRef!.getBoundingClientRect().height - this._paletteOffset
|
|
106
|
+
)
|
|
103
107
|
}
|
|
104
108
|
calcSaturation = (position: number) =>
|
|
105
109
|
Math.round((position / this.paletteWidth) * 100) / 100
|
|
@@ -109,10 +113,9 @@ class ColorPalette extends Component<ColorPaletteProps, ColorPaletteState> {
|
|
|
109
113
|
|
|
110
114
|
calcPositionFromColor(hsv: HSVType) {
|
|
111
115
|
const { s, v } = hsv
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
+
const x = s * this.paletteWidth
|
|
117
|
+
const y = (1 - v) * this.paletteHeight
|
|
118
|
+
return { x, y }
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
handlePaletteMouseDown(e: React.MouseEvent<ViewOwnProps, MouseEvent>) {
|
|
@@ -57,7 +57,7 @@ type ColorPaletteProps = ColorPaletteOwnProps &
|
|
|
57
57
|
OtherHTMLAttributes<ColorPaletteOwnProps>
|
|
58
58
|
|
|
59
59
|
type ColorPaletteStyle = ComponentStyle<
|
|
60
|
-
'ColorPalette' | 'indicator' | 'palette' | 'disabledOverlay'
|
|
60
|
+
'ColorPalette' | 'indicator' | 'palette' | 'disabledOverlay' | 'paletteOffset'
|
|
61
61
|
>
|
|
62
62
|
|
|
63
63
|
const propTypes: PropValidators<PropKeys> = {
|
|
@@ -41,7 +41,8 @@ const generateComponentTheme = (theme: Theme): ColorMixerPaletteTheme => {
|
|
|
41
41
|
indicatorBorderWidth: borders.widthSmall,
|
|
42
42
|
paletteBorderRadius: borders.radiusMedium,
|
|
43
43
|
paletteBorderWidth: borders.widthSmall,
|
|
44
|
-
disabledOverlayZIndex: stacking.topmost
|
|
44
|
+
disabledOverlayZIndex: stacking.topmost,
|
|
45
|
+
paletteOffset: '0.125rem'
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return {
|