'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Dot = exports.Container = undefined;

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; }; }();

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 }; }

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; }

var Container = exports.Container = _styledComponents2.default.div.withConfig({ displayName: 'LoaderContainer' }).withConfig({
  displayName: 'Loader__Container'
})(['display: flex;flex-direction: row;margin: auto;']);

var grow = (0, _styledComponents.keyframes)(['0% {transform: scale(0);}50% {opacity: 1;transform: scale(1);}100% {opacity: 0;}']);

var Dot = exports.Dot = _styledComponents2.default.div.withConfig({ displayName: 'LoaderDot' }).withConfig({
  displayName: 'Loader__Dot'
})(['height: ', ';width: ', ';border-thickness: 2px;border-style: solid;border-color: ', ';border-radius: 50%;margin: 0 5px;transform: scale(0);animation: ', ' 1000ms ease infinite 0ms;&:nth-child(2) {animation-delay: 300ms;}&:nth-child(3) {animation-delay: 600ms;}&:first-child {margin-left: 0;}&:last-child {margin-right: 0;}'], function (_ref) {
  var size = _ref.size;
  return size;
}, function (_ref2) {
  var size = _ref2.size;
  return size;
}, function (_ref3) {
  var theme = _ref3.theme,
      color = _ref3.color;
  return color ? color : theme.colors.primary;
}, grow);

Dot.defaultProps = {
  size: '20px',
  color: null
};

var Loader = function (_React$Component) {
  _inherits(Loader, _React$Component);

  function Loader() {
    _classCallCheck(this, Loader);

    return _possibleConstructorReturn(this, (Loader.__proto__ || Object.getPrototypeOf(Loader)).apply(this, arguments));
  }

  _createClass(Loader, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          size = _props.size,
          color = _props.color;


      return _react2.default.createElement(
        Container,
        null,
        _react2.default.createElement(Dot, { size: size, color: color }),
        _react2.default.createElement(Dot, { size: size, color: color }),
        _react2.default.createElement(Dot, { size: size, color: color })
      );
    }
  }]);

  return Loader;
}(_react2.default.Component);

Loader.propTypes = {
  size: _propTypes2.default.string,
  color: _propTypes2.default.string
};
Loader.defaultProps = {
  size: '20px',
  color: null
};


Loader.usage = '\n# Loader\n\nDrop a loader anywhere you want to display a loading animation. It should self-center in a flexbox.\n\nUse the `size` prop to pass a custom dot size, `color` to override the color.\n\n```\n<Loader size="20px" />\n```\n';

exports.default = Loader;