"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); /** @jsx jsx */ var React = __importStar(require("react")); var core_1 = require("@emotion/core"); var index_1 = require("./helpers/index"); var Loader = /** @class */ (function (_super) { __extends(Loader, _super); function Loader() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.thickness = function () { var size = _this.props.size; return size / 5; }; _this.lat = function () { var size = _this.props.size; return (size - _this.thickness()) / 2; }; _this.offset = function () { return _this.lat() - _this.thickness(); }; _this.color = function () { var color = _this.props.color; return index_1.calculateRgba(color, 0.75); }; _this.before = function () { var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit; var color = _this.color(); var lat = _this.lat(); var thickness = _this.thickness(); var offset = _this.offset(); return core_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, "" + size + sizeUnit, -offset, color, offset, color, thickness, -lat, -offset, color, lat, offset, color, lat, -offset, color, -lat, offset, color); }; _this.after = function () { var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit; var color = _this.color(); var lat = _this.lat(); var thickness = _this.thickness(); var offset = _this.offset(); return core_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, "" + size + sizeUnit, offset, color, -offset, color, thickness, offset, -lat, color, -offset, lat, color, offset, lat, color, -offset, -lat, color); }; _this.style = function (i) { var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit; return core_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: ", " 2s 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: ", " 2s infinite;\n "])), "" + size / 5 + sizeUnit, "" + size / 5 + sizeUnit, "" + size / 10 + sizeUnit, i === 1 ? _this.before() : _this.after()); }; _this.wrapper = function () { var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit; return core_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 "])), "" + size + sizeUnit, "" + size + sizeUnit); }; return _this; } Loader.prototype.render = function () { var _a = this.props, loading = _a.loading, css = _a.css; return loading ? (core_1.jsx("div", { css: [this.wrapper(), css] }, core_1.jsx("div", { css: this.style(1) }), core_1.jsx("div", { css: this.style(2) }))) : null; }; Loader.defaultProps = index_1.sizeDefaults(50); return Loader; }(React.PureComponent)); exports.default = Loader; var templateObject_1, templateObject_2, templateObject_3, templateObject_4;