@flodesk/grain 5.0.0 → 5.1.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.
- package/es/components/slider.js +1 -1
- package/es/components/text-input.js +21 -10
- package/es/components/text.js +3 -2
- package/es/types.js +1 -0
- package/package.json +1 -1
package/es/components/slider.js
CHANGED
|
@@ -20,7 +20,7 @@ import { PropTypes } from 'prop-types';
|
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import styled from '@emotion/styled';
|
|
22
22
|
import { css } from '@emotion/react';
|
|
23
|
-
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --trackHeight: 2px;\n --sliderHeight:
|
|
23
|
+
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --trackHeight: 2px;\n --sliderHeight: 16px;\n --thumbSize: var(--sliderHeight);\n\n position: relative;\n\n &:after {\n content: '';\n width: 100%;\n height: var(--trackHeight);\n top: 0;\n bottom: 0;\n margin: auto;\n background: linear-gradient(\n 90deg,\n var(--grn-color-body) 0 var(--value),\n var(--grn-color-fade2) var(--value) 100%\n );\n display: block;\n position: absolute;\n border-radius: 100px;\n }\n"])));
|
|
24
24
|
var trackStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: 100%;\n height: var(--sliderHeight);\n cursor: pointer;\n background: transparent;\n"])));
|
|
25
25
|
var thumbStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n -webkit-appearance: none;\n height: var(--thumbSize);\n width: var(--thumbSize);\n border-radius: 100px;\n background: var(--grn-color-body);\n cursor: pointer;\n"])));
|
|
26
26
|
var InputWrapper = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n -webkit-appearance: none;\n width: 100%;\n margin: 0;\n display: block;\n background: transparent;\n\n &::-webkit-slider-runnable-track {\n ", "\n }\n &::-moz-range-track {\n ", "\n }\n\n &::-webkit-slider-thumb {\n ", "\n }\n &::-moz-range-thumb {\n ", "\n }\n"])), trackStyles, trackStyles, thumbStyles, thumbStyles);
|
|
@@ -12,7 +12,7 @@ import "core-js/modules/es.string.iterator.js";
|
|
|
12
12
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
13
13
|
import "core-js/modules/es.array.from.js";
|
|
14
14
|
import "core-js/modules/es.regexp.exec.js";
|
|
15
|
-
var _excluded = ["value", "placeholder", "label", "id", "icon"];
|
|
15
|
+
var _excluded = ["value", "placeholder", "label", "id", "icon", "hasError", "errorMessage"];
|
|
16
16
|
|
|
17
17
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
18
18
|
|
|
@@ -41,19 +41,21 @@ import PropTypes from 'prop-types';
|
|
|
41
41
|
import React from 'react';
|
|
42
42
|
import styled from '@emotion/styled';
|
|
43
43
|
import { css } from '@emotion/react';
|
|
44
|
-
import { Box } from '
|
|
44
|
+
import { Box, Text } from '.';
|
|
45
45
|
import { Icon } from './icon';
|
|
46
46
|
import { transitions } from '../foundational';
|
|
47
|
-
var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-fieldBorderColor: var(--grn-color-fade3);\n --grn-fieldBorderColor-hover: var(--grn-color-fade6);\n --grn-fieldXPadding: 12px;\n"])));
|
|
47
|
+
var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-fieldBorderColor: var(--grn-color-fade3);\n --grn-fieldBorderColor-hover: var(--grn-color-fade6);\n --grn-fieldBorderColor-focus: var(--grn-color-grey6);\n --grn-fieldXPadding: 12px;\n"])));
|
|
48
48
|
var iconOffsetPx = 12;
|
|
49
49
|
var iconTextGapPx = 8;
|
|
50
50
|
var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n"])), variables);
|
|
51
51
|
var Label = styled.label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: block;\n margin-bottom: 4px;\n"])));
|
|
52
|
-
var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n font: inherit;\n color: inherit;\n background-color: transparent;\n transition-property: border-color;\n
|
|
53
|
-
return getRadius('s');
|
|
54
|
-
}, function (p) {
|
|
52
|
+
var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n font: inherit;\n color: inherit;\n background-color: transparent;\n transition-property: border-color;\n width: 100%;\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-fieldXPadding) 0 ", ";\n outline: none;\n border: 1px solid ", ";\n\n &::placeholder {\n color: ", ";\n }\n\n ", "\n"])), transitions, getRadius('s'), function (p) {
|
|
55
53
|
return p.paddingLeft;
|
|
56
|
-
},
|
|
54
|
+
}, function (p) {
|
|
55
|
+
return p.hasError ? 'var(--grn-color-danger)' : 'var(--grn-fieldBorderColor)';
|
|
56
|
+
}, getColor('grey5'), function (p) {
|
|
57
|
+
return !p.hasError && "\n &:hover {\n border-color: var(--grn-fieldBorderColor-hover);\n }\n\n &:focus {\n transition: 0s;\n border-color: var(--grn-fieldBorderColor-focus);\n }\n ";
|
|
58
|
+
});
|
|
57
59
|
var IconSection = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n margin: auto;\n left: ", "px;\n top: 0;\n bottom: 0;\n height: fit-content;\n pointer-events: none;\n"])), iconOffsetPx);
|
|
58
60
|
export var TextInput = function TextInput(_ref) {
|
|
59
61
|
var value = _ref.value,
|
|
@@ -61,6 +63,8 @@ export var TextInput = function TextInput(_ref) {
|
|
|
61
63
|
label = _ref.label,
|
|
62
64
|
id = _ref.id,
|
|
63
65
|
icon = _ref.icon,
|
|
66
|
+
hasError = _ref.hasError,
|
|
67
|
+
errorMessage = _ref.errorMessage,
|
|
64
68
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
65
69
|
|
|
66
70
|
var iconRef = React.useRef(null);
|
|
@@ -91,13 +95,20 @@ export var TextInput = function TextInput(_ref) {
|
|
|
91
95
|
label: label,
|
|
92
96
|
icon: icon,
|
|
93
97
|
id: id,
|
|
94
|
-
paddingLeft: paddingLeft
|
|
95
|
-
|
|
98
|
+
paddingLeft: paddingLeft,
|
|
99
|
+
hasError: hasError
|
|
100
|
+
}, props))), errorMessage && /*#__PURE__*/React.createElement(Box, {
|
|
101
|
+
marginTop: 0.5
|
|
102
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
103
|
+
color: "danger"
|
|
104
|
+
}, errorMessage)));
|
|
96
105
|
};
|
|
97
106
|
TextInput.propTypes = {
|
|
98
107
|
id: PropTypes.string.isRequired,
|
|
99
108
|
placeholder: PropTypes.string,
|
|
100
109
|
value: PropTypes.string,
|
|
101
110
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
102
|
-
icon: PropTypes.node
|
|
111
|
+
icon: PropTypes.node,
|
|
112
|
+
hasError: PropTypes.bool,
|
|
113
|
+
errorMessage: PropTypes.string
|
|
103
114
|
};
|
package/es/components/text.js
CHANGED
|
@@ -43,7 +43,8 @@ export var Text = function Text(_ref) {
|
|
|
43
43
|
_ref$weight = _ref.weight,
|
|
44
44
|
weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
|
|
45
45
|
color = _ref.color,
|
|
46
|
-
tag = _ref.tag,
|
|
46
|
+
_ref$tag = _ref.tag,
|
|
47
|
+
tag = _ref$tag === void 0 ? 'span' : _ref$tag,
|
|
47
48
|
hasEllipsis = _ref.hasEllipsis,
|
|
48
49
|
ellipsisLines = _ref.ellipsisLines,
|
|
49
50
|
align = _ref.align,
|
|
@@ -64,7 +65,7 @@ Text.propTypes = {
|
|
|
64
65
|
weight: types.weight,
|
|
65
66
|
color: types.color,
|
|
66
67
|
align: types.textAlign,
|
|
67
|
-
tag:
|
|
68
|
+
tag: types.textTag,
|
|
68
69
|
hasEllipsis: PropTypes.bool,
|
|
69
70
|
ellipsisLines: PropTypes.number
|
|
70
71
|
};
|
package/es/types.js
CHANGED
|
@@ -18,6 +18,7 @@ export var types = {
|
|
|
18
18
|
textAlign: PropTypes.oneOf(['left', 'center', 'right']),
|
|
19
19
|
overflow: PropTypes.oneOf(['visible', 'hidden', 'scroll', 'auto']),
|
|
20
20
|
fieldSize: PropTypes.oneOf(['s', 'm']),
|
|
21
|
+
textTag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span']),
|
|
21
22
|
columns: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
22
23
|
autoFlow: PropTypes.oneOf(autoFlows),
|
|
23
24
|
gridItemsAlignment: PropTypes.oneOf(gridItemsAlignments),
|