@bigfishtv/cockpit
Version:
73 lines (61 loc) • 3.17 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _class, _temp;
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 PropTypes from 'prop-types';
import React, { Component } from 'react';
import classnames from 'classnames';
import Icon from '../Icon';
/**
* Alert component, used by NotificationsHost
*/
var Alert = (_temp = _class = function (_Component) {
_inherits(Alert, _Component);
function Alert() {
_classCallCheck(this, Alert);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
Alert.prototype.render = function render() {
var _props = this.props,
status = _props.status,
message = _props.message,
index = _props.index,
autoDismiss = _props.autoDismiss,
dismissed = _props.dismissed,
props = _objectWithoutProperties(_props, ['status', 'message', 'index', 'autoDismiss', 'dismissed']);
return React.createElement(
'div',
_extends({ className: classnames('alert', status) }, props, { style: { top: index == null ? -100 : index * 60 + 20 } }),
React.createElement(
'div',
{ className: 'alert-icon' },
React.createElement(Icon, { name: status })
),
React.createElement(
'div',
{ className: 'alert-content' },
React.createElement(
'div',
{ className: 'alert-message' },
message
)
),
React.createElement(
'button',
{ className: 'alert-dismiss' },
React.createElement(Icon, { name: 'close', size: '18' })
)
);
};
return Alert;
}(Component), _class.propTypes = {
/** Alert message, can be text or react component */
message: PropTypes.node,
/** Alert status, used to color accordingly */
status: PropTypes.oneOf(['success', 'error', 'warning', 'info']),
/** Alert index, used to vertically position */
index: PropTypes.number // null if it should be hidden offscreen
}, _temp);
export { Alert as default };