@flodesk/grain 2.7.6 → 2.8.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.
@@ -13,6 +13,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
15
 
16
+ require("core-js/modules/es.array.concat.js");
17
+
16
18
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
17
19
 
18
20
  var _utilities = require("../../utilities");
@@ -21,30 +23,37 @@ var _react = _interopRequireDefault(require("react"));
21
23
 
22
24
  var _styled = _interopRequireDefault(require("@emotion/styled"));
23
25
 
24
- var _excluded = ["children", "size", "weight", "color", "tag"];
26
+ var _react2 = require("@emotion/react");
27
+
28
+ var _excluded = ["children", "tag", "variant", "isDisabled"];
25
29
 
26
- var _templateObject, _templateObject2;
30
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
27
31
 
28
32
  var __jsx = _react.default.createElement;
33
+ var variants = {
34
+ neutral: (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: inherit;\n background-color: transparent;\n border-color: ", ";\n\n &:hover {\n border-color: ", ";\n }\n &:active {\n border-color: ", ";\n }\n "])), (0, _utilities.getColor)('buttonBorder'), (0, _utilities.getColor)('buttonBorderHover'), (0, _utilities.getColor)('buttonBorderActive')),
35
+ primary: (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n color: white;\n background-color: ", ";\n border-color: transparent;\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n color: ", ";\n background-color: black;\n }\n "])), (0, _utilities.getColor)('body'), (0, _utilities.getColor)('grey7'), (0, _utilities.getColor)('grey2'))
36
+ };
29
37
 
30
- var Wrapper = _styled.default.button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n appearance: none;\n border: none;\n font-family: inherit;\n font-size: ", ";\n font-weight: ", ";\n cursor: pointer;\n background-color: ", ";\n color: ", ";\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-buttonTextBoxPaddingX-m);\n"])), (0, _utilities.getTextSize)('m'), (0, _utilities.getWeight)('medium'), (0, _utilities.getColor)('body'), (0, _utilities.getColor)('white'), (0, _utilities.getRadius)('m'));
38
+ var Wrapper = _styled.default.button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n appearance: none;\n border: none;\n font-family: inherit;\n font-size: inherit;\n cursor: pointer;\n border-width: 1px;\n border-style: solid;\n font-weight: ", ";\n border-radius: ", ";\n transition: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-buttonTextBoxPaddingX-m);\n \n ", ";\n \n ", ";\n \n &:hover {\n transition: ", ";\n }\n \n &:active {\n transition: 0s;\n }\n"])), (0, _utilities.getWeight)('medium'), (0, _utilities.getRadius)('s'), (0, _utilities.getTransition)('slow'), function (p) {
39
+ return !p.isDisabled && variants[p.variant];
40
+ }, function (p) {
41
+ return p.isDisabled && "\n color: ".concat((0, _utilities.getColor)('disabledContent'), ";\n background-color: ").concat((0, _utilities.getColor)('disabledBackground'), ";\n border-color: transparent;\n cursor: default;\n ");
42
+ }, (0, _utilities.getTransition)('fast'));
31
43
 
32
- var ButtonText = _styled.default.span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n --opticalCompensation: -0.3px;\n\n position: relative;\n top: var(--opticalCompensation);\n"])));
44
+ var ButtonText = _styled.default.span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n --opticalCompensation: -0.3px;\n\n position: relative;\n top: var(--opticalCompensation);\n"])));
33
45
 
34
46
  var Button = function Button(_ref) {
35
47
  var children = _ref.children,
36
- _ref$size = _ref.size,
37
- size = _ref$size === void 0 ? 'm' : _ref$size,
38
- _ref$weight = _ref.weight,
39
- weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
40
- color = _ref.color,
41
48
  tag = _ref.tag,
49
+ _ref$variant = _ref.variant,
50
+ variant = _ref$variant === void 0 ? 'neutral' : _ref$variant,
51
+ isDisabled = _ref.isDisabled,
42
52
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
43
53
  return __jsx(Wrapper, (0, _extends2.default)({
44
- size: size,
45
- weight: weight,
46
- color: color,
47
- as: tag
54
+ as: tag,
55
+ variant: variant,
56
+ isDisabled: isDisabled
48
57
  }, props), __jsx(ButtonText, null, children));
49
58
  };
50
59
 
@@ -54,19 +63,44 @@ Button.__docgenInfo = {
54
63
  "methods": [],
55
64
  "displayName": "Button",
56
65
  "props": {
57
- "size": {
66
+ "variant": {
58
67
  "defaultValue": {
59
- "value": "'m'",
68
+ "value": "'neutral'",
60
69
  "computed": false
61
70
  },
62
- "required": false
71
+ "type": {
72
+ "name": "enum",
73
+ "value": [{
74
+ "value": "\"neutral\"",
75
+ "computed": false
76
+ }, {
77
+ "value": "\"primary\"",
78
+ "computed": false
79
+ }]
80
+ },
81
+ "required": false,
82
+ "description": ""
63
83
  },
64
- "weight": {
65
- "defaultValue": {
66
- "value": "'normal'",
67
- "computed": false
84
+ "children": {
85
+ "type": {
86
+ "name": "node"
87
+ },
88
+ "required": false,
89
+ "description": ""
90
+ },
91
+ "onClick": {
92
+ "type": {
93
+ "name": "func"
94
+ },
95
+ "required": false,
96
+ "description": ""
97
+ },
98
+ "isDisabled": {
99
+ "type": {
100
+ "name": "bool"
68
101
  },
69
- "required": false
102
+ "required": false,
103
+ "description": ""
70
104
  }
71
105
  }
72
106
  };
@@ -1,9 +1,15 @@
1
1
  :root {
2
- --grn-textBoxHeight-s: calc(var(--grn-unit) * 3.5);
3
- --grn-textBoxHeight-m: calc(var(--grn-unit) * 5);
4
-
5
- --grn-fieldTextBoxPaddingX-s: calc(var(--grn-unit) * 1);
6
- --grn-fieldTextBoxPaddingX-m: calc(var(--grn-unit) * 1.5);
7
-
8
- --grn-buttonTextBoxPaddingX-m: calc(var(--grn-unit) * 2.5);
2
+ --grn-textBoxHeight-s: 28px;
3
+ --grn-textBoxHeight-m: 40px;
4
+
5
+ --grn-fieldTextBoxPaddingX-s: 8px;
6
+ --grn-fieldTextBoxPaddingX-m: 12px;
7
+
8
+ --grn-buttonTextBoxPaddingX-m: 20px;
9
+ }
10
+
11
+ :root {
12
+ --grn-color-buttonBorder: hsl(var(--grn-color-grey8-HSL) / 30%);
13
+ --grn-color-buttonBorderHover: hsl(var(--grn-color-grey8-HSL) / 50%);
14
+ --grn-color-buttonBorderActive: hsl(var(--grn-color-grey8-HSL) / 80%);
9
15
  }
@@ -31,6 +31,11 @@
31
31
  --grn-radius-l: 15px;
32
32
  }
33
33
 
34
+ :root {
35
+ --grn-transition-slow: 400ms;
36
+ --grn-transition-fast: 200ms;
37
+ }
38
+
34
39
  :root {
35
40
  --grn-color-grey8-HSL: 0 0% 7%;
36
41
 
@@ -42,10 +47,14 @@
42
47
  --grn-color-grey3: hsl(0 0% 83%);
43
48
  --grn-color-grey2: hsl(0 0% 93%);
44
49
  --grn-color-grey1: hsl(0 0% 98%);
50
+ }
45
51
 
52
+ :root {
46
53
  --grn-color-blue: hsl(218 74% 54%);
47
54
  --grn-color-red: hsl(6 66% 65%);
55
+ }
48
56
 
57
+ :root {
49
58
  --grn-color-body: var(--grn-color-grey8);
50
59
  --grn-color-bodyDimmed: hsl(var(--grn-color-grey8-HSL) / 50%);
51
60
  --grn-color-accent: var(--grn-color-grey8);
@@ -55,6 +64,8 @@
55
64
  --grn-color-border: hsl(var(--grn-color-grey8-HSL) / 15%);
56
65
  --grn-color-selection: var(--grn-color-blue);
57
66
  --grn-color-danger: var(--grn-color-red);
67
+ --grn-color-disabledContent: var(--grn-color-grey5);
68
+ --grn-color-disabledBackground: hsl(var(--grn-color-grey8-HSL) / 12%);
58
69
  }
59
70
 
60
71
  :root {
@@ -23,7 +23,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
23
23
  Object.defineProperty(exports, "__esModule", {
24
24
  value: true
25
25
  });
26
- exports.getBorder = exports.getSpace = exports.getRadius = exports.getWeight = exports.getTextSize = exports.getShadow = exports.getColor = exports.getCssVar = exports.getCssVarCore = exports.isBrowser = void 0;
26
+ exports.getBorder = exports.getSpace = exports.getTransition = exports.getRadius = exports.getWeight = exports.getTextSize = exports.getShadow = exports.getColor = exports.getCssVar = exports.getCssVarCore = exports.isBrowser = void 0;
27
27
 
28
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
29
 
@@ -104,6 +104,14 @@ var getRadius = function getRadius(radius) {
104
104
 
105
105
  exports.getRadius = getRadius;
106
106
 
107
+ var getTransition = function getTransition(transition) {
108
+ if (transition in _variables.vars.transitions) {
109
+ return getCssVar("transition", transition);
110
+ }
111
+ };
112
+
113
+ exports.getTransition = getTransition;
114
+
107
115
  var getSpace = function getSpace(space) {
108
116
  if (isNaN(space)) {
109
117
  if (space in _variables.vars.spaces) {
@@ -39,6 +39,10 @@ var vars = {
39
39
  m: "m",
40
40
  l: "l"
41
41
  },
42
+ transitions: {
43
+ slow: "slow",
44
+ fast: "fast"
45
+ },
42
46
  colors: {
43
47
  greys: {
44
48
  grey8: "grey8",
@@ -62,8 +66,13 @@ var vars = {
62
66
  background: "background",
63
67
  overlay: "overlay",
64
68
  border: "border",
69
+ buttonBorder: "buttonBorder",
70
+ buttonBorderHover: "buttonBorderHover",
71
+ buttonBorderActive: "buttonBorderActive",
65
72
  selection: "selection",
66
- danger: "danger"
73
+ danger: "danger",
74
+ disabledContent: "disabledContent",
75
+ disabledBackground: "disabledBackground"
67
76
  }
68
77
  }
69
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "2.7.6",
3
+ "version": "2.8.0",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",