UNPKG

1.94 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.propKey = propKey;
7exports.intersection = intersection;
8exports.createRuleSet = createRuleSet;
9exports.createClassName = createClassName;
10
11function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
12
13function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
14
15function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
16
17function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
18
19/**
20 * Extracts the single breakpoint prop from the props object.
21 */
22function propKey(breakpointProps) {
23 return Object.keys(breakpointProps)[0];
24}
25/**
26 * Returns the intersection of two arrays.
27 */
28
29
30function intersection(a1, a2) {
31 return a2 ? a1.filter(function (element) {
32 return a2.indexOf(element) >= 0;
33 }) : _toConsumableArray(a1);
34}
35/**
36 * Generate a style rule for a given class name that will hide the element
37 * when the given query matches.
38 */
39
40
41function createRuleSet(className, query) {
42 return "@media ".concat(query, "{.").concat(className, "{display:none!important;}}");
43}
44/**
45 * Given a list of strings, or string tuples, generates a class name.
46 */
47
48
49function createClassName() {
50 for (var _len = arguments.length, components = new Array(_len), _key = 0; _key < _len; _key++) {
51 components[_key] = arguments[_key];
52 }
53
54 return ["fresnel"].concat(_toConsumableArray(components.reduce(function (acc, breakpoint) {
55 return Array.isArray(breakpoint) ? _toConsumableArray(acc).concat(_toConsumableArray(breakpoint)) : _toConsumableArray(acc).concat([breakpoint]);
56 }, []))).join("-");
57}
58//# sourceMappingURL=Utils.js.map
\No newline at end of file