"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));

var _styles = require("@material-ui/core/styles");

var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));

var _classnames = _interopRequireDefault(require("classnames"));

var _renderUi = require("../../render-ui");

var Toggle = (0, _styles.withStyles)(function (theme) {
  return {
    toggle: {
      display: 'flex',
      width: '100%',
      justifyContent: 'space-between'
    },
    label: {
      color: 'rgba(0, 0, 0, 0.89)',
      fontSize: theme.typography.fontSize,
      paddingTop: theme.spacing.unit * 2
    },
    checkedThumb: {
      color: "".concat(_renderUi.color.tertiary(), " !important")
    },
    checkedBar: {
      backgroundColor: "".concat(_renderUi.color.tertiaryLight(), " !important")
    }
  };
})(function (_ref) {
  var checked = _ref.checked,
      label = _ref.label,
      toggle = _ref.toggle,
      classes = _ref.classes;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.toggle
  }, /*#__PURE__*/_react["default"].createElement(_InputLabel["default"], {
    className: classes.label
  }, label), /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
    classes: {
      checked: (0, _classnames["default"])(classes.checkedThumb),
      bar: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.checkedBar, checked))
    },
    checked: checked,
    onChange: function onChange(e) {
      return toggle(e.target.checked);
    }
  }));
});
Toggle.propTypes = {
  checked: _propTypes["default"].bool,
  label: _propTypes["default"].string.isRequired,
  toggle: _propTypes["default"].func.isRequired
};
var _default = Toggle;
exports["default"] = _default;
//# sourceMappingURL=toggle.js.map