UNPKG

feeles-ide

Version:

The hackable and serializable IDE to make learning material

74 lines (61 loc) 2.4 kB
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _createClass from 'babel-runtime/helpers/createClass'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import CircularProgress from 'material-ui/CircularProgress'; // Timeout [ms] 間 resolve がなければ、次の resolve まで hide var Timeout = 1000; var ResolveProgress = function (_PureComponent) { _inherits(ResolveProgress, _PureComponent); function ResolveProgress() { var _ref; var _temp, _this, _ret; _classCallCheck(this, ResolveProgress); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ResolveProgress.__proto__ || _Object$getPrototypeOf(ResolveProgress)).call.apply(_ref, [this].concat(args))), _this), _this.state = { visible: false }, _this._timer = null, _this.handleResolve = function () { if (!_this.state.visible) { _this.setState({ visible: true }); } clearInterval(_this._timer); _this._timer = setTimeout(function () { _this.setState({ visible: false }); }, Timeout); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(ResolveProgress, [{ key: 'componentWillMount', value: function componentWillMount() { var globalEvent = this.props.globalEvent; globalEvent.on('message.resolve', this.handleResolve); } }, { key: 'render', value: function render() { if (!this.state.visible) { return null; } var palette = this.context.muiTheme.palette; return React.createElement(CircularProgress, { size: this.props.size, thickness: Math.max(1, this.props.size / 8), color: palette.primary1Color }); } }]); return ResolveProgress; }(PureComponent); ResolveProgress.propTypes = { size: PropTypes.number.isRequired, globalEvent: PropTypes.object.isRequired }; ResolveProgress.contextTypes = { muiTheme: PropTypes.object.isRequired }; export default ResolveProgress;