Dashboard sipadu mbip
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

PacmanLoader.js 6.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 (b.hasOwnProperty(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 __importStar = (this && this.__importStar) || function (mod) {
  20. if (mod && mod.__esModule) return mod;
  21. var result = {};
  22. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  23. result["default"] = mod;
  24. return result;
  25. };
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. /** @jsx jsx */
  28. var React = __importStar(require("react"));
  29. var core_1 = require("@emotion/core");
  30. var helpers_1 = require("./helpers");
  31. var pacman = [
  32. core_1.keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(-44deg)}\n "], ["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(-44deg)}\n "]))),
  33. core_1.keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(44deg)}\n "], ["\n 0% {transform: rotate(0deg)}\n 50% {transform: rotate(44deg)}\n "])))
  34. ];
  35. var Loader = /** @class */ (function (_super) {
  36. __extends(Loader, _super);
  37. function Loader() {
  38. var _this = _super !== null && _super.apply(this, arguments) || this;
  39. _this.ball = function () {
  40. var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit;
  41. return core_1.keyframes(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n 75% {opacity: 0.7}\n 100% {transform: translate(", ", ", ")}\n "], ["\n 75% {opacity: 0.7}\n 100% {transform: translate(", ", ", ")}\n "])), "" + -4 * size + sizeUnit, "" + -size / 4 + sizeUnit);
  42. };
  43. _this.ballStyle = function (i) {
  44. var _a = _this.props, color = _a.color, margin = _a.margin, size = _a.size, sizeUnit = _a.sizeUnit;
  45. return core_1.css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n background-color: ", ";\n margin: ", ";\n border-radius: 100%;\n transform: translate(0, ", ");\n position: absolute;\n top: ", ";\n left: ", ";\n animation: ", " 1s ", "s infinite linear;\n animation-fill-mode: both;\n "], ["\n width: ", ";\n height: ", ";\n background-color: ", ";\n margin: ", ";\n border-radius: 100%;\n transform: translate(0, ", ");\n position: absolute;\n top: ", ";\n left: ", ";\n animation: ", " 1s ", "s infinite linear;\n animation-fill-mode: both;\n "])), "" + size / 3 + sizeUnit, "" + size / 3 + sizeUnit, color, margin, "" + -size / 4 + sizeUnit, "" + size + sizeUnit, "" + size * 4 + sizeUnit, _this.ball(), i * 0.25);
  46. };
  47. _this.s1 = function () {
  48. var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit;
  49. return "" + size + sizeUnit + " solid transparent";
  50. };
  51. _this.s2 = function () {
  52. var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit, color = _a.color;
  53. return "" + size + sizeUnit + " solid " + color;
  54. };
  55. _this.pacmanStyle = function (i) {
  56. var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit;
  57. var s1 = _this.s1();
  58. var s2 = _this.s2();
  59. return core_1.css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: 0;\n height: 0;\n border-right: ", ";\n border-top: ", ";\n border-left: ", ";\n border-bottom: ", ";\n border-radius: ", ";\n position: absolute;\n animation: ", " 0.8s infinite ease-in-out;\n animation-fill-mode: both;\n "], ["\n width: 0;\n height: 0;\n border-right: ", ";\n border-top: ", ";\n border-left: ", ";\n border-bottom: ", ";\n border-radius: ", ";\n position: absolute;\n animation: ", " 0.8s infinite ease-in-out;\n animation-fill-mode: both;\n "])), s1, i === 0 ? s1 : s2, s2, i === 0 ? s2 : s1, "" + size + sizeUnit, pacman[i]);
  60. };
  61. _this.wrapper = function () {
  62. var _a = _this.props, size = _a.size, sizeUnit = _a.sizeUnit;
  63. return core_1.css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: relative;\n font-size: 0;\n height: ", ";\n width: ", ";\n "], ["\n position: relative;\n font-size: 0;\n height: ", ";\n width: ", ";\n "])), "" + size + sizeUnit, "" + size + sizeUnit);
  64. };
  65. _this.pac = function () { return _this.pacmanStyle(0); };
  66. _this.man = function () { return _this.pacmanStyle(1); };
  67. return _this;
  68. }
  69. Loader.prototype.render = function () {
  70. var _a = this.props, loading = _a.loading, css = _a.css;
  71. return loading ? (core_1.jsx("div", { css: [this.wrapper(), css] },
  72. core_1.jsx("div", { css: this.pac() }),
  73. core_1.jsx("div", { css: this.man() }),
  74. core_1.jsx("div", { css: this.ballStyle(2) }),
  75. core_1.jsx("div", { css: this.ballStyle(3) }),
  76. core_1.jsx("div", { css: this.ballStyle(4) }),
  77. core_1.jsx("div", { css: this.ballStyle(5) }))) : null;
  78. };
  79. Loader.defaultProps = helpers_1.sizeMarginDefaults(25);
  80. return Loader;
  81. }(React.PureComponent));
  82. exports.default = Loader;
  83. var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;