@loomhq/lens 10.98.1 → 10.99.0

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.
@@ -7,6 +7,8 @@ declare type AvatarProps = {
7
7
  imageSrc?: string;
8
8
  size?: string | number;
9
9
  children?: React.ReactNode;
10
+ height?: number;
11
+ width?: number;
10
12
  };
11
13
  declare type AvatarWrapperProps = {
12
14
  size?: string | number;
@@ -11,29 +11,30 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { getRadius, getSizeValue, u } from '../../utilities';
13
13
  import React from 'react';
14
- import { css } from '@emotion/core';
15
14
  import styled from '@emotion/styled';
16
15
  const getLetterSize = wrapperSize => `calc(${wrapperSize} / 1.75)`;
17
16
  const getAvatarSize = avatarSize => {
17
+ let width;
18
+ let height;
18
19
  if (avatarSize === 'medium') {
19
- return css `
20
- width: ${u(4)};
21
- height: ${u(4)};
22
- font-size: ${getLetterSize(u(4))};
23
- `;
20
+ width = u(4);
21
+ height = u(4);
24
22
  }
25
- if (avatarSize === 'large') {
26
- return css `
27
- width: ${u(7)};
28
- height: ${u(7)};
29
- font-size: ${getLetterSize(u(7))};
30
- `;
23
+ else if (avatarSize === 'large') {
24
+ width = u(7);
25
+ height = u(7);
31
26
  }
32
- return css `
33
- width: ${getSizeValue(avatarSize)};
34
- height: ${getSizeValue(avatarSize)};
35
- font-size: ${getLetterSize(getSizeValue(avatarSize))};
36
- `;
27
+ else {
28
+ const sizeValue = getSizeValue(avatarSize);
29
+ width = sizeValue;
30
+ height = sizeValue;
31
+ }
32
+ const fontSize = getLetterSize(width);
33
+ return {
34
+ width,
35
+ height,
36
+ fontSize,
37
+ };
37
38
  };
38
39
  const AvatarWrapper = styled.span `
39
40
  display: block;
@@ -46,7 +47,18 @@ const AvatarWrapper = styled.span `
46
47
  justify-content: center;
47
48
  line-height: 1;
48
49
  font-weight: var(--lns-fontWeight-bold);
49
- ${props => getAvatarSize(props.size)};
50
+ width: ${props => {
51
+ const { width } = getAvatarSize(props.size);
52
+ return width;
53
+ }};
54
+ height: ${props => {
55
+ const { height } = getAvatarSize(props.size);
56
+ return height;
57
+ }};
58
+ font-size: ${props => {
59
+ const { fontSize } = getAvatarSize(props.size);
60
+ return fontSize;
61
+ }};
50
62
  position: relative;
51
63
  z-index: 0;
52
64
 
@@ -64,7 +76,19 @@ const AvatarWrapper = styled.span `
64
76
  }
65
77
  `;
66
78
  const AvatarImage = styled.img `
67
- width: 100%;
79
+ max-width: 100%;
80
+ width: ${props => {
81
+ const { width } = getAvatarSize(props.size);
82
+ return width;
83
+ }};
84
+ height: ${props => {
85
+ const { height } = getAvatarSize(props.size);
86
+ return height;
87
+ }};
88
+ font-size: ${props => {
89
+ const { fontSize } = getAvatarSize(props.size);
90
+ return fontSize;
91
+ }};
68
92
  `;
69
93
  const Avatar = (_a) => {
70
94
  var { altText = '', size = 4, letter, imageSrc, children } = _a, props = __rest(_a, ["altText", "size", "letter", "imageSrc", "children"]);
@@ -73,7 +97,9 @@ const Avatar = (_a) => {
73
97
  return children;
74
98
  }
75
99
  if (imageSrc) {
76
- return React.createElement(AvatarImage, { alt: altText, src: imageSrc });
100
+ const height = getAvatarSize(size).height;
101
+ const width = getAvatarSize(size).width;
102
+ return (React.createElement(AvatarImage, { size: size, alt: altText, src: imageSrc, height: height, width: width }));
77
103
  }
78
104
  if (letter) {
79
105
  if (altText) {
@@ -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;
@@ -258,3 +258,4 @@ export { default as SvgFolderPlus } from "./folder-plus.js";
258
258
  export { default as SvgPower } from "./power.js";
259
259
  export { default as SvgReplay } from "./replay.js";
260
260
  export { default as SvgTranscript } from "./transcript";
261
+ export { default as SvgVariables } from "./variables";
@@ -258,3 +258,4 @@ export { default as SvgFolderPlus } from './folder-plus.js';
258
258
  export { default as SvgPower } from './power.js';
259
259
  export { default as SvgReplay } from './replay.js';
260
260
  export { default as SvgTranscript } from './transcript';
261
+ export { default as SvgVariables } from './variables';
@@ -0,0 +1,2 @@
1
+ export default SvgVariables;
2
+ declare function SvgVariables(props: any): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ function SvgVariables(props) {
3
+ return (React.createElement("svg", Object.assign({ viewBox: "0 0 25 24", fill: "none" }, props),
4
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8.78181 3.75H8.25176C6.17193 3.75 4.87858 4.80682 4.87858 7.03977V9.46023C4.87858 10.5933 4.1437 11.026 3.18006 11.0448C3.16669 11.0443 3.15324 11.044 3.13973 11.044C2.60281 11.044 2.16754 11.4685 2.16754 11.9922C2.16754 12.5158 2.60281 12.9403 3.13973 12.9403C3.15965 12.9403 3.17943 12.9397 3.19905 12.9386C4.15333 12.9627 4.87858 13.3971 4.87858 14.5227V16.9432C4.87858 19.1761 6.17193 20.25 8.25176 20.25H8.79356V20.2485C9.27681 20.2423 9.66661 19.8584 9.66661 19.3856C9.66661 18.909 9.27047 18.5227 8.78181 18.5227C8.74712 18.5227 8.7129 18.5246 8.67925 18.5284H8.28671C7.41283 18.5284 6.8186 18.1193 6.8186 16.9943V14.1477C6.8186 13.0568 6.17193 12.2727 5.07084 12C6.1894 11.7102 6.8186 10.9261 6.8186 9.85227V6.98864C6.8186 5.86364 7.41283 5.47159 8.28671 5.47159H8.69332C8.72242 5.47441 8.75194 5.47585 8.78181 5.47585C9.27047 5.47585 9.66661 5.08951 9.66661 4.61293C9.66661 4.14017 9.27681 3.75621 8.79356 3.75007V3.75H8.78181ZM16.5514 3.75H17.0815C19.1613 3.75 20.4546 4.80682 20.4546 7.03977V9.46023C20.4546 10.5933 21.1895 11.026 22.1532 11.0448C22.1665 11.0443 22.18 11.044 22.1935 11.044C22.7304 11.044 23.1657 11.4685 23.1657 11.9922C23.1657 12.5158 22.7304 12.9403 22.1935 12.9403C22.1736 12.9403 22.1538 12.9397 22.1342 12.9386C21.1799 12.9627 20.4546 13.3971 20.4546 14.5227V16.9432C20.4546 19.1761 19.1613 20.25 17.0815 20.25H16.5397V20.2485C16.0564 20.2423 15.6666 19.8584 15.6666 19.3856C15.6666 18.909 16.0628 18.5227 16.5514 18.5227C16.5861 18.5227 16.6203 18.5246 16.654 18.5284H17.0465C17.9204 18.5284 18.5146 18.1193 18.5146 16.9943V14.1477C18.5146 13.0568 19.1613 12.2727 20.2624 12C19.1438 11.7102 18.5146 10.9261 18.5146 9.85227V6.98864C18.5146 5.86364 17.9204 5.47159 17.0465 5.47159H16.6399C16.6108 5.47441 16.5813 5.47585 16.5514 5.47585C16.0628 5.47585 15.6666 5.08951 15.6666 4.61293C15.6666 4.14017 16.0564 3.75621 16.5397 3.75007V3.75H16.5514ZM15.2579 12.352C15.4853 12.3376 15.6666 12.2878 15.6666 12.0546C15.6666 11.8244 15.4853 11.7746 15.255 11.7602C14.1698 11.6997 13.0258 10.4968 12.9625 9.41163C12.951 9.18135 12.9041 9 12.668 9C12.432 9 12.3822 9.18135 12.3707 9.41163C12.3074 10.4968 11.1634 11.6997 10.0782 11.7602C9.84796 11.7746 9.66661 11.8215 9.66661 12.0546C9.66661 12.2878 9.84796 12.3376 10.0782 12.352C11.1634 12.4124 12.3074 13.5032 12.3707 14.5855C12.3822 14.8187 12.4349 15 12.668 15C12.9012 15 12.951 14.8187 12.9625 14.5884C13.0258 13.5032 14.1698 12.4124 15.2579 12.352Z", fill: "currentColor" })));
5
+ }
6
+ export default SvgVariables;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.98.1",
3
+ "version": "10.99.0",
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"