UNPKG

wix-style-react

Version:
89 lines (73 loc) 3.61 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; 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 Text from '../../Text'; import Box from '../../Box'; import { st, classes } from './Subheader.st.css'; import { isString } from '../../utils/StringUtils'; import { WixStyleReactContext } from '../../WixStyleReactProvider/context'; var Subheader = /*#__PURE__*/function (_React$PureComponent) { _inherits(Subheader, _React$PureComponent); var _super = _createSuper(Subheader); function Subheader() { _classCallCheck(this, Subheader); return _super.apply(this, arguments); } _createClass(Subheader, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, title = _this$props.title, suffix = _this$props.suffix, skin = _this$props.skin; return /*#__PURE__*/React.createElement(WixStyleReactContext.Consumer, null, function (_ref) { var reducedSpacingAndImprovedLayout = _ref.reducedSpacingAndImprovedLayout; return /*#__PURE__*/React.createElement("div", { "data-hook": dataHook, className: st(classes.root, { skin: skin, reducedSpacingAndImprovedLayout: reducedSpacingAndImprovedLayout }) }, /*#__PURE__*/React.createElement(Box, { verticalAlign: "middle", flexGrow: 1, overflow: "hidden" }, isString(title) ? /*#__PURE__*/React.createElement(Text, { ellipsis: true, weight: "normal", size: "medium", dataHook: "title" }, title) : /*#__PURE__*/React.createElement("div", { "data-hook": "title-node" }, title)), suffix && /*#__PURE__*/React.createElement("div", { className: classes.suffix, "data-hook": "suffix-node" }, suffix)); }); } }]); return Subheader; }(React.PureComponent); _defineProperty(Subheader, "displayName", 'Card.Subheader'); _defineProperty(Subheader, "defaultProps", { skin: 'standard' }); _defineProperty(Subheader, "propTypes", { /** Applied as data-hook HTML attribute that can be used in the tests */ dataHook: PropTypes.string, /** card title */ title: PropTypes.node.isRequired, /** suffix node that will be rendered on the right side */ suffix: PropTypes.node, /** skin */ skin: PropTypes.oneOf(['standard', 'neutral']) }); export default Subheader;