UNPKG

@makeen.io/material-ui-kit

Version:
24 lines (18 loc) 1.84 kB
import _extends from "@babel/runtime/helpers/extends";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";function _templateObject() {var data = _taggedTemplateLiteral(["\n & .MuiCircularProgress-colorPrimary {\n color: ", ";\n }\n\n & .MuiCircularProgress-colorSecondary {\n color: ", ";\n }\n"]);_templateObject = function _templateObject() {return data;};return data;}import React, { useEffect, useState } from "react"; import CircularProgress from "@material-ui/core/CircularProgress"; import styled from "styled-components"; export default styled(function (_ref) {var show = _ref.show,_ref$variant = _ref.variant,defaultVariant = _ref$variant === void 0 ? "determinate" : _ref$variant,value = _ref.value,className = _ref.className,rest = _objectWithoutProperties(_ref, ["show", "variant", "value", "className"]);var _useState = useState(value || 0),_useState2 = _slicedToArray(_useState, 2),progress = _useState2[0],setProgress = _useState2[1]; useEffect(function () { var tick = function tick() { // reset when reaching 100% setProgress(function (oldProgress) {return oldProgress >= 100 ? 0 : oldProgress + 1;}); }; var timer = setInterval(tick, 20); return function () {return clearInterval(timer);}; }, []); return /*#__PURE__*/React.createElement("div", { className: className }, show ? /*#__PURE__*/React.createElement(CircularProgress, _extends({ variant: defaultVariant, value: progress }, rest)) : null); })(_templateObject(), function (props) {return props.theme.palette.labelColorPrimary;}, function (props) {return props.theme.palette.labelColorSecondary;}); //# sourceMappingURL=Loader.js.map