import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import Loader from 'react-loader'; export default @observer class Infobox extends Component { static propTypes = { children: PropTypes.any.isRequired, // eslint-disable-line icon: PropTypes.string, type: PropTypes.string, ctaOnClick: PropTypes.func, ctaLabel: PropTypes.string, ctaLoading: PropTypes.bool, dismissable: PropTypes.bool, onDismiss: PropTypes.func, onSeen: PropTypes.func, }; static defaultProps = { icon: '', type: 'primary', dismissable: false, ctaOnClick: () => null, ctaLabel: '', ctaLoading: false, onDismiss: () => null, onSeen: () => null, }; state = { dismissed: false, }; componentDidMount() { const { onSeen } = this.props; if (onSeen) onSeen(); } render() { const { children, icon, type, ctaLabel, ctaLoading, ctaOnClick, dismissable, onDismiss, } = this.props; if (this.state.dismissed) { return null; } return (
{icon && ( )}
{children}
{ctaLabel && ( )} {dismissable && (
); } }