@loomhq/lens 10.98.1 → 10.98.2

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.
@@ -10,10 +10,48 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useState } from 'react';
13
- import { CustomPicker } from 'react-color';
14
- import { Saturation, Hue, EditableInput, } from 'react-color/lib/components/common';
13
+ import { HexColorPicker, HexColorInput } from 'react-colorful';
15
14
  import styled from '@emotion/styled';
16
15
  import { getRadius, u } from '../../utilities';
16
+ const ColorfulWrapper = styled.div `
17
+ padding: var(--lns-space-medium);
18
+ & .react-colorful {
19
+ width: auto;
20
+ height: auto;
21
+ }
22
+ & .react-colorful__saturation {
23
+ height: ${u(14)};
24
+ border-bottom: none;
25
+ box-shadow: inset 0 0 0 1px var(--lns-color-border);
26
+ border-radius: var(--lns-radius-medium);
27
+ margin-bottom: var(--lns-space-small);
28
+ }
29
+
30
+ & .react-colorful__hue {
31
+ height: ${u(2)};
32
+ width: 100%;
33
+ box-shadow: inset 0 0 0 1px var(--lns-color-border);
34
+ border-radius: 3px;
35
+ margin-bottom: var(--lns-space-medium);
36
+ }
37
+
38
+ & .react-colorful__saturation-pointer {
39
+ width: ${u(1)};
40
+ height: ${u(1)};
41
+ cursor: pointer;
42
+ border: 2px solid white;
43
+ box-shadow: 0 0 0 3px var(--lns-color-border);
44
+ border-radius: var(--lns-radius-medium);
45
+ }
46
+ & .react-colorful__hue-pointer {
47
+ width: ${u(1)};
48
+ height: ${u(2.5)};
49
+ border-radius: 2px;
50
+ box-shadow: 0 0 0 2px var(--lns-color-border);
51
+ cursor: pointer;
52
+ border: 2px solid white;
53
+ }
54
+ `;
17
55
  const ColorPickerContainer = styled.div `
18
56
  position: relative;
19
57
  width: ${u(31)};
@@ -21,29 +59,16 @@ const ColorPickerContainer = styled.div `
21
59
  border-radius: var(--lns-radius-medium);
22
60
  box-shadow: 0 0 0 1px var(--lns-color-border), var(--lns-shadow-medium);
23
61
  `;
24
- const SaturationContainer = styled.div `
25
- position: relative;
26
- height: ${u(14)};
27
- border: 1px solid var(--lns-color-border);
28
- box-shadow: inset 0 0 0 1px var(--lns-color-border);
29
- border-radius: var(--lns-radius-medium);
30
- margin-bottom: var(--lns-space-small);
31
- `;
32
- const HueContainer = styled.div `
33
- position: relative;
34
- width: 100%;
35
- height: ${u(2)};
36
- border: 1px solid var(--lns-color-border);
37
- box-shadow: inset 0 0 0 1px var(--lns-color-border);
38
- border-radius: 3px;
39
- margin-bottom: var(--lns-space-medium);
40
- `;
41
62
  const InputContainer = styled.div `
42
63
  position: relative;
43
64
  width: 100%;
44
65
 
45
66
  input {
46
- padding: ${u(1)};
67
+ padding: 0 0 0 ${u(4)};
68
+ height: ${u(4)};
69
+ width: 100%;
70
+ font: inherit;
71
+ font-size: var(--lns-fontSize-small);
47
72
  border: none;
48
73
  box-shadow: inset 0 0 0 var(--lns-formFieldBorderWidth)
49
74
  var(--lns-color-formFieldBorder);
@@ -79,25 +104,6 @@ const ButtonWrapper = styled.div `
79
104
  padding: 0 var(--lns-space-medium) var(--lns-space-medium)
80
105
  var(--lns-space-medium);
81
106
  `;
82
- const SaturationPointer = styled.div `
83
- transform: translate(-50%);
84
- cursor: pointer;
85
- border: 2px solid white;
86
- box-shadow: 0 0 0 3px var(--lns-color-border);
87
- border-radius: var(--lns-radius-medium);
88
- width: ${u(1)};
89
- height: ${u(1)};
90
- `;
91
- const HuePointerInternal = styled.div `
92
- transform: translate(-50%, -3px);
93
- cursor: pointer;
94
- border: 2px solid white;
95
- box-shadow: 0 0 0 2px var(--lns-color-border);
96
- border-radius: 2px;
97
- width: ${u(1)};
98
- height: ${u(2.5)};
99
- background: ${props => props.hueColor};
100
- `;
101
107
  const SwatchesContainer = styled.div `
102
108
  display: grid;
103
109
  grid-template-columns: repeat(7, ${u(3)});
@@ -105,9 +111,6 @@ const SwatchesContainer = styled.div `
105
111
  border-bottom: 1px solid var(--lns-color-border);
106
112
  padding: var(--lns-space-medium);
107
113
  `;
108
- const ColorSelectorsWrapper = styled.div `
109
- padding: var(--lns-space-medium);
110
- `;
111
114
  const Swatch = styled.div `
112
115
  cursor: pointer;
113
116
  width: ${u(3)};
@@ -123,47 +126,26 @@ const SwatchSelector = ({ swatches, currentColor, onSwatchClick }) => {
123
126
  const selectedSwatch = swatches.includes(currentColor) && currentColor;
124
127
  return (React.createElement(SwatchesContainer, null, swatches.map(swatch => (React.createElement(Swatch, { key: swatch, color: swatch, selected: selectedSwatch, onClick: () => onSwatchClick(swatch) })))));
125
128
  };
126
- const HuePointer = props => {
127
- const hueHSL = `hsl(${props.hsl.h},100%,50%,1)`;
128
- return React.createElement(HuePointerInternal, { hueColor: hueHSL });
129
- };
130
- const ColorSelectorInternal = props => {
131
- const inputStyles = {
132
- input: {
133
- padding: `0 0 0 ${u(4)}`,
134
- height: u(4),
135
- width: '100%',
136
- font: 'inherit',
137
- color: 'inherit',
138
- fontSize: 'var(--lns-fontSize-small)',
139
- },
140
- };
141
- return (React.createElement(ColorSelectorsWrapper, null,
142
- React.createElement(SaturationContainer, null,
143
- React.createElement(Saturation, Object.assign({}, props, { pointer: SaturationPointer, radius: "var(--lns-radius-medium)" }))),
144
- React.createElement(HueContainer, null,
145
- React.createElement(Hue, Object.assign({}, props, { pointer: HuePointer, radius: "3px" }))),
129
+ const ColorSelector = ({ color, setColor }) => {
130
+ return (React.createElement(ColorfulWrapper, null,
131
+ React.createElement(HexColorPicker, { color: color, onChange: setColor }),
146
132
  React.createElement(InputContainer, null,
147
- React.createElement(EditableInput, Object.assign({}, props, { style: inputStyles, value: props.hex })),
148
- React.createElement(ColorBox, { color: props.color }))));
133
+ React.createElement(HexColorInput, { prefixed: true, color: color, onChange: setColor }),
134
+ React.createElement(ColorBox, { color: color }))));
149
135
  };
150
- const ColorSelector = CustomPicker(ColorSelectorInternal);
151
136
  const ColorPicker = (_a) => {
152
137
  var { defaultColor = '#ffffff', confirmButton, swatches, onChange } = _a, props = __rest(_a, ["defaultColor", "confirmButton", "swatches", "onChange"]);
153
138
  const [tempColor, setTempColor] = useState(defaultColor ? defaultColor : '#FFFFFF');
154
- const handleOnChange = ({ hex }) => {
139
+ const handleOnChange = hex => {
155
140
  setTempColor(hex);
156
141
  onChange(hex);
157
142
  };
158
143
  const onSwatchClick = swatch => {
159
- const object = {
160
- hex: swatch,
161
- };
162
- handleOnChange(object);
144
+ handleOnChange(swatch);
163
145
  };
164
146
  return (React.createElement(ColorPickerContainer, Object.assign({}, props),
165
147
  swatches && (React.createElement(SwatchSelector, { swatches: swatches, currentColor: tempColor, onSwatchClick: onSwatchClick })),
166
- React.createElement(ColorSelector, { color: tempColor, onChange: handleOnChange }),
148
+ React.createElement(ColorSelector, { color: tempColor, setColor: handleOnChange }),
167
149
  confirmButton && React.createElement(ButtonWrapper, null, confirmButton)));
168
150
  };
169
151
  export default ColorPicker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.98.1",
3
+ "version": "10.98.2",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",
@@ -28,7 +28,7 @@
28
28
  "downshift": "^5.4.7",
29
29
  "focus-trap-react": "^10.0.0",
30
30
  "lodash": "^4.17.21",
31
- "react-color": "^2.19.3",
31
+ "react-colorful": "^5.6.1",
32
32
  "react-laag": "^2.0.3",
33
33
  "resize-observer-polyfill": "^1.5.1",
34
34
  "transition-hook": "^1.5.1"