@flodesk/grain 2.4.7 → 2.5.1

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/README.md CHANGED
@@ -14,6 +14,20 @@ npm install @flodesk/grain
14
14
  import "@flodesk/grain/es/styles/base.css";
15
15
  ```
16
16
 
17
+ ### Add text styles context
18
+
19
+ Add `grn-context` class to a parent wrapper, this class sets dynamically the `line-height` and the `letter-spacing`. It can be added to a smaller UI section or to the page wrapper. Set it on as many wrappers as needed.
20
+
21
+ In the future, once Grain is widely adopted, we will remove these classes and apply the text styles globally.
22
+
23
+ ```jsx
24
+ <div className="some-wrapper grn-context">
25
+ <Text size="l">Content</Text>
26
+ // or
27
+ <div className="element-with-grain-styles">Content</div>
28
+ </div>
29
+ ```
30
+
17
31
  ## Usage
18
32
 
19
33
  ### Component usage
@@ -0,0 +1,43 @@
1
+ import "core-js/modules/es.array.slice.js";
2
+ import "core-js/modules/es.object.freeze.js";
3
+ import "core-js/modules/es.object.define-properties.js";
4
+ import "core-js/modules/es.object.keys.js";
5
+ import "core-js/modules/es.array.index-of.js";
6
+ import "core-js/modules/es.symbol.js";
7
+ var _excluded = ["children", "size", "weight", "color", "tag"];
8
+
9
+ var _templateObject, _templateObject2;
10
+
11
+ import "core-js/modules/es.object.assign.js";
12
+
13
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
+
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+
17
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
+
19
+ import { getColor, getRadius, getSpace, getTextSize, getWeight } from '../../utilities';
20
+ import { PropTypes } from 'prop-types';
21
+ import React from "react";
22
+ import styled from "@emotion/styled";
23
+ import { types } from '../../types';
24
+ var Wrapper = styled.button(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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: 0.34em;\n height: var(--grn-textBoxHeight);\n padding: 0 var(--grn-buttonTextBoxPaddingX);\n"])), getTextSize('m'), getWeight('medium'), getColor('body'), getColor('white'));
25
+ var ButtonText = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n top: -0.3px;\n"])));
26
+ export var Button = function Button(_ref) {
27
+ var children = _ref.children,
28
+ _ref$size = _ref.size,
29
+ size = _ref$size === void 0 ? 'm' : _ref$size,
30
+ _ref$weight = _ref.weight,
31
+ weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
32
+ color = _ref.color,
33
+ tag = _ref.tag,
34
+ props = _objectWithoutProperties(_ref, _excluded);
35
+
36
+ return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
37
+ size: size,
38
+ weight: weight,
39
+ color: color,
40
+ as: tag
41
+ }, props), /*#__PURE__*/React.createElement(ButtonText, null, children));
42
+ };
43
+ Button.propTypes = {};
@@ -1,2 +1,4 @@
1
1
  export { Text } from "./text";
2
- export { Box } from "./box";
2
+ export { Box } from "./box";
3
+ export { Button } from "./button";
4
+ export { Input } from "./input";
@@ -0,0 +1,45 @@
1
+ import "core-js/modules/es.array.slice.js";
2
+ import "core-js/modules/es.object.freeze.js";
3
+ import "core-js/modules/es.object.define-properties.js";
4
+ import "core-js/modules/es.object.keys.js";
5
+ import "core-js/modules/es.array.index-of.js";
6
+ import "core-js/modules/es.symbol.js";
7
+ var _excluded = ["value", "placeholder", "size"];
8
+
9
+ var _templateObject;
10
+
11
+ import "core-js/modules/es.object.assign.js";
12
+
13
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
+
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
+
17
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
+
19
+ import { getColor, getRadius, getSpace, getTextSize, getWeight } from '../../utilities';
20
+ import { PropTypes } from 'prop-types';
21
+ import React from "react";
22
+ import styled from "@emotion/styled";
23
+ import { types } from '../../types';
24
+ var Wrapper = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n appearance: none;\n border: none;\n font-family: inherit;\n background-color: transparent;\n color: inherit;\n font-size: ", ";\n border-radius: ", ";\n border: 1px solid ", ";\n height: ", ";\n padding: 0 ", ";\n width: 100%;\n"])), function (p) {
25
+ return getTextSize(p.size);
26
+ }, getRadius('m'), getColor('grey3'), function (p) {
27
+ return "var(--grn-textBoxHeight-".concat(p.size, ")");
28
+ }, function (p) {
29
+ return "var(--grn-fieldTextBoxPaddingX-".concat(p.size, ")");
30
+ });
31
+ export var Input = function Input(_ref) {
32
+ var value = _ref.value,
33
+ _ref$placeholder = _ref.placeholder,
34
+ placeholder = _ref$placeholder === void 0 ? 'Placeholder' : _ref$placeholder,
35
+ _ref$size = _ref.size,
36
+ size = _ref$size === void 0 ? 'm' : _ref$size,
37
+ props = _objectWithoutProperties(_ref, _excluded);
38
+
39
+ return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
40
+ value: value,
41
+ placeholder: placeholder,
42
+ size: size
43
+ }, props));
44
+ };
45
+ Input.propTypes = {};
@@ -1,4 +1,5 @@
1
1
  @import './variables.css';
2
+ @import './components-variables.css';
2
3
 
3
4
  :root {
4
5
  --grn-letterSpacing-fixed: 1.3px;
@@ -12,16 +13,12 @@
12
13
  --grn-font-global: 'Beausite Classic', sans-serif;
13
14
  }
14
15
 
15
- * {
16
+ .grn-context, .grn-context * {
16
17
  letter-spacing: var(--grn-letterSpacing-global);
17
18
  line-height: var(--grn-lineHeight-global);
18
19
  }
19
20
 
20
- *, *:before, *:after {
21
- box-sizing: border-box;
22
- }
23
-
24
- body {
21
+ .grn-context {
25
22
  font-family: var(--grn-font-global);
26
23
  color: var(--grn-color-body);
27
24
  font-size: var(--grn-text-m);
@@ -29,7 +26,12 @@ body {
29
26
  -moz-osx-font-smoothing: grayscale;
30
27
  }
31
28
 
32
- a {
29
+ .grn-context a {
33
30
  color: inherit;
34
31
  text-decoration: none;
35
- }
32
+ }
33
+
34
+ *, *:before, *:after {
35
+ box-sizing: border-box;
36
+ }
37
+
@@ -0,0 +1,9 @@
1
+ :root {
2
+ --grn-textBoxHeight-s: calc(var(--grn-unit) * 3.5);
3
+ --grn-textBoxHeight-m: calc(var(--grn-unit) * 5);
4
+
5
+ --grn-buttonTextBoxPaddingX: calc(var(--grn-textBoxHeight) / 2);
6
+
7
+ --grn-fieldTextBoxPaddingX-s: calc(var(--grn-unit) * 1);
8
+ --grn-fieldTextBoxPaddingX-m: calc(var(--grn-unit) * 1.5);
9
+ }
@@ -26,8 +26,7 @@
26
26
  }
27
27
 
28
28
  :root {
29
- --grn-radius-s: calc(var(--grn-unit) * 0.5);
30
- --grn-radius-m: calc(var(--grn-unit) * 1);
29
+ --grn-radius-m: calc(var(--grn-unit) * 0.625);
31
30
  --grn-radius-l: calc(var(--grn-unit) * 1.25);
32
31
  --grn-radius-xl: calc(var(--grn-unit) * 2);
33
32
  }
@@ -78,4 +77,4 @@
78
77
  var(--grn-shadowLayer-1),
79
78
  var(--grn-shadowLayer-4)
80
79
  ;
81
- }
80
+ }
@@ -21,7 +21,6 @@ export var vars = {
21
21
  semiBold: "semiBold"
22
22
  },
23
23
  radiuses: {
24
- s: "s",
25
24
  m: "m",
26
25
  l: "l",
27
26
  xl: "xl"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "2.4.7",
3
+ "version": "2.5.1",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",