UNPKG

5.1 kBJavaScriptView Raw
1"use strict";
2var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4 return cooked;
5};
6var __extends = (this && this.__extends) || (function () {
7 var extendStatics = function (d, b) {
8 extendStatics = Object.setPrototypeOf ||
9 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
11 return extendStatics(d, b);
12 };
13 return function (d, b) {
14 extendStatics(d, b);
15 function __() { this.constructor = d; }
16 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17 };
18})();
19var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20 if (k2 === undefined) k2 = k;
21 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
22}) : (function(o, m, k, k2) {
23 if (k2 === undefined) k2 = k;
24 o[k2] = m[k];
25}));
26var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27 Object.defineProperty(o, "default", { enumerable: true, value: v });
28}) : function(o, v) {
29 o["default"] = v;
30});
31var __importStar = (this && this.__importStar) || function (mod) {
32 if (mod && mod.__esModule) return mod;
33 var result = {};
34 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
35 __setModuleDefault(result, mod);
36 return result;
37};
38Object.defineProperty(exports, "__esModule", { value: true });
39/** @jsx jsx */
40var React = __importStar(require("react"));
41var react_1 = require("@emotion/react");
42var helpers_1 = require("./helpers");
43var rotate = react_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(180deg)}\n 100% {transform: rotate(360deg)}\n"], ["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(180deg)}\n 100% {transform: rotate(360deg)}\n"])));
44var Loader = /** @class */ (function (_super) {
45 __extends(Loader, _super);
46 function Loader() {
47 var _this = _super !== null && _super.apply(this, arguments) || this;
48 _this.style = function (i) {
49 var margin = _this.props.margin;
50 var _a = helpers_1.parseLengthAndUnit(margin), value = _a.value, unit = _a.unit;
51 var left = (i % 2 ? -1 : 1) * (26 + value);
52 return react_1.css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 0.8;\n position: absolute;\n top: 0;\n left: ", "", ";\n "], ["\n opacity: 0.8;\n position: absolute;\n top: 0;\n left: ", "", ";\n "])), left, unit);
53 };
54 _this.ball = function () {
55 var _a = _this.props, color = _a.color, size = _a.size;
56 return react_1.css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n width: ", ";\n height: ", ";\n border-radius: 100%;\n "], ["\n background-color: ", ";\n width: ", ";\n height: ", ";\n border-radius: 100%;\n "])), color, helpers_1.cssValue(size), helpers_1.cssValue(size));
57 };
58 _this.wrapper = function () {
59 var speedMultiplier = _this.props.speedMultiplier;
60 return react_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n display: inline-block;\n position: relative;\n animation-fill-mode: both;\n animation: ", " ", "s 0s infinite cubic-bezier(0.7, -0.13, 0.22, 0.86);\n "], ["\n ", ";\n display: inline-block;\n position: relative;\n animation-fill-mode: both;\n animation: ", " ", "s 0s infinite cubic-bezier(0.7, -0.13, 0.22, 0.86);\n "])), _this.ball(), rotate, 1 / speedMultiplier);
61 };
62 _this.long = function () { return react_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n ", ";\n "], ["\n ", ";\n ", ";\n "])), _this.ball(), _this.style(1)); };
63 _this.short = function () { return react_1.css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n ", ";\n "], ["\n ", ";\n ", ";\n "])), _this.ball(), _this.style(2)); };
64 return _this;
65 }
66 Loader.prototype.render = function () {
67 var _a = this.props, loading = _a.loading, css = _a.css;
68 return loading ? (react_1.jsx("span", { css: [this.wrapper(), css] },
69 react_1.jsx("span", { css: this.long() }),
70 react_1.jsx("span", { css: this.short() }))) : null;
71 };
72 Loader.defaultProps = helpers_1.sizeMarginDefaults(15);
73 return Loader;
74}(React.PureComponent));
75exports.default = Loader;
76var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;