"use strict";

exports.__esModule = true;
exports.default = void 0;
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _proptypes = require("../../../util/proptypes");
var _provider = _interopRequireDefault(require("../../../atom/provider"));
var _button = _interopRequireDefault(require("../../../atom/button"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ForumComment = (props, context) => {
  const {
    translate,
    skin
  } = context;
  const {
    avatar,
    onPost,
    onChange,
    value,
    textareaDisabled,
    postDisabled,
    newPost = false,
    profileAvatarAlt
  } = props;
  const primary = (0, _get2.default)('common.primary', skin);
  const light = (0, _get2.default)('common.light', skin);
  const avatarView = avatar ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.image
  }, /*#__PURE__*/_react.default.createElement("img", {
    src: avatar,
    alt: profileAvatarAlt
  })) : null;
  const button = /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.post
  }, /*#__PURE__*/_react.default.createElement(_button.default, {
    type: "link",
    onClick: !postDisabled ? onPost : _noop2.default,
    disabled: postDisabled,
    submitValue: translate('Post'),
    "aria-label": translate('post_comment_aria_label'),
    style: {
      backgroundColor: postDisabled ? light : primary
    },
    className: postDisabled ? _style.default.disabledButton : _style.default.button
  }));
  return /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "forumComment",
    className: (0, _classnames.default)(_style.default.container, newPost ? _style.default.newPost : null)
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(_style.default.wrapper, newPost ? _style.default.newPost : null)
  }, avatarView, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.comment
  }, /*#__PURE__*/_react.default.createElement("textarea", {
    placeholder: translate('comment_aria_label'),
    title: translate('comment_aria_label'),
    "aria-label": translate('comment_aria_label'),
    value: value,
    onChange: onChange,
    disabled: textareaDisabled
  }))), button);
};
ForumComment.contextTypes = {
  translate: _provider.default.childContextTypes.translate,
  skin: _provider.default.childContextTypes.skin
};
ForumComment.propTypes = process.env.NODE_ENV !== "production" ? {
  value: _propTypes.default.string,
  profileAvatarAlt: _propTypes.default.string,
  avatar: _proptypes.SrcPropType,
  onChange: _propTypes.default.func,
  onPost: _propTypes.default.func,
  newPost: _propTypes.default.bool,
  textareaDisabled: _propTypes.default.bool,
  postDisabled: _propTypes.default.bool
} : {};
var _default = exports.default = ForumComment;
//# sourceMappingURL=index.js.map