1 | ;
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = animation;
|
5 | var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
|
6 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
7 | /**
|
8 | * Shorthand for easily setting the animation property. Allows either multiple arrays with animations
|
9 | * or a single animation spread over the arguments.
|
10 | * @example
|
11 | * // Styles as object usage
|
12 | * const styles = {
|
13 | * ...animation(['rotate', '1s', 'ease-in-out'], ['colorchange', '2s'])
|
14 | * }
|
15 | *
|
16 | * // styled-components usage
|
17 | * const div = styled.div`
|
18 | * ${animation(['rotate', '1s', 'ease-in-out'], ['colorchange', '2s'])}
|
19 | * `
|
20 | *
|
21 | * // CSS as JS Output
|
22 | *
|
23 | * div {
|
24 | * 'animation': 'rotate 1s ease-in-out, colorchange 2s'
|
25 | * }
|
26 | * @example
|
27 | * // Styles as object usage
|
28 | * const styles = {
|
29 | * ...animation('rotate', '1s', 'ease-in-out')
|
30 | * }
|
31 | *
|
32 | * // styled-components usage
|
33 | * const div = styled.div`
|
34 | * ${animation('rotate', '1s', 'ease-in-out')}
|
35 | * `
|
36 | *
|
37 | * // CSS as JS Output
|
38 | *
|
39 | * div {
|
40 | * 'animation': 'rotate 1s ease-in-out'
|
41 | * }
|
42 | */
|
43 | function animation() {
|
44 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
45 | args[_key] = arguments[_key];
|
46 | }
|
47 | // Allow single or multiple animations passed
|
48 | var multiMode = Array.isArray(args[0]);
|
49 | if (!multiMode && args.length > 8) {
|
50 | throw new _errors["default"](64);
|
51 | }
|
52 | var code = args.map(function (arg) {
|
53 | if (multiMode && !Array.isArray(arg) || !multiMode && Array.isArray(arg)) {
|
54 | throw new _errors["default"](65);
|
55 | }
|
56 | if (Array.isArray(arg) && arg.length > 8) {
|
57 | throw new _errors["default"](66);
|
58 | }
|
59 | return Array.isArray(arg) ? arg.join(' ') : arg;
|
60 | }).join(', ');
|
61 | return {
|
62 | animation: code
|
63 | };
|
64 | }
|
65 | module.exports = exports.default; |
\ | No newline at end of file |