1 | "use strict";
|
2 | var __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 | };
|
6 | var __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 | })();
|
19 | var __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 | }));
|
26 | var __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 | });
|
31 | var __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 | };
|
38 | Object.defineProperty(exports, "__esModule", { value: true });
|
39 |
|
40 | var React = __importStar(require("react"));
|
41 | var react_1 = require("@emotion/react");
|
42 | var helpers_1 = require("./helpers");
|
43 | var moon = react_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 100% {transform: rotate(360deg)}\n"], ["\n 100% {transform: rotate(360deg)}\n"])));
|
44 | var Loader = (function (_super) {
|
45 | __extends(Loader, _super);
|
46 | function Loader() {
|
47 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
48 | _this.moonSize = function () {
|
49 | var size = _this.props.size;
|
50 | var value = helpers_1.parseLengthAndUnit(size).value;
|
51 | return value / 7;
|
52 | };
|
53 | _this.ballStyle = function (size) {
|
54 | return react_1.css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n border-radius: 100%;\n "], ["\n width: ", ";\n height: ", ";\n border-radius: 100%;\n "])), helpers_1.cssValue(size), helpers_1.cssValue(size));
|
55 | };
|
56 | _this.wrapper = function () {
|
57 | var _a = _this.props, size = _a.size, speedMultiplier = _a.speedMultiplier;
|
58 | var _b = helpers_1.parseLengthAndUnit(size), value = _b.value, unit = _b.unit;
|
59 | return react_1.css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n width: ", ";\n height: ", ";\n animation: ", " ", "s 0s infinite linear;\n animation-fill-mode: forwards;\n "], ["\n position: relative;\n width: ", ";\n height: ", ";\n animation: ", " ", "s 0s infinite linear;\n animation-fill-mode: forwards;\n "])), "" + (value + _this.moonSize() * 2) + unit, "" + (value + _this.moonSize() * 2) + unit, moon, 0.6 / speedMultiplier);
|
60 | };
|
61 | _this.ball = function () {
|
62 | var _a = _this.props, color = _a.color, size = _a.size, speedMultiplier = _a.speedMultiplier;
|
63 | var _b = helpers_1.parseLengthAndUnit(size), value = _b.value, unit = _b.unit;
|
64 | return react_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", ";\n background-color: ", ";\n opacity: 0.8;\n position: absolute;\n top: ", ";\n animation: ", " ", "s 0s infinite linear;\n animation-fill-mode: forwards;\n "], ["\n ", ";\n background-color: ", ";\n opacity: 0.8;\n position: absolute;\n top: ", ";\n animation: ", " ", "s 0s infinite linear;\n animation-fill-mode: forwards;\n "])), _this.ballStyle(_this.moonSize()), color, "" + (value / 2 - _this.moonSize() / 2) + unit, moon, 0.6 / speedMultiplier);
|
65 | };
|
66 | _this.circle = function () {
|
67 | var _a = _this.props, size = _a.size, color = _a.color;
|
68 | var value = helpers_1.parseLengthAndUnit(size).value;
|
69 | return react_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n border: ", "px solid ", ";\n opacity: 0.1;\n box-sizing: content-box;\n position: absolute;\n "], ["\n ", ";\n border: ", "px solid ", ";\n opacity: 0.1;\n box-sizing: content-box;\n position: absolute;\n "])), _this.ballStyle(value), _this.moonSize(), color);
|
70 | };
|
71 | return _this;
|
72 | }
|
73 | Loader.prototype.render = function () {
|
74 | var _a = this.props, loading = _a.loading, css = _a.css;
|
75 | return loading ? (react_1.jsx("span", { css: [this.wrapper(), css] },
|
76 | react_1.jsx("span", { css: this.ball() }),
|
77 | react_1.jsx("span", { css: this.circle() }))) : null;
|
78 | };
|
79 | Loader.defaultProps = helpers_1.sizeDefaults(60);
|
80 | return Loader;
|
81 | }(React.PureComponent));
|
82 | exports.default = Loader;
|
83 | var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|