@flodesk/grain 3.0.2 → 3.0.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/utilities/responsive.js +19 -27
- package/package.json +1 -1
|
@@ -13,7 +13,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import "core-js/modules/es.array.concat.js";
|
|
14
14
|
import "core-js/modules/es.array.map.js";
|
|
15
15
|
import "core-js/modules/es.object.entries.js";
|
|
16
|
-
import "core-js/modules/es.array.reverse.js";
|
|
17
16
|
import "core-js/modules/es.symbol.js";
|
|
18
17
|
import "core-js/modules/es.symbol.description.js";
|
|
19
18
|
import "core-js/modules/es.object.to-string.js";
|
|
@@ -40,20 +39,23 @@ export var getMediaCss = function getMediaCss(mediaQuery, property, value) {
|
|
|
40
39
|
return "\n ".concat(mediaQuery, " {\n ").concat(property, ": ").concat(getValue(value), ";\n }\n ");
|
|
41
40
|
};
|
|
42
41
|
export var mapObjToMedia = function mapObjToMedia(property, obj, type) {
|
|
43
|
-
var
|
|
42
|
+
var checkValueInVars = function checkValueInVars(value) {
|
|
43
|
+
if (type && value in vars[type]) {
|
|
44
|
+
var varPrefix = varInfo[type].prefix;
|
|
45
|
+
return getCssVar(varPrefix, value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
|
|
44
51
|
var declarations = Object.entries(obj).map(function (_ref) {
|
|
45
52
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
46
53
|
mediaQuery = _ref2[0],
|
|
47
54
|
value = _ref2[1];
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return getMediaCss(mediaQuery, property, value);
|
|
54
|
-
}); // reverse array to make sure max-widths correctly override
|
|
55
|
-
|
|
56
|
-
declarations.reverse().join('');
|
|
56
|
+
return getMediaCss(mediaQuery, property, checkValueInVars(value));
|
|
57
|
+
});
|
|
58
|
+
declarations.join('');
|
|
57
59
|
return declarations;
|
|
58
60
|
};
|
|
59
61
|
export var getDimension = function getDimension(dimension) {
|
|
@@ -61,14 +63,14 @@ export var getDimension = function getDimension(dimension) {
|
|
|
61
63
|
if (isString(dimension)) return dimension;
|
|
62
64
|
if (isNumber(dimension)) return u(dimension);
|
|
63
65
|
};
|
|
64
|
-
export var getSpace = function getSpace(
|
|
65
|
-
if (
|
|
66
|
-
return getCssVar(varInfo.spaces.prefix,
|
|
66
|
+
export var getSpace = function getSpace(space) {
|
|
67
|
+
if (space in vars.spaces) {
|
|
68
|
+
return getCssVar(varInfo.spaces.prefix, space);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
if (
|
|
70
|
-
if (isString(
|
|
71
|
-
if (isNumber(
|
|
71
|
+
if (space === 0) return space;
|
|
72
|
+
if (isString(space)) return space;
|
|
73
|
+
if (isNumber(space)) return u(space);
|
|
72
74
|
};
|
|
73
75
|
export var getResponsiveDimension = function getResponsiveDimension(property, dimension) {
|
|
74
76
|
if (!dimension) return;
|
|
@@ -105,22 +107,12 @@ export var getResponsiveTextSize = function getResponsiveTextSize(size) {
|
|
|
105
107
|
|
|
106
108
|
return "".concat(property, ": ").concat(getTextSize(size));
|
|
107
109
|
};
|
|
108
|
-
export var mapColumnsToMedia = function mapColumnsToMedia(property, obj) {
|
|
109
|
-
var declarations = Object.entries(obj).map(function (_ref3) {
|
|
110
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
111
|
-
breakpoint = _ref4[0],
|
|
112
|
-
value = _ref4[1];
|
|
113
|
-
|
|
114
|
-
return getMediaCss(breakpoint, property, value);
|
|
115
|
-
});
|
|
116
|
-
return declarations.join('');
|
|
117
|
-
};
|
|
118
110
|
export var getResponsiveGridColumns = function getResponsiveGridColumns(columns) {
|
|
119
111
|
if (!columns) return;
|
|
120
112
|
var property = 'grid-template-columns';
|
|
121
113
|
|
|
122
114
|
if (isObject(columns)) {
|
|
123
|
-
return
|
|
115
|
+
return mapObjToMedia(property, columns);
|
|
124
116
|
}
|
|
125
117
|
|
|
126
118
|
return "".concat(property, ": ").concat(columns);
|