UNPKG

wix-style-react

Version:
73 lines (59 loc) 2.99 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"; 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 { st, classes } from './FontUpgrade.st.css'; import PropTypes from 'prop-types'; import { FontUpgradeContext } from './context'; import { WixStyleReactEnvironmentContext } from '../WixStyleReactEnvironmentProvider/context'; var FontUpgrade = /*#__PURE__*/function (_React$PureComponent) { _inherits(FontUpgrade, _React$PureComponent); var _super = _createSuper(FontUpgrade); function FontUpgrade() { _classCallCheck(this, FontUpgrade); return _super.apply(this, arguments); } _createClass(FontUpgrade, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, className = _this$props.className, active = _this$props.active, as = _this$props.as, children = _this$props.children; return /*#__PURE__*/React.createElement(FontUpgradeContext.Provider, { value: { active: active } }, /*#__PURE__*/React.createElement(as, { 'data-hook': dataHook, 'data-active': active, className: st(active ? classes.root : null, className) }, children)); } }]); return FontUpgrade; }(React.PureComponent); FontUpgrade.contextType = WixStyleReactEnvironmentContext; FontUpgrade.defaultProps = { active: true, as: 'span' }; FontUpgrade.propTypes = { /** Applied as data-hook HTML attribute that can be used to create driver in testing */ dataHook: PropTypes.string, /** A css class to be applied to the component's root element */ className: PropTypes.string, /** Sets the Madefor font upgrade active when true (which is by default) */ active: PropTypes.bool, /** render as some other component or DOM tag */ as: PropTypes.oneOf(['span', 'div']), /** A renderable node */ children: PropTypes.node }; export default FontUpgrade;