'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var React = require('react');
var React__default = _interopDefault(React);
var PropTypes = _interopDefault(require('prop-types'));
var __chunk_1 = require('../chunk-f817ce38.js');
var index$7 = require('../Icons/Info/index.js');
var index$3 = require('../Icons/Exit/index.js');
var index$1$1 = require('../Text/index.js');
require('../chunk-2b268ae7.js');
require('../chunk-6d243953.js');
require('../Icons/Icon/index.js');

var styles = (function (theme) {
  return {
    root: {
      display: 'flex',
      padding: '8px 16px',
      position: 'sticky',
      borderTop: 'solid 1px #d3d3db',
      justifyContent: 'space-between',
      bottom: 0,
      borderRadius: 4,
      boxShadow: '0 2px 8px 0 rgba(36, 47, 51, 0.1)',
      border: 'solid 1px ' + theme.palette.grey80,
      backgroundColor: theme.palette.white
    },
    type: {
      borderLeft: function borderLeft(_ref) {
        var type = _ref.type;

        if (type === 'info') return 'solid 4px ' + theme.palette.blue;
        if (type === 'correct') return 'solid 4px ' + theme.palette.green;
        if (type === 'warning') return 'solid 4px ' + theme.palette.lightRed;
      }
    },
    infoIcon: {
      marginRight: 10
    },
    content: {
      display: 'flex',
      justifyContent: 'flex-start'
    },
    exit: {
      outline: 'none'
    }
  };
});

var colors = {
  warning: 'lightRed',
  info: 'blue',
  correct: 'green'
};

var Toast = function Toast(_ref) {
  var label = _ref.label,
      type = _ref.type,
      classes = _ref.classes,
      onClose = _ref.onClose;
  return React__default.createElement(
    'div',
    { className: __chunk_1.classNames(classes.root, type && classes.type) },
    React__default.createElement(
      'div',
      { className: classes.content },
      React__default.createElement(
        'div',
        null,
        React__default.createElement(index$7, { color: colors[type], className: classes.infoIcon, display: 'block' })
      ),
      React__default.createElement(
        index$1$1,
        { size: 'md' },
        label
      )
    ),
    React__default.createElement(
      'div',
      {
        className: classes.exit,
        role: 'button',
        tabIndex: 0,
        onClick: onClose || null,
        onKeyDown: function onKeyDown(e) {
          if (e.keyCode === 'ESC' && onClose) onClose();
        }
      },
      React__default.createElement(index$3, { className: classes.exitIcon, color: 'grey90', hoverColor: 'black' })
    )
  );
};

Toast.defaultProps = {
  type: 'warning'
};

Toast.propTypes = {
  label: PropTypes.string,
  type: PropTypes.oneOf(['info', 'correct', 'warning']),
  classes: PropTypes.object,
  onClose: PropTypes.func
};

var Toast$1 = __chunk_1.withNano(styles)(Toast);

module.exports = Toast$1;
//# sourceMappingURL=index.js.map
