UNPKG

wix-style-react

Version:
67 lines (54 loc) 3.07 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 { st, classes } from './SidebarSectionTitle.st.css'; import Text from '../Text'; import { SidebarContext } from '../Sidebar/SidebarAPI'; import { sidebarSkins } from '../Sidebar/constants'; import { WixStyleReactContext } from '../WixStyleReactProvider/context'; /** A title for the section within the sidebar */ var SidebarSectionTitle = /*#__PURE__*/function (_React$PureComponent) { _inherits(SidebarSectionTitle, _React$PureComponent); var _super = _createSuper(SidebarSectionTitle); function SidebarSectionTitle() { _classCallCheck(this, SidebarSectionTitle); return _super.apply(this, arguments); } _createClass(SidebarSectionTitle, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, children = _this$props.children; return /*#__PURE__*/React.createElement(WixStyleReactContext.Consumer, null, function () { return /*#__PURE__*/React.createElement(SidebarContext.Consumer, null, function (context) { var skin = context && context.getSkin() || sidebarSkins.dark; return /*#__PURE__*/React.createElement(Text, { dataHook: dataHook, className: st(classes.root, { skin: skin }), size: "tiny", weight: "bold" }, children); }); }); } }]); return SidebarSectionTitle; }(React.PureComponent); _defineProperty(SidebarSectionTitle, "displayName", 'SidebarSectionTitle'); _defineProperty(SidebarSectionTitle, "propTypes", { /** Applied as data-hook HTML attribute that can be used in the tests */ dataHook: PropTypes.string, /** Usually plain text, but could be any renderable node */ children: PropTypes.node.isRequired }); export default SidebarSectionTitle;