@flodesk/grain 1.5.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 +1 -1
- package/es/components/text/index.js +4 -4
- package/es/utilities/index.js +14 -8
- package/es/variables/index.js +2 -8
- package/package.json +1 -1
package/es/base-styles.css
CHANGED
|
@@ -9,8 +9,8 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
9
9
|
import { getColor, getTextSize, getWeight } from '../../utilities';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React from "react";
|
|
12
|
+
import { cssVarOptions } from '../../variables';
|
|
12
13
|
import styled from "@emotion/styled";
|
|
13
|
-
import { varOptions } from '../../variables';
|
|
14
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) {
|
|
@@ -32,7 +32,7 @@ export var Text = function Text(_ref) {
|
|
|
32
32
|
}, children);
|
|
33
33
|
};
|
|
34
34
|
Text.propTypes = {
|
|
35
|
-
size: PropTypes.oneOf(
|
|
36
|
-
weight: PropTypes.oneOf(
|
|
37
|
-
color: PropTypes.oneOfType([PropTypes.oneOf(
|
|
35
|
+
size: PropTypes.oneOf(cssVarOptions.textSizes),
|
|
36
|
+
weight: PropTypes.oneOf(cssVarOptions.weights),
|
|
37
|
+
color: PropTypes.oneOfType([PropTypes.oneOf(cssVarOptions.weights), PropTypes.string])
|
|
38
38
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -1,23 +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
|
+
};
|
|
5
11
|
export var getColor = function getColor(color) {
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
12
|
+
if (cssVarOptions.colors.includes(color)) {
|
|
13
|
+
return getCssVar("color", color);
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
return color;
|
|
11
17
|
};
|
|
12
18
|
export var getTextSize = function getTextSize(size) {
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
19
|
+
if (cssVarOptions.textSizes.includes(size)) {
|
|
20
|
+
return getCssVar("text", size);
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
return size;
|
|
18
24
|
};
|
|
19
25
|
export var getWeight = function getWeight(weight) {
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
26
|
+
if (cssVarOptions.weights.includes(weight)) {
|
|
27
|
+
return getCssVar("weight", weight);
|
|
22
28
|
}
|
|
23
29
|
};
|
package/es/variables/index.js
CHANGED
|
@@ -30,17 +30,11 @@ for (var step = 1; step < greysAmount + 1; step++) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export var grnPrefix = "--grn-";
|
|
33
|
-
export var varPrefixes = {
|
|
34
|
-
space: "space-",
|
|
35
|
-
weight: "weight-",
|
|
36
|
-
text: "text-",
|
|
37
|
-
color: "color-"
|
|
38
|
-
};
|
|
39
33
|
export var greys = greysArray.reverse();
|
|
40
34
|
export var semanticColors = ["body", "bodyDimmed", "primary", "backgroundSecondary", "background", "border"];
|
|
41
|
-
export var
|
|
35
|
+
export var cssVarOptions = {
|
|
42
36
|
textSizes: ["s", "m", "l", "xl", "xxl"],
|
|
43
37
|
spaces: ["xs", "s", "m", "l", "xl", "xxl"],
|
|
44
38
|
weights: ["normal", "medium", "semiBold"],
|
|
45
|
-
|
|
39
|
+
colors: [].concat(_toConsumableArray(greys), semanticColors)
|
|
46
40
|
};
|