UNPKG

wix-style-react

Version:
112 lines (98 loc) 4.64 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 PropTypes from 'prop-types'; import FluidColumns from '../common/FluidColumns'; import Text from '../Text'; import { st, classes } from './TestimonialList.st.css'; import { dataHooks } from './constants'; /** TestimonialList is a group of layouts that display avatar, description and name. It's used in a footer of a marketing page layout. */ var TestimonialList = /*#__PURE__*/function (_React$Component) { _inherits(TestimonialList, _React$Component); var _super = _createSuper(TestimonialList); function TestimonialList() { _classCallCheck(this, TestimonialList); return _super.apply(this, arguments); } _createClass(TestimonialList, [{ key: "render", value: function render() { var _this$props = this.props, className = _this$props.className, dataHook = _this$props.dataHook, testimonials = _this$props.testimonials, cols = _this$props.cols; return /*#__PURE__*/React.createElement("div", { className: st(classes.root, className), "data-hook": dataHook }, /*#__PURE__*/React.createElement(FluidColumns, { cols: cols }, testimonials.map(function (testimonial, index) { return /*#__PURE__*/React.createElement(TestimonialItem, { dataHook: dataHooks.testimonial, key: index, index: index, avatar: testimonial.avatar, text: testimonial.text, authorName: testimonial.authorName }); }))); } }]); return TestimonialList; }(React.Component); var TestimonialItem = function TestimonialItem(_ref) { var index = _ref.index, avatar = _ref.avatar, text = _ref.text, authorName = _ref.authorName, dataHook = _ref.dataHook; return /*#__PURE__*/React.createElement("div", { className: classes.testimonialItem, "data-hook": dataHook }, avatar && /*#__PURE__*/React.createElement("div", { className: classes.testimonialItemAvatar, "data-hook": "".concat(dataHooks.testimonialAvatar).concat(index) }, avatar), /*#__PURE__*/React.createElement("div", { className: classes.testimonialItemTextArea }, text && /*#__PURE__*/React.createElement("div", { className: classes.testimonialItemText }, /*#__PURE__*/React.createElement(Text, { dataHook: "".concat(dataHooks.testimonialText).concat(index), size: "small" }, text)), authorName && /*#__PURE__*/React.createElement(Text, { dataHook: "".concat(dataHooks.testimonialAuthorName).concat(index), size: "small", weight: "bold" }, authorName))); }; TestimonialList.displayName = 'TestimonialList'; TestimonialList.propTypes = { /** Applies a data-hook HTML attribute that can be used in the tests */ dataHook: PropTypes.string, /** Specifies a CSS class name to be appended to the component’s root element */ className: PropTypes.string, /** Defines the number of columns. It is used to define how many features will be displayed in a single row. */ cols: PropTypes.number, /** * Specifies an array of testimonials. It accepts following properties: * * `avatar` - use to pass an avatar image * * `text` - use for testimonial itself * * `authorName` - use to specify testimonial author. */ testimonials: PropTypes.arrayOf(PropTypes.shape({ avatar: PropTypes.node, text: PropTypes.string, authorName: PropTypes.string })) }; TestimonialList.defaultProps = { cols: 3, testimonials: [] }; export default TestimonialList;