'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Container = _styledComponents2.default.div.withConfig({
  displayName: 'ConfirmationGauge__Container'
})(['display:flex;flex-direction:row;justify-content:flex-start;align-items:center;width:100%;max-width:300px;']);
var Bar = _styledComponents2.default.div.withConfig({
  displayName: 'ConfirmationGauge__Bar'
})(['display:flex;flex-grow:1;height:15px;border:1px solid ', ';box-sizing:border-box;background-color:', ';'], function (props) {
  return props.theme['black'];
}, function (props) {
  return props.theme[props.color];
});

var selectColor = function selectColor(nbConfirmations) {
  switch (nbConfirmations) {
    case 1:
      return 'brand-yellow-lighter';
    case 2:
      return 'brand-yellow';
    case 3:
      return 'success';
    default:
      return 'white';
  }
};

var ConfirmationGauge = function ConfirmationGauge(props) {
  var nbConfirmations = props.nbConfirmations;

  var color = selectColor(nbConfirmations);

  return _react2.default.createElement(
    Container,
    null,
    nbConfirmations > 0 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'white' }),
    nbConfirmations > 1 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'white' }),
    nbConfirmations > 2 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'white' })
  );
};

ConfirmationGauge.defaultProps = {
  nbConfirmations: 0
};

ConfirmationGauge.propTypes = {
  nbConfirmations: _propTypes2.default.number.isRequired
};

exports.default = ConfirmationGauge;