d2-ui
Version:
95 lines (81 loc) • 4.09 kB
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { CircularProgress } from 'material-ui';
import FontIcon from 'material-ui/FontIcon';
import { ERROR, LOADING, SUCCESS } from '../FeedbackSnackbarTypes';
var styles = {
content: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
fontSize: '15px'
},
icon: {
color: '#ffffff',
marginLeft: '15px'
}
};
var FeedbackSnackbarBody = function (_PureComponent) {
_inherits(FeedbackSnackbarBody, _PureComponent);
function FeedbackSnackbarBody() {
_classCallCheck(this, FeedbackSnackbarBody);
return _possibleConstructorReturn(this, (FeedbackSnackbarBody.__proto__ || Object.getPrototypeOf(FeedbackSnackbarBody)).apply(this, arguments));
}
_createClass(FeedbackSnackbarBody, [{
key: 'render',
value: function render() {
var icon = void 0;
switch (this.props.type) {
case SUCCESS:
icon = React.createElement(
FontIcon,
{ className: 'material-icons', style: styles.icon },
'done'
);
break;
case LOADING:
icon = React.createElement(CircularProgress, { style: styles.icon, color: '#ffffff', size: 28, thickness: 2 });
break;
case ERROR:
icon = React.createElement(
FontIcon,
{ className: 'material-icons', style: styles.icon },
'error'
);
break;
default:
icon = React.createElement(
FontIcon,
{ className: 'material-icons', style: styles.icon },
'warning'
);
break;
}
var snackBarContent = React.createElement(
'div',
{ style: styles.content },
React.createElement(
'div',
null,
this.props.message
),
icon
);
return snackBarContent;
}
}]);
return FeedbackSnackbarBody;
}(PureComponent);
FeedbackSnackbarBody.propTypes = {
type: PropTypes.string,
message: PropTypes.string
};
FeedbackSnackbarBody.defaultProps = {
type: '',
message: ''
};
export default FeedbackSnackbarBody;