1 | ;
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports["default"] = transitions;
|
5 | var _errors = _interopRequireDefault(require("../internalHelpers/_errors"));
|
6 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
7 | /**
|
8 | * Accepts any number of transition values as parameters for creating a single transition statement. You may also pass an array of properties as the first parameter that you would like to apply the same transition values to (second parameter).
|
9 | * @example
|
10 | * // Styles as object usage
|
11 | * const styles = {
|
12 | * ...transitions('opacity 1.0s ease-in 0s', 'width 2.0s ease-in 2s'),
|
13 | * ...transitions(['color', 'background-color'], '2.0s ease-in 2s')
|
14 | * }
|
15 | *
|
16 | * // styled-components usage
|
17 | * const div = styled.div`
|
18 | * ${transitions('opacity 1.0s ease-in 0s', 'width 2.0s ease-in 2s')};
|
19 | * ${transitions(['color', 'background-color'], '2.0s ease-in 2s'),};
|
20 | * `
|
21 | *
|
22 | * // CSS as JS Output
|
23 | *
|
24 | * div {
|
25 | * 'transition': 'opacity 1.0s ease-in 0s, width 2.0s ease-in 2s'
|
26 | * 'transition': 'color 2.0s ease-in 2s, background-color 2.0s ease-in 2s',
|
27 | * }
|
28 | */
|
29 | function transitions() {
|
30 | for (var _len = arguments.length, properties = new Array(_len), _key = 0; _key < _len; _key++) {
|
31 | properties[_key] = arguments[_key];
|
32 | }
|
33 | if (Array.isArray(properties[0]) && properties.length === 2) {
|
34 | var value = properties[1];
|
35 | if (typeof value !== 'string') {
|
36 | throw new _errors["default"](61);
|
37 | }
|
38 | var transitionsString = properties[0].map(function (property) {
|
39 | return property + " " + value;
|
40 | }).join(', ');
|
41 | return {
|
42 | transition: transitionsString
|
43 | };
|
44 | } else {
|
45 | return {
|
46 | transition: properties.join(', ')
|
47 | };
|
48 | }
|
49 | }
|
50 | module.exports = exports.default; |
\ | No newline at end of file |