import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import React from 'react';

var SettingsBar =
/*#__PURE__*/
function (_React$PureComponent) {
  _inherits(SettingsBar, _React$PureComponent);

  function SettingsBar() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, SettingsBar);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(SettingsBar)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.setHighContrast = function () {
      document.getElementsByTagName('html')[0].classList.add('high-contrast');
      localStorage.setItem('highContrast', 'on');
    };

    _this.clearHighContrast = function () {
      document.getElementsByTagName('html')[0].classList.remove('high-contrast');
      localStorage.removeItem('highContrast');
    };

    _this.updateFont = function (_ref) {
      var amount = _ref.amount;
      var current = document.body.style.zoom || 1;
      document.body.style.zoom = Number(current) + amount;
      localStorage.setItem('zoom', document.body.style.zoom);
    };

    _this.increaseFont = function () {
      _this.updateFont({
        amount: 0.1
      });
    };

    _this.descreaseFont = function () {
      _this.updateFont({
        amount: -0.1
      });
    };

    _this.resetFont = function () {
      document.body.style.zoom = 1;
      localStorage.setItem('zoom', 1);
    };

    return _this;
  }

  _createClass(SettingsBar, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          isSettingsOpen = _this$props.isSettingsOpen,
          toggleSettingsOpen = _this$props.toggleSettingsOpen;
      var openClass = isSettingsOpen ? 'in' : '';
      return React.createElement("div", {
        className: "site-settings section section-standout collapse collapsed ".concat(openClass),
        role: "alert",
        id: "siteSettings"
      }, React.createElement("div", {
        className: "container  p-y"
      }, React.createElement("button", {
        onClick: toggleSettingsOpen,
        type: "button",
        className: "close",
        "aria-expanded": "false",
        "aria-controls": "siteSettings",
        "aria-label": "Close"
      }, React.createElement("span", {
        "aria-hidden": "true"
      }, "\xD7")), React.createElement("div", {
        className: "btn-group btn-group-justified-sm",
        role: "group",
        "aria-label": "contrastMode"
      }, React.createElement("div", {
        className: "btn-group"
      }, React.createElement("button", {
        onClick: this.clearHighContrast,
        type: "button",
        className: "btn btn-standout disableHighContrastMode"
      }, "Default")), React.createElement("div", {
        className: "btn-group"
      }, React.createElement("button", {
        onClick: this.setHighContrast,
        type: "button",
        className: "btn btn-standout enableHighContrastMode"
      }, "High Contrast"))), React.createElement("div", {
        className: "btn-group",
        role: "group",
        "aria-label": "textSizeMode"
      }, React.createElement("div", {
        className: "btn-group"
      }, React.createElement("button", {
        onClick: this.resetFont,
        type: "button",
        className: "btn btn-standout resetTextSize"
      }, "Reset")), React.createElement("div", {
        className: "btn-group"
      }, React.createElement("button", {
        onClick: this.increaseFont,
        type: "button",
        className: "btn btn-standout increaseTextSize"
      }, React.createElement("span", {
        className: "hidden-xs"
      }, "Increase Font Size"), React.createElement("span", {
        className: "visible-xs"
      }, "Font", React.createElement("small", {
        className: "ca-gov-icon-plus-line"
      })))), React.createElement("div", {
        className: "btn-group"
      }, React.createElement("button", {
        onClick: this.descreaseFont,
        type: "button",
        className: "btn btn-standout decreaseTextSize"
      }, React.createElement("span", {
        className: "hidden-xs"
      }, "Decrease Font Size"), React.createElement("span", {
        className: "visible-xs"
      }, "Font", React.createElement("small", {
        className: "ca-gov-icon-minus-line"
      })))))));
    }
  }]);

  return SettingsBar;
}(React.PureComponent);

export default SettingsBar;