wix-style-react
Version:
69 lines (54 loc) • 3.01 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React from 'react';
import PropTypes from 'prop-types';
import { st, classes } from './Content.st.css';
import { WixStyleReactContext } from '../../WixStyleReactProvider/context';
var Content = /*#__PURE__*/function (_React$Component) {
_inherits(Content, _React$Component);
var _super = _createSuper(Content);
function Content() {
var _this;
_classCallCheck(this, Content);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "_getChildName", function (children) {
return children.type && (children.type.displayName || children.type.name);
});
return _this;
}
_createClass(Content, [{
key: "render",
value: function render() {
var _this$props = this.props,
children = _this$props.children,
size = _this$props.size;
var isEmptyStateContent = this._getChildName(children) === 'EmptyState';
return /*#__PURE__*/React.createElement(WixStyleReactContext.Consumer, null, function (_ref) {
var reducedSpacingAndImprovedLayout = _ref.reducedSpacingAndImprovedLayout;
return /*#__PURE__*/React.createElement("div", {
className: st(classes.root, {
size: size,
emptyStateContent: isEmptyStateContent,
reducedSpacingAndImprovedLayout: reducedSpacingAndImprovedLayout
})
}, children);
});
}
}]);
return Content;
}(React.Component);
_defineProperty(Content, "propTypes", {
children: PropTypes.node,
size: PropTypes.oneOf(['medium', 'large'])
});
export default Content;