@flodesk/grain 1.2.4 → 1.5.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.
@@ -26,9 +26,21 @@
26
26
  }
27
27
 
28
28
  :root {
29
- --grn-color-body: hsl(0 0% 7%);
30
- --grn-color-bodyDimmed: hsl(0 0% 7% / 40%);
31
- --grn-color-primary: hsl(0 0% 7%);
29
+ --grn-color-grey8: hsl(0 0% 7%);
30
+ --grn-color-grey7: hsl(0 0% 20%);
31
+ --grn-color-grey6: hsl(0 0% 32%);
32
+ --grn-color-grey5: hsl(0 0% 44%);
33
+ --grn-color-grey4: hsl(0 0% 63%);
34
+ --grn-color-grey3: hsl(0 0% 78%);
35
+ --grn-color-grey2: hsl(0 0% 87%);
36
+ --grn-color-grey1: hsl(0 0% 96%);
37
+
38
+ --grn-color-body: var(--grn-color-grey8);
39
+ --grn-color-bodyDimmed: hsl(0 0% 7% / 50%);
40
+ --grn-color-primary: var(--grn-color-grey8);
41
+ --grn-color-backgroundSecondary: hsl(0 0% 100%);
42
+ --grn-color-background: var(--grn-color-grey1);
43
+ --grn-color-border: hsl(0 0% 7% / 15%);
32
44
  }
33
45
 
34
46
  * {
@@ -43,7 +55,7 @@
43
55
  }
44
56
 
45
57
  body {
46
- font-family: 'BeausiteClassic';
58
+ font-family: 'BeausiteClassic', sans-serif;
47
59
  color: var(--grn-color-body);
48
60
  font-size: var(--grn-text-m);
49
61
  }
@@ -6,29 +6,33 @@ var _templateObject;
6
6
 
7
7
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
8
8
 
9
+ import { getColor, getTextSize, getWeight } from '../../utilities';
9
10
  import PropTypes from 'prop-types';
10
11
  import React from "react";
11
- import { getTextSize } from '../../utilities';
12
12
  import styled from "@emotion/styled";
13
- export var textSizes = ['s', 'm', 'l', 'xl', 'xxl'];
14
- export var weights = ['normal', 'medium', 'semiBold'];
15
- var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n font-size: ", ";\n font-weight: var(--grn-weight-", ");\n"])), function (p) {
13
+ import { varOptions } from '../../variables';
14
+ var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n"])), function (p) {
16
15
  return getTextSize(p.size);
17
16
  }, function (p) {
18
- return p.weight;
17
+ return getWeight(p.weight);
18
+ }, function (p) {
19
+ return getColor(p.color);
19
20
  });
20
21
  export var Text = function Text(_ref) {
21
22
  var children = _ref.children,
22
23
  _ref$size = _ref.size,
23
24
  size = _ref$size === void 0 ? 'm' : _ref$size,
24
25
  _ref$weight = _ref.weight,
25
- weight = _ref$weight === void 0 ? 'normal' : _ref$weight;
26
+ weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
27
+ color = _ref.color;
26
28
  return /*#__PURE__*/React.createElement(Wrapper, {
27
29
  size: size,
28
- weight: weight
30
+ weight: weight,
31
+ color: color
29
32
  }, children);
30
33
  };
31
34
  Text.propTypes = {
32
- size: PropTypes.oneOf(textSizes),
33
- weight: PropTypes.oneOf(weights)
35
+ size: PropTypes.oneOf(varOptions.textSizes),
36
+ weight: PropTypes.oneOf(varOptions.weights),
37
+ color: PropTypes.oneOfType([PropTypes.oneOf(varOptions.weights), PropTypes.string])
34
38
  };
@@ -1,10 +1,23 @@
1
1
  import "core-js/modules/es.array.includes.js";
2
2
  import "core-js/modules/es.string.includes.js";
3
- import { textSizes } from "../components/text";
3
+ import "core-js/modules/es.array.concat.js";
4
+ import { grnPrefix, varOptions, varPrefixes } from "../variables";
5
+ export var getColor = function getColor(color) {
6
+ if (varOptions.allColors.includes(color)) {
7
+ return "var(".concat(grnPrefix).concat(varPrefixes.color).concat(color, ")");
8
+ }
9
+
10
+ return color;
11
+ };
4
12
  export var getTextSize = function getTextSize(size) {
5
- if (textSizes.includes(size)) {
6
- return "var(--grn-text-".concat(size, ")");
13
+ if (varOptions.textSizes.includes(size)) {
14
+ return "var(".concat(grnPrefix).concat(varPrefixes.text).concat(size, ")");
7
15
  }
8
16
 
9
17
  return size;
18
+ };
19
+ export var getWeight = function getWeight(weight) {
20
+ if (varOptions.weights.includes(weight)) {
21
+ return "var(".concat(grnPrefix).concat(varPrefixes.weight).concat(weight, ")");
22
+ }
10
23
  };
@@ -0,0 +1,46 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
+
13
+ import "core-js/modules/es.array.reverse.js";
14
+ import "core-js/modules/es.array.concat.js";
15
+ import "core-js/modules/es.symbol.js";
16
+ import "core-js/modules/es.symbol.description.js";
17
+ import "core-js/modules/es.object.to-string.js";
18
+ import "core-js/modules/es.symbol.iterator.js";
19
+ import "core-js/modules/es.array.iterator.js";
20
+ import "core-js/modules/es.string.iterator.js";
21
+ import "core-js/modules/web.dom-collections.iterator.js";
22
+ import "core-js/modules/es.array.from.js";
23
+ import "core-js/modules/es.array.slice.js";
24
+ import "core-js/modules/es.regexp.exec.js";
25
+ var greysAmount = 8;
26
+ var greysArray = [];
27
+
28
+ for (var step = 1; step < greysAmount + 1; step++) {
29
+ greysArray.push("grey" + step);
30
+ }
31
+
32
+ export var grnPrefix = "--grn-";
33
+ export var varPrefixes = {
34
+ space: "space-",
35
+ weight: "weight-",
36
+ text: "text-",
37
+ color: "color-"
38
+ };
39
+ export var greys = greysArray.reverse();
40
+ export var semanticColors = ["body", "bodyDimmed", "primary", "backgroundSecondary", "background", "border"];
41
+ export var varOptions = {
42
+ textSizes: ["s", "m", "l", "xl", "xxl"],
43
+ spaces: ["xs", "s", "m", "l", "xl", "xxl"],
44
+ weights: ["normal", "medium", "semiBold"],
45
+ allColors: [].concat(_toConsumableArray(greys), semanticColors)
46
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "1.2.4",
3
+ "version": "1.5.0",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",