@flodesk/grain 3.1.1 → 5.0.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.
@@ -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", "size", "label", "id", "icon"];
15
+ var _excluded = ["value", "placeholder", "label", "id", "icon"];
16
16
 
17
17
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
18
18
 
@@ -36,55 +36,28 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
36
36
 
37
37
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
38
38
 
39
- import { getColor, getRadius, getTextSize } from '../utilities';
39
+ import { getColor, getRadius } from '../utilities';
40
40
  import PropTypes from 'prop-types';
41
41
  import React from 'react';
42
42
  import styled from '@emotion/styled';
43
- import { types } from '../types';
44
43
  import { css } from '@emotion/react';
45
44
  import { Box } from './box';
46
45
  import { Icon } from './icon';
47
46
  import { transitions } from '../foundational';
48
- var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-color-fieldBorder: var(--grn-color-fade3);\n --grn-color-fieldBorder-hover: var(--grn-color-fade6);\n"])));
49
- var sizesStyles = {
50
- s: {
51
- height: 'var(--grn-textBoxHeight-s)',
52
- padding: '0 8px',
53
- labelGap: '2px',
54
- iconOffsetPx: 8,
55
- iconTextGapPx: 4
56
- },
57
- m: {
58
- height: 'var(--grn-textBoxHeight-m)',
59
- padding: '0 12px',
60
- labelGap: '4px',
61
- iconOffsetPx: 12,
62
- iconTextGapPx: 8
63
- }
64
- };
65
- var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n font-size: ", ";\n"])), variables, function (p) {
66
- return getTextSize(p.size);
67
- });
68
- var Label = styled.label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: block;\n margin-bottom: ", ";\n"])), function (p) {
69
- return sizesStyles[p.size].labelGap;
70
- });
71
- var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n font-family: inherit;\n background-color: transparent;\n color: inherit;\n font-size: inherit;\n transition-property: border-color;\n border: 1px solid var(--grn-color-fieldBorder);\n width: 100%;\n border-radius: ", ";\n height: ", ";\n padding: ", ";\n ", ";\n outline: none;\n\n &::placeholder {\n color: ", ";\n }\n\n &:hover {\n border-color: var(--grn-color-fieldBorder-hover);\n }\n\n &:focus {\n transition: 0s;\n border-color: var(--grn-color-grey6);\n }\n"])), transitions, function () {
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"])));
48
+ var iconOffsetPx = 12;
49
+ var iconTextGapPx = 8;
50
+ var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n"])), variables);
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 border: 1px solid var(--grn-fieldBorderColor);\n width: 100%;\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-fieldXPadding) 0 ", ";\n outline: none;\n\n &::placeholder {\n color: ", ";\n }\n\n &:hover {\n border-color: var(--grn-fieldBorderColor-hover);\n }\n\n &:focus {\n transition: 0s;\n border-color: var(--grn-color-grey6);\n }\n"])), transitions, function () {
72
53
  return getRadius('s');
73
54
  }, function (p) {
74
- return sizesStyles[p.size].height;
75
- }, function (p) {
76
- return sizesStyles[p.size].padding;
77
- }, function (p) {
78
- return p.paddingLeft && "padding-left: ".concat(p.paddingLeft, "px");
55
+ return p.paddingLeft;
79
56
  }, getColor('grey5'));
80
- 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"])), function (p) {
81
- return sizesStyles[p.size].iconOffsetPx;
82
- });
57
+ 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);
83
58
  export var TextInput = function TextInput(_ref) {
84
59
  var value = _ref.value,
85
60
  placeholder = _ref.placeholder,
86
- _ref$size = _ref.size,
87
- size = _ref$size === void 0 ? 'm' : _ref$size,
88
61
  label = _ref.label,
89
62
  id = _ref.id,
90
63
  icon = _ref.icon,
@@ -102,25 +75,19 @@ export var TextInput = function TextInput(_ref) {
102
75
  setIconWidth(iconRef.current.getBoundingClientRect().width);
103
76
  }
104
77
  }, []);
105
- var paddingLeft = icon && sizesStyles[size].iconOffsetPx + iconWidth + sizesStyles[size].iconTextGapPx;
78
+ var paddingLeft = icon ? "".concat(iconOffsetPx + iconWidth + iconTextGapPx, "px") : "var(--grn-fieldXPadding)";
106
79
  return /*#__PURE__*/React.createElement(Wrapper, {
107
- size: size,
108
80
  type: "text"
109
81
  }, label && /*#__PURE__*/React.createElement(Label, {
110
- htmlFor: id,
111
- size: size
82
+ htmlFor: id
112
83
  }, label), /*#__PURE__*/React.createElement(Box, {
113
84
  position: "relative"
114
- }, icon && /*#__PURE__*/React.createElement(IconSection, {
115
- size: size
116
- }, /*#__PURE__*/React.createElement(Icon, {
85
+ }, icon && /*#__PURE__*/React.createElement(IconSection, null, /*#__PURE__*/React.createElement(Icon, {
117
86
  ref: iconRef,
118
- icon: icon,
119
- size: size
87
+ icon: icon
120
88
  })), /*#__PURE__*/React.createElement(InputField, Object.assign({
121
89
  value: value,
122
90
  placeholder: placeholder,
123
- size: size,
124
91
  label: label,
125
92
  icon: icon,
126
93
  id: id,
@@ -131,7 +98,6 @@ TextInput.propTypes = {
131
98
  id: PropTypes.string.isRequired,
132
99
  placeholder: PropTypes.string,
133
100
  value: PropTypes.string,
134
- size: types.fieldSize,
135
101
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
136
102
  icon: PropTypes.node
137
103
  };
package/es/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './components';
2
2
  export * from './icons';
3
- export * from './variables';
3
+ export * from './variables';
4
+ export * from './utilities';
@@ -8,10 +8,12 @@ import "core-js/modules/es.symbol.iterator.js";
8
8
  import "core-js/modules/es.array.iterator.js";
9
9
  import "core-js/modules/es.string.iterator.js";
10
10
  import "core-js/modules/web.dom-collections.iterator.js";
11
- import { grnPrefix } from '../variables';
11
+ import { grnPrefix, varInfo } from '../variables';
12
12
  export var isBrowser = typeof window !== 'undefined';
13
13
  export var getCssVarCore = function getCssVarCore(type, value) {
14
- return "".concat(grnPrefix).concat(type, "-").concat(value);
14
+ var typeInfo = varInfo[type];
15
+ var prefix = typeInfo ? typeInfo.prefix : type;
16
+ return "".concat(grnPrefix).concat(prefix, "-").concat(value);
15
17
  };
16
18
  export var getCssVar = function getCssVar(type, value) {
17
19
  return "var(".concat(getCssVarCore(type, value), ")");
@@ -1,21 +1,3 @@
1
- export { getDimension } from './responsive';
2
- export { getResponsiveDimension } from './responsive';
3
- export { getResponsiveGridColumns } from './responsive';
4
- export { getColor } from './styles';
5
- export { getShadow } from './styles';
6
- export { getTextSize } from './responsive';
7
- export { getResponsiveTextSize } from './responsive';
8
- export { getWeight } from './styles';
9
- export { getRadius } from './styles';
10
- export { getTransition } from './styles';
11
- export { getResponsiveSpace } from './responsive';
12
- export { getIconSize } from './styles';
13
- export { getBorder } from './styles';
14
- export { isBrowser } from './helpers';
15
- export { getCssVarCore } from './helpers';
16
- export { getCssVar } from './helpers';
17
- export { u } from './helpers';
18
- export { isNumber } from './helpers';
19
- export { isString } from './helpers';
20
- export { isArray } from './helpers';
21
- export { isObject } from './helpers';
1
+ export * from './helpers';
2
+ export * from './responsive';
3
+ export * from './styles';
@@ -41,8 +41,7 @@ export var getMediaCss = function getMediaCss(mediaQuery, property, value) {
41
41
  export var mapObjToMedia = function mapObjToMedia(property, obj, type) {
42
42
  var checkValueInVars = function checkValueInVars(value) {
43
43
  if (type && value in vars[type]) {
44
- var varPrefix = varInfo[type].prefix;
45
- return getCssVar(varPrefix, value);
44
+ return getCssVar(varInfo[type].name, value);
46
45
  }
47
46
 
48
47
  return value;
@@ -65,7 +64,7 @@ export var getDimension = function getDimension(dimension) {
65
64
  };
66
65
  export var getSpace = function getSpace(space) {
67
66
  if (space in vars.spaces) {
68
- return getCssVar(varInfo.spaces.prefix, space);
67
+ return getCssVar(varInfo.spaces.name, space);
69
68
  }
70
69
 
71
70
  if (space === 0) return space;
@@ -92,7 +91,7 @@ export var getResponsiveSpace = function getResponsiveSpace(property, space) {
92
91
  };
93
92
  export var getTextSize = function getTextSize(size) {
94
93
  if (size in vars.texts) {
95
- return getCssVar(varInfo.texts.prefix, size);
94
+ return getCssVar(varInfo.texts.name, size);
96
95
  }
97
96
 
98
97
  if (isString(size)) return size;
@@ -1,49 +1,30 @@
1
1
  import "core-js/modules/es.array.concat.js";
2
2
  import "core-js/modules/es.array.map.js";
3
- import "core-js/modules/es.object.define-property.js";
4
- import "core-js/modules/es.object.keys.js";
5
- import "core-js/modules/es.symbol.js";
6
- import "core-js/modules/es.array.filter.js";
7
- import "core-js/modules/es.object.to-string.js";
8
- import "core-js/modules/es.object.get-own-property-descriptor.js";
9
- import "core-js/modules/web.dom-collections.for-each.js";
10
- import "core-js/modules/es.object.get-own-property-descriptors.js";
11
- import "core-js/modules/es.object.define-properties.js";
12
-
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
-
17
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
-
19
3
  import { getCssVar, isNumber, isString, u } from '.';
20
4
  import { vars, varInfo } from '../variables';
21
5
  import { getDimension } from './responsive';
22
-
23
- var allColors = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, vars.colors.bases), vars.colors.greys), vars.colors.semantics), vars.colors.fades);
24
-
25
6
  export var getColor = function getColor(color) {
26
- if (color in allColors) {
27
- return getCssVar(varInfo.colors.prefix, color);
7
+ if (color in vars.colors) {
8
+ return getCssVar(varInfo.colors.name, color);
28
9
  }
29
10
 
30
11
  return color;
31
12
  };
32
13
  export var getShadow = function getShadow(shadow) {
33
14
  if (shadow in vars.shadows) {
34
- return getCssVar(varInfo.shadows.prefix, shadow);
15
+ return getCssVar(varInfo.shadows.name, shadow);
35
16
  }
36
17
 
37
18
  return shadow;
38
19
  };
39
20
  export var getWeight = function getWeight(weight) {
40
21
  if (weight in vars.weights) {
41
- return getCssVar(varInfo.weights.prefix, weight);
22
+ return getCssVar(varInfo.weights.name, weight);
42
23
  }
43
24
  };
44
25
  export var getRadius = function getRadius(radius) {
45
26
  if (radius in vars.radii) {
46
- return getCssVar(varInfo.radii.prefix, radius);
27
+ return getCssVar(varInfo.radii.name, radius);
47
28
  }
48
29
 
49
30
  if (radius === 0) return radius;
@@ -52,12 +33,12 @@ export var getRadius = function getRadius(radius) {
52
33
  };
53
34
  export var getTransition = function getTransition(transition) {
54
35
  if (transition in vars.transitions) {
55
- return getCssVar(varInfo.transitions.prefix, transition);
36
+ return getCssVar(varInfo.transitions.name, transition);
56
37
  }
57
38
  };
58
39
  export var getIconSize = function getIconSize(size) {
59
40
  if (size in vars.icons) {
60
- return getCssVar(varInfo.icons.prefix, size);
41
+ return getCssVar(varInfo.icons.name, size);
61
42
  }
62
43
 
63
44
  return getDimension(size);
package/es/variables.js CHANGED
@@ -1,4 +1,58 @@
1
+ import "core-js/modules/es.object.define-property.js";
2
+ import "core-js/modules/es.object.keys.js";
3
+ import "core-js/modules/es.symbol.js";
4
+ import "core-js/modules/es.array.filter.js";
5
+ import "core-js/modules/es.object.to-string.js";
6
+ import "core-js/modules/es.object.get-own-property-descriptor.js";
7
+ import "core-js/modules/web.dom-collections.for-each.js";
8
+ import "core-js/modules/es.object.get-own-property-descriptors.js";
9
+ import "core-js/modules/es.object.define-properties.js";
10
+
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
+
15
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+
1
17
  export var grnPrefix = '--grn-';
18
+ export var colors = {
19
+ greys: {
20
+ grey8: 'grey8',
21
+ grey7: 'grey7',
22
+ grey6: 'grey6',
23
+ grey5: 'grey5',
24
+ grey4: 'grey4',
25
+ grey3: 'grey3',
26
+ grey2: 'grey2',
27
+ grey1: 'grey1'
28
+ },
29
+ fades: {
30
+ fade7: 'fade7',
31
+ fade6: 'fade6',
32
+ fade5: 'fade5',
33
+ fade4: 'fade4',
34
+ fade3: 'fade3',
35
+ fade2: 'fade2',
36
+ fade1: 'fade1'
37
+ },
38
+ bases: {
39
+ blue: 'blue',
40
+ red: 'red'
41
+ },
42
+ semantics: {
43
+ body: 'body',
44
+ bodyDimmed: 'bodyDimmed',
45
+ accent: 'accent',
46
+ backgroundSecondary: 'backgroundSecondary',
47
+ background: 'background',
48
+ overlay: 'overlay',
49
+ border: 'border',
50
+ selection: 'selection',
51
+ danger: 'danger',
52
+ disabledContent: 'disabledContent',
53
+ disabledBackground: 'disabledBackground'
54
+ }
55
+ };
2
56
  export var vars = {
3
57
  texts: {
4
58
  s: 's',
@@ -42,44 +96,7 @@ export var vars = {
42
96
  fast: 'fast',
43
97
  xFast: 'xFast'
44
98
  },
45
- colors: {
46
- greys: {
47
- grey8: 'grey8',
48
- grey7: 'grey7',
49
- grey6: 'grey6',
50
- grey5: 'grey5',
51
- grey4: 'grey4',
52
- grey3: 'grey3',
53
- grey2: 'grey2',
54
- grey1: 'grey1'
55
- },
56
- fades: {
57
- fade7: 'fade7',
58
- fade6: 'fade6',
59
- fade5: 'fade5',
60
- fade4: 'fade4',
61
- fade3: 'fade3',
62
- fade2: 'fade2',
63
- fade1: 'fade1'
64
- },
65
- bases: {
66
- blue: 'blue',
67
- red: 'red'
68
- },
69
- semantics: {
70
- body: 'body',
71
- bodyDimmed: 'bodyDimmed',
72
- accent: 'accent',
73
- backgroundSecondary: 'backgroundSecondary',
74
- background: 'background',
75
- overlay: 'overlay',
76
- border: 'border',
77
- selection: 'selection',
78
- danger: 'danger',
79
- disabledContent: 'disabledContent',
80
- disabledBackground: 'disabledBackground'
81
- }
82
- }
99
+ colors: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colors.greys), colors.fades), colors.bases), colors.semantics)
83
100
  };
84
101
  export var varInfo = {
85
102
  texts: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "3.1.1",
3
+ "version": "5.0.0",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",