1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | extendStatics(d, b);
|
11 | function __() { this.constructor = d; }
|
12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13 | };
|
14 | })();
|
15 | var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
16 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
17 | return cooked;
|
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 index_1 = require("./helpers/index");
|
43 | var Loader = (function (_super) {
|
44 | __extends(Loader, _super);
|
45 | function Loader() {
|
46 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
47 | _this.thickness = function () {
|
48 | var size = _this.props.size;
|
49 | var value = index_1.parseLengthAndUnit(size).value;
|
50 | return value / 5;
|
51 | };
|
52 | _this.lat = function () {
|
53 | var size = _this.props.size;
|
54 | var value = index_1.parseLengthAndUnit(size).value;
|
55 | return (value - _this.thickness()) / 2;
|
56 | };
|
57 | _this.offset = function () { return _this.lat() - _this.thickness(); };
|
58 | _this.color = function () {
|
59 | var color = _this.props.color;
|
60 | return index_1.calculateRgba(color, 0.75);
|
61 | };
|
62 | _this.before = function () {
|
63 | var size = _this.props.size;
|
64 | var color = _this.color();
|
65 | var lat = _this.lat();
|
66 | var thickness = _this.thickness();
|
67 | var offset = _this.offset();
|
68 | return react_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {width: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 35% {width: ", ";box-shadow: 0 ", "px ", ", 0 ", "px ", "}\n 70% {width: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 100% {box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n "], ["\n 0% {width: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 35% {width: ", ";box-shadow: 0 ", "px ", ", 0 ", "px ", "}\n 70% {width: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 100% {box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n "])), thickness, lat, -offset, color, -lat, offset, color, index_1.cssValue(size), -offset, color, offset, color, thickness, -lat, -offset, color, lat, offset, color, lat, -offset, color, -lat, offset, color);
|
69 | };
|
70 | _this.after = function () {
|
71 | var size = _this.props.size;
|
72 | var color = _this.color();
|
73 | var lat = _this.lat();
|
74 | var thickness = _this.thickness();
|
75 | var offset = _this.offset();
|
76 | return react_1.keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0% {height: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 35% {height: ", ";box-shadow: ", "px 0 ", ", ", "px 0 ", "}\n 70% {height: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 100% {box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n "], ["\n 0% {height: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 35% {height: ", ";box-shadow: ", "px 0 ", ", ", "px 0 ", "}\n 70% {height: ", "px;box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n 100% {box-shadow: ", "px ", "px ", ", ", "px ", "px ", "}\n "])), thickness, offset, lat, color, -offset, -lat, color, index_1.cssValue(size), offset, color, -offset, color, thickness, offset, -lat, color, -offset, lat, color, offset, lat, color, -offset, -lat, color);
|
77 | };
|
78 | _this.style = function (i) {
|
79 | var _a = _this.props, size = _a.size, speedMultiplier = _a.speedMultiplier;
|
80 | var _b = index_1.parseLengthAndUnit(size), value = _b.value, unit = _b.unit;
|
81 | return react_1.css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n content: \"\";\n top: 50%;\n left: 50%;\n display: block;\n width: ", ";\n height: ", ";\n border-radius: ", ";\n transform: translate(-50%, -50%);\n animation-fill-mode: none;\n animation: ", " ", "s infinite;\n "], ["\n position: absolute;\n content: \"\";\n top: 50%;\n left: 50%;\n display: block;\n width: ", ";\n height: ", ";\n border-radius: ", ";\n transform: translate(-50%, -50%);\n animation-fill-mode: none;\n animation: ", " ", "s infinite;\n "])), "" + value / 5 + unit, "" + value / 5 + unit, "" + value / 10 + unit, i === 1 ? _this.before() : _this.after(), 2 / speedMultiplier);
|
82 | };
|
83 | _this.wrapper = function () {
|
84 | var size = _this.props.size;
|
85 | return react_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n width: ", ";\n height: ", ";\n transform: rotate(165deg);\n "], ["\n position: relative;\n width: ", ";\n height: ", ";\n transform: rotate(165deg);\n "])), index_1.cssValue(size), index_1.cssValue(size));
|
86 | };
|
87 | return _this;
|
88 | }
|
89 | Loader.prototype.render = function () {
|
90 | var _a = this.props, loading = _a.loading, css = _a.css;
|
91 | return loading ? (react_1.jsx("span", { css: [this.wrapper(), css] },
|
92 | react_1.jsx("span", { css: this.style(1) }),
|
93 | react_1.jsx("span", { css: this.style(2) }))) : null;
|
94 | };
|
95 | Loader.defaultProps = index_1.sizeDefaults(50);
|
96 | return Loader;
|
97 | }(React.PureComponent));
|
98 | exports.default = Loader;
|
99 | var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|