@flodesk/grain 2.20.2 → 2.20.3
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/index.js +1 -1
- package/es/types.js +1 -1
- package/es/utilities/responsive.js +9 -10
- package/es/utilities/styles.js +9 -9
- package/es/variables.js +100 -97
- package/package.json +1 -1
package/es/index.js
CHANGED
package/es/types.js
CHANGED
|
@@ -6,7 +6,7 @@ export var types = {
|
|
|
6
6
|
space: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
7
7
|
dimension: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
8
8
|
side: PropTypes.oneOf(["all", "left", "right", "top", "bottom", "x", "y"]),
|
|
9
|
-
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.
|
|
9
|
+
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.radii)), PropTypes.string]),
|
|
10
10
|
shadow: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.shadows)), PropTypes.string]),
|
|
11
11
|
position: PropTypes.oneOf(["static", "relative", "fixed", "absolute", "sticky"]),
|
|
12
12
|
textSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.texts)), PropTypes.string, PropTypes.object]),
|
|
@@ -25,7 +25,7 @@ import "core-js/modules/es.array.slice.js";
|
|
|
25
25
|
import "core-js/modules/es.array.from.js";
|
|
26
26
|
import "core-js/modules/es.regexp.exec.js";
|
|
27
27
|
import { getCssVar, isNumber, isString, u, isObject } from ".";
|
|
28
|
-
import {
|
|
28
|
+
import { vars, varInfo } from "../variables";
|
|
29
29
|
export var getMediaCss = function getMediaCss(breakpoint, property, value) {
|
|
30
30
|
var getValue = function getValue(val) {
|
|
31
31
|
if (val === 0) return val;
|
|
@@ -39,15 +39,14 @@ export var getMediaCss = function getMediaCss(breakpoint, property, value) {
|
|
|
39
39
|
|
|
40
40
|
return "\n @media ".concat(breakpoint, " {\n ").concat(property, ": ").concat(getValue(value), ";\n }\n ");
|
|
41
41
|
};
|
|
42
|
-
export var mapObjToMedia = function mapObjToMedia(property, obj,
|
|
43
|
-
var
|
|
44
|
-
var varPrefix = varNames[varName].prefix;
|
|
42
|
+
export var mapObjToMedia = function mapObjToMedia(property, obj, type) {
|
|
43
|
+
var varPrefix = varInfo[type].prefix;
|
|
45
44
|
var declarations = Object.entries(obj).map(function (_ref) {
|
|
46
45
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
47
46
|
breakpoint = _ref2[0],
|
|
48
47
|
value = _ref2[1];
|
|
49
48
|
|
|
50
|
-
if (value in vars[
|
|
49
|
+
if (value in vars[type]) {
|
|
51
50
|
return getMediaCss(breakpoint, property, getCssVar(varPrefix, value));
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -64,7 +63,7 @@ export var getDimension = function getDimension(dimension) {
|
|
|
64
63
|
};
|
|
65
64
|
export var getSpace = function getSpace(value) {
|
|
66
65
|
if (value in vars.spaces) {
|
|
67
|
-
return getCssVar(
|
|
66
|
+
return getCssVar(varInfo.spaces.prefix, value);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
if (value === 0) return value;
|
|
@@ -75,7 +74,7 @@ export var getResponsiveDimension = function getResponsiveDimension(property, di
|
|
|
75
74
|
if (!dimension) return;
|
|
76
75
|
|
|
77
76
|
if (isObject(dimension)) {
|
|
78
|
-
return mapObjToMedia(property, dimension,
|
|
77
|
+
return mapObjToMedia(property, dimension, varInfo.spaces.name);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
return "".concat(property, ": ").concat(getDimension(dimension));
|
|
@@ -84,14 +83,14 @@ export var getResponsiveSpace = function getResponsiveSpace(property, space) {
|
|
|
84
83
|
if (!space) return;
|
|
85
84
|
|
|
86
85
|
if (isObject(space)) {
|
|
87
|
-
return mapObjToMedia(property, space,
|
|
86
|
+
return mapObjToMedia(property, space, varInfo.spaces.name);
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
return "".concat(property, ": ").concat(getSpace(space));
|
|
91
90
|
};
|
|
92
91
|
export var getTextSize = function getTextSize(size) {
|
|
93
92
|
if (size in vars.texts) {
|
|
94
|
-
return getCssVar(
|
|
93
|
+
return getCssVar(varInfo.texts.prefix, size);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
if (isString(size)) return size;
|
|
@@ -101,7 +100,7 @@ export var getResponsiveTextSize = function getResponsiveTextSize(size) {
|
|
|
101
100
|
var property = "font-size";
|
|
102
101
|
|
|
103
102
|
if (isObject(size)) {
|
|
104
|
-
return mapObjToMedia(property, size,
|
|
103
|
+
return mapObjToMedia(property, size, varInfo.texts.name);
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
return "".concat(property, ": ").concat(getTextSize(size));
|
package/es/utilities/styles.js
CHANGED
|
@@ -17,33 +17,33 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
17
17
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
18
|
|
|
19
19
|
import { getCssVar, isNumber, isString, u, isArray } from ".";
|
|
20
|
-
import {
|
|
20
|
+
import { vars, varInfo } from "../variables";
|
|
21
21
|
import { getDimension } from "./responsive";
|
|
22
22
|
|
|
23
|
-
var allColors = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, vars.colors.
|
|
23
|
+
var allColors = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, vars.colors.bases), vars.colors.greys), vars.colors.semantics), vars.colors.fades);
|
|
24
24
|
|
|
25
25
|
export var getColor = function getColor(color) {
|
|
26
26
|
if (color in allColors) {
|
|
27
|
-
return getCssVar(
|
|
27
|
+
return getCssVar(varInfo.colors.prefix, color);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return color;
|
|
31
31
|
};
|
|
32
32
|
export var getShadow = function getShadow(shadow) {
|
|
33
33
|
if (shadow in vars.shadows) {
|
|
34
|
-
return getCssVar(
|
|
34
|
+
return getCssVar(varInfo.shadows.prefix, shadow);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return shadow;
|
|
38
38
|
};
|
|
39
39
|
export var getWeight = function getWeight(weight) {
|
|
40
40
|
if (weight in vars.weights) {
|
|
41
|
-
return getCssVar(
|
|
41
|
+
return getCssVar(varInfo.weights.prefix, weight);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
export var getRadius = function getRadius(radius) {
|
|
45
|
-
if (radius in vars.
|
|
46
|
-
return getCssVar(
|
|
45
|
+
if (radius in vars.radii) {
|
|
46
|
+
return getCssVar(varInfo.radii.prefix, radius);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (radius === 0) return radius;
|
|
@@ -52,12 +52,12 @@ export var getRadius = function getRadius(radius) {
|
|
|
52
52
|
};
|
|
53
53
|
export var getTransition = function getTransition(transition) {
|
|
54
54
|
if (transition in vars.transitions) {
|
|
55
|
-
return getCssVar(
|
|
55
|
+
return getCssVar(varInfo.transitions.prefix, transition);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
export var getIconSize = function getIconSize(size) {
|
|
59
59
|
if (size in vars.icons) {
|
|
60
|
-
return getCssVar(
|
|
60
|
+
return getCssVar(varInfo.icons.prefix, size);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return getDimension(size);
|
package/es/variables.js
CHANGED
|
@@ -1,114 +1,117 @@
|
|
|
1
|
-
var _vars;
|
|
2
|
-
|
|
3
|
-
import "core-js/modules/es.object.define-property.js";
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
export var grnPrefix = "--grn-";
|
|
8
|
-
export var
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
export var vars = {
|
|
3
|
+
texts: {
|
|
4
|
+
s: "s",
|
|
5
|
+
m: "m",
|
|
6
|
+
l: "l",
|
|
7
|
+
xl: "xl",
|
|
8
|
+
xxl: "xxl"
|
|
9
|
+
},
|
|
10
|
+
icons: {
|
|
11
|
+
s: "s",
|
|
12
|
+
m: "m",
|
|
13
|
+
l: "l",
|
|
14
|
+
xl: "xl",
|
|
15
|
+
xxl: "xxl"
|
|
16
|
+
},
|
|
17
|
+
spaces: {
|
|
18
|
+
xs: "xs",
|
|
19
|
+
s: "s",
|
|
20
|
+
m: "m",
|
|
21
|
+
l: "l",
|
|
22
|
+
xl: "xl",
|
|
23
|
+
xxl: "xxl"
|
|
24
|
+
},
|
|
25
|
+
weights: {
|
|
26
|
+
normal: "normal",
|
|
27
|
+
medium: "medium",
|
|
28
|
+
semiBold: "semiBold"
|
|
29
|
+
},
|
|
30
|
+
radii: {
|
|
31
|
+
s: "s",
|
|
32
|
+
m: "m",
|
|
33
|
+
l: "l"
|
|
34
|
+
},
|
|
35
|
+
shadows: {
|
|
36
|
+
s: "s",
|
|
37
|
+
m: "m",
|
|
38
|
+
l: "l"
|
|
39
|
+
},
|
|
40
|
+
transitions: {
|
|
41
|
+
slow: "slow",
|
|
42
|
+
fast: "fast",
|
|
43
|
+
xFast: "xFast"
|
|
44
|
+
},
|
|
45
|
+
colors: {
|
|
46
|
+
greys: {
|
|
47
|
+
grey8: "grey8",
|
|
48
|
+
grey7: "grey7",
|
|
49
|
+
grey6: "grey6",
|
|
50
|
+
grey5: "grey5",
|
|
51
|
+
grey4: "grey4",
|
|
52
|
+
grey3: "grey3",
|
|
53
|
+
grey2: "grey2",
|
|
54
|
+
grey1: "grey1"
|
|
55
|
+
},
|
|
56
|
+
fades: {
|
|
57
|
+
fade7: "fade7",
|
|
58
|
+
fade6: "fade6",
|
|
59
|
+
fade5: "fade5",
|
|
60
|
+
fade4: "fade4",
|
|
61
|
+
fade3: "fade3",
|
|
62
|
+
fade2: "fade2",
|
|
63
|
+
fade1: "fade1"
|
|
64
|
+
},
|
|
65
|
+
bases: {
|
|
66
|
+
blue: "blue",
|
|
67
|
+
red: "red"
|
|
68
|
+
},
|
|
69
|
+
semantics: {
|
|
70
|
+
body: "body",
|
|
71
|
+
bodyDimmed: "bodyDimmed",
|
|
72
|
+
accent: "accent",
|
|
73
|
+
backgroundSecondary: "backgroundSecondary",
|
|
74
|
+
background: "background",
|
|
75
|
+
overlay: "overlay",
|
|
76
|
+
border: "border",
|
|
77
|
+
selection: "selection",
|
|
78
|
+
danger: "danger",
|
|
79
|
+
disabledContent: "disabledContent",
|
|
80
|
+
disabledBackground: "disabledBackground"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export var varInfo = {
|
|
85
|
+
texts: {
|
|
86
|
+
name: 'texts',
|
|
11
87
|
prefix: "text"
|
|
12
88
|
},
|
|
13
|
-
|
|
14
|
-
|
|
89
|
+
icons: {
|
|
90
|
+
name: 'icons',
|
|
15
91
|
prefix: "icon"
|
|
16
92
|
},
|
|
17
|
-
|
|
18
|
-
|
|
93
|
+
spaces: {
|
|
94
|
+
name: 'spaces',
|
|
19
95
|
prefix: "space"
|
|
20
96
|
},
|
|
21
|
-
|
|
22
|
-
|
|
97
|
+
weights: {
|
|
98
|
+
name: 'weights',
|
|
23
99
|
prefix: "weight"
|
|
24
100
|
},
|
|
25
|
-
|
|
26
|
-
|
|
101
|
+
radii: {
|
|
102
|
+
name: 'radii',
|
|
27
103
|
prefix: "radius"
|
|
28
104
|
},
|
|
29
|
-
|
|
30
|
-
|
|
105
|
+
shadows: {
|
|
106
|
+
name: 'shadows',
|
|
31
107
|
prefix: "shadow"
|
|
32
108
|
},
|
|
33
|
-
|
|
34
|
-
|
|
109
|
+
transitions: {
|
|
110
|
+
name: 'transitions',
|
|
35
111
|
prefix: "transition"
|
|
36
112
|
},
|
|
37
|
-
|
|
38
|
-
|
|
113
|
+
colors: {
|
|
114
|
+
name: 'colors',
|
|
39
115
|
prefix: "color"
|
|
40
116
|
}
|
|
41
|
-
};
|
|
42
|
-
export var vars = (_vars = {}, _defineProperty(_vars, varNames.text.group, {
|
|
43
|
-
s: "s",
|
|
44
|
-
m: "m",
|
|
45
|
-
l: "l",
|
|
46
|
-
xl: "xl",
|
|
47
|
-
xxl: "xxl"
|
|
48
|
-
}), _defineProperty(_vars, varNames.icon.group, {
|
|
49
|
-
s: "s",
|
|
50
|
-
m: "m",
|
|
51
|
-
l: "l",
|
|
52
|
-
xl: "xl",
|
|
53
|
-
xxl: "xxl"
|
|
54
|
-
}), _defineProperty(_vars, varNames.space.group, {
|
|
55
|
-
xs: "xs",
|
|
56
|
-
s: "s",
|
|
57
|
-
m: "m",
|
|
58
|
-
l: "l",
|
|
59
|
-
xl: "xl",
|
|
60
|
-
xxl: "xxl"
|
|
61
|
-
}), _defineProperty(_vars, varNames.weight.group, {
|
|
62
|
-
normal: "normal",
|
|
63
|
-
medium: "medium",
|
|
64
|
-
semiBold: "semiBold"
|
|
65
|
-
}), _defineProperty(_vars, varNames.radius.group, {
|
|
66
|
-
s: "s",
|
|
67
|
-
m: "m",
|
|
68
|
-
l: "l"
|
|
69
|
-
}), _defineProperty(_vars, varNames.shadow.group, {
|
|
70
|
-
s: "s",
|
|
71
|
-
m: "m",
|
|
72
|
-
l: "l"
|
|
73
|
-
}), _defineProperty(_vars, varNames.transition.group, {
|
|
74
|
-
slow: "slow",
|
|
75
|
-
fast: "fast",
|
|
76
|
-
xFast: "xFast"
|
|
77
|
-
}), _defineProperty(_vars, varNames.color.group, {
|
|
78
|
-
greys: {
|
|
79
|
-
grey8: "grey8",
|
|
80
|
-
grey7: "grey7",
|
|
81
|
-
grey6: "grey6",
|
|
82
|
-
grey5: "grey5",
|
|
83
|
-
grey4: "grey4",
|
|
84
|
-
grey3: "grey3",
|
|
85
|
-
grey2: "grey2",
|
|
86
|
-
grey1: "grey1"
|
|
87
|
-
},
|
|
88
|
-
fades: {
|
|
89
|
-
fade7: "fade7",
|
|
90
|
-
fade6: "fade6",
|
|
91
|
-
fade5: "fade5",
|
|
92
|
-
fade4: "fade4",
|
|
93
|
-
fade3: "fade3",
|
|
94
|
-
fade2: "fade2",
|
|
95
|
-
fade1: "fade1"
|
|
96
|
-
},
|
|
97
|
-
baseColors: {
|
|
98
|
-
blue: "blue",
|
|
99
|
-
red: "red"
|
|
100
|
-
},
|
|
101
|
-
semanticColors: {
|
|
102
|
-
body: "body",
|
|
103
|
-
bodyDimmed: "bodyDimmed",
|
|
104
|
-
accent: "accent",
|
|
105
|
-
backgroundSecondary: "backgroundSecondary",
|
|
106
|
-
background: "background",
|
|
107
|
-
overlay: "overlay",
|
|
108
|
-
border: "border",
|
|
109
|
-
selection: "selection",
|
|
110
|
-
danger: "danger",
|
|
111
|
-
disabledContent: "disabledContent",
|
|
112
|
-
disabledBackground: "disabledBackground"
|
|
113
|
-
}
|
|
114
|
-
}), _vars);
|
|
117
|
+
};
|