@flodesk/grain 1.3.0 → 1.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/es/base-styles.css +8 -5
- package/es/components/text/index.js +13 -8
- package/es/utilities/index.js +22 -4
- package/es/variables/index.js +31 -7
- package/package.json +1 -1
package/es/base-styles.css
CHANGED
|
@@ -26,10 +26,6 @@
|
|
|
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%);
|
|
32
|
-
|
|
33
29
|
--grn-color-grey8: hsl(0 0% 7%);
|
|
34
30
|
--grn-color-grey7: hsl(0 0% 20%);
|
|
35
31
|
--grn-color-grey6: hsl(0 0% 32%);
|
|
@@ -38,6 +34,13 @@
|
|
|
38
34
|
--grn-color-grey3: hsl(0 0% 78%);
|
|
39
35
|
--grn-color-grey2: hsl(0 0% 87%);
|
|
40
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% / 9%);
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
* {
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
body {
|
|
55
|
-
font-family: 'BeausiteClassic';
|
|
58
|
+
font-family: 'BeausiteClassic', sans-serif;
|
|
56
59
|
color: var(--grn-color-body);
|
|
57
60
|
font-size: var(--grn-text-m);
|
|
58
61
|
}
|
|
@@ -6,28 +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 {
|
|
9
|
+
import { getColor, getTextSize, getWeight } from '../../utilities';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React from "react";
|
|
12
|
-
import {
|
|
12
|
+
import { cssVarOptions } from '../../variables';
|
|
13
13
|
import styled from "@emotion/styled";
|
|
14
|
-
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n font-size: ", ";\n font-weight:
|
|
14
|
+
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n font-size: ", ";\n font-weight: ", ";\n color: ", ";\n"])), function (p) {
|
|
15
15
|
return getTextSize(p.size);
|
|
16
16
|
}, function (p) {
|
|
17
|
-
return p.weight;
|
|
17
|
+
return getWeight(p.weight);
|
|
18
|
+
}, function (p) {
|
|
19
|
+
return getColor(p.color);
|
|
18
20
|
});
|
|
19
21
|
export var Text = function Text(_ref) {
|
|
20
22
|
var children = _ref.children,
|
|
21
23
|
_ref$size = _ref.size,
|
|
22
24
|
size = _ref$size === void 0 ? 'm' : _ref$size,
|
|
23
25
|
_ref$weight = _ref.weight,
|
|
24
|
-
weight = _ref$weight === void 0 ? 'normal' : _ref$weight
|
|
26
|
+
weight = _ref$weight === void 0 ? 'normal' : _ref$weight,
|
|
27
|
+
color = _ref.color;
|
|
25
28
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
26
29
|
size: size,
|
|
27
|
-
weight: weight
|
|
30
|
+
weight: weight,
|
|
31
|
+
color: color
|
|
28
32
|
}, children);
|
|
29
33
|
};
|
|
30
34
|
Text.propTypes = {
|
|
31
|
-
size: PropTypes.oneOf(textSizes),
|
|
32
|
-
weight: PropTypes.oneOf(weights)
|
|
35
|
+
size: PropTypes.oneOf(cssVarOptions.textSizes),
|
|
36
|
+
weight: PropTypes.oneOf(cssVarOptions.weights),
|
|
37
|
+
color: PropTypes.oneOfType([PropTypes.oneOf(cssVarOptions.weights), PropTypes.string])
|
|
33
38
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
import "core-js/modules/es.array.concat.js";
|
|
1
2
|
import "core-js/modules/es.array.includes.js";
|
|
2
3
|
import "core-js/modules/es.string.includes.js";
|
|
3
|
-
import "
|
|
4
|
-
|
|
4
|
+
import { cssVarOptions, grnPrefix } from "../variables";
|
|
5
|
+
export var getCssVarCore = function getCssVarCore(type, value) {
|
|
6
|
+
return "".concat(grnPrefix).concat(type, "-").concat(value);
|
|
7
|
+
};
|
|
8
|
+
export var getCssVar = function getCssVar(type, value) {
|
|
9
|
+
return "var(".concat(getCssVarCore(type, value), ")");
|
|
10
|
+
};
|
|
11
|
+
export var getColor = function getColor(color) {
|
|
12
|
+
if (cssVarOptions.colors.includes(color)) {
|
|
13
|
+
return getCssVar("color", color);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return color;
|
|
17
|
+
};
|
|
5
18
|
export var getTextSize = function getTextSize(size) {
|
|
6
|
-
if (textSizes.includes(size)) {
|
|
7
|
-
return
|
|
19
|
+
if (cssVarOptions.textSizes.includes(size)) {
|
|
20
|
+
return getCssVar("text", size);
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
return size;
|
|
24
|
+
};
|
|
25
|
+
export var getWeight = function getWeight(weight) {
|
|
26
|
+
if (cssVarOptions.weights.includes(weight)) {
|
|
27
|
+
return getCssVar("weight", weight);
|
|
28
|
+
}
|
|
11
29
|
};
|
package/es/variables/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
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
|
+
|
|
1
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";
|
|
2
25
|
var greysAmount = 8;
|
|
3
26
|
var greysArray = [];
|
|
4
27
|
|
|
@@ -6,11 +29,12 @@ for (var step = 1; step < greysAmount + 1; step++) {
|
|
|
6
29
|
greysArray.push("grey" + step);
|
|
7
30
|
}
|
|
8
31
|
|
|
9
|
-
export var
|
|
10
|
-
export var spaceVarPrefix = "space-";
|
|
11
|
-
export var weightVarPrefix = "weight-";
|
|
12
|
-
export var textVarPrefix = "text-";
|
|
32
|
+
export var grnPrefix = "--grn-";
|
|
13
33
|
export var greys = greysArray.reverse();
|
|
14
|
-
export var
|
|
15
|
-
export var
|
|
16
|
-
|
|
34
|
+
export var semanticColors = ["body", "bodyDimmed", "primary", "backgroundSecondary", "background", "border"];
|
|
35
|
+
export var cssVarOptions = {
|
|
36
|
+
textSizes: ["s", "m", "l", "xl", "xxl"],
|
|
37
|
+
spaces: ["xs", "s", "m", "l", "xl", "xxl"],
|
|
38
|
+
weights: ["normal", "medium", "semiBold"],
|
|
39
|
+
colors: [].concat(_toConsumableArray(greys), semanticColors)
|
|
40
|
+
};
|