UNPKG

3.96 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _react = _interopRequireDefault(require("react"));
9
10var _propTypes = _interopRequireDefault(require("prop-types"));
11
12var _withStyles = require("../helpers/withStyles");
13
14var _reactWithStyles = require("react-with-styles");
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
19
20function _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; }
21
22var propTypes = _objectSpread({}, _reactWithStyles.withStylesPropTypes, {
23 isLoading: _propTypes.default.bool,
24 small: _propTypes.default.bool,
25 large: _propTypes.default.bool,
26 primary: _propTypes.default.bool,
27 secondary: _propTypes.default.bool,
28 mono: _propTypes.default.bool
29});
30
31var Loader = function Loader(_ref) {
32 var isLoading = _ref.isLoading,
33 styles = _ref.styles,
34 small = _ref.small,
35 large = _ref.large,
36 secondary = _ref.secondary,
37 primary = _ref.primary,
38 mono = _ref.mono;
39 return _react.default.createElement("div", (0, _withStyles.css)(styles.loader), _react.default.createElement("div", (0, _withStyles.css)(styles.loader__ball, small && styles.loader__ball_small, large && styles.loader__ball_large, secondary && styles.loader__ball_secondary, primary && styles.loader__ball_primary, mono && styles.loader__ball_mono)), _react.default.createElement("div", (0, _withStyles.css)(styles.loader__ball, styles.loader__ball_second, small && styles.loader__ball_small, large && styles.loader__ball_large, secondary && styles.loader__ball_secondary, primary && styles.loader__ball_primary, mono && styles.loader__ball_mono)), _react.default.createElement("div", (0, _withStyles.css)(styles.loader__ball, styles.loader__ball_third, small && styles.loader__ball_small, large && styles.loader__ball_large, secondary && styles.loader__ball_secondary, primary && styles.loader__ball_primary, mono && styles.loader__ball_mono)));
40};
41
42Loader.propTypes = propTypes;
43var bounceKeyframes = {
44 '0%, 80%, 100%': {
45 transform: 'scale(0)'
46 },
47 '40%': {
48 transform: 'scale(1.0)'
49 }
50};
51var LoaderWithStyles = (0, _withStyles.withStyles)(function (_ref2) {
52 var color = _ref2.color,
53 units = _ref2.units;
54 return {
55 loader: {
56 display: 'flex',
57 alignItems: 'center',
58 justifyContent: 'center'
59 },
60 loader__ball: {
61 width: units(1),
62 height: units(1),
63 margin: units(.1),
64 backgroundColor: color.white,
65 borderRadius: '100%',
66 display: 'inline-block',
67 animationName: bounceKeyframes,
68 animationDuration: '1.4s',
69 animationIterationCount: 'infinite',
70 animationEasing: 'ease-in-out',
71 animationDirection: 'both'
72 },
73 loader__ball_small: {
74 width: units(0.5),
75 height: units(0.5)
76 },
77 loader__ball_large: {
78 width: units(2),
79 height: units(2)
80 },
81 loader__ball_primary: {
82 backgroundColor: color.primary
83 },
84 loader__ball_secondary: {
85 backgroundColor: color.secondary
86 },
87 loader__ball_mono: {
88 backgroundColor: color.grayDarker
89 },
90 loader__ball_second: {
91 animationDelay: '0.16s'
92 },
93 loader__ball_third: {
94 animationDelay: '0.32s'
95 }
96 };
97})(Loader);
98var _default = LoaderWithStyles;
99exports.default = _default;
\No newline at end of file