wix-style-react
Version:
113 lines (99 loc) • 4.54 kB
JavaScript
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 { st, classes } from './FeatureList.st.css';
import { dataHooks } from './constants';
import FluidColumns from '../common/FluidColumns';
import Text from '../Text';
/** FeatureList is a group of layouts that displays image, description and title. It's used in a footer of a marketing page to list product features. */
var FeatureList = /*#__PURE__*/function (_React$Component) {
_inherits(FeatureList, _React$Component);
var _super = _createSuper(FeatureList);
function FeatureList() {
_classCallCheck(this, FeatureList);
return _super.apply(this, arguments);
}
_createClass(FeatureList, [{
key: "render",
value: function render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
className = _this$props.className,
features = _this$props.features,
cols = _this$props.cols;
return /*#__PURE__*/React.createElement("div", {
className: st(classes.root, className),
"data-hook": dataHook
}, /*#__PURE__*/React.createElement(FluidColumns, {
cols: cols
}, features.map(function (feature, index) {
return /*#__PURE__*/React.createElement(FeatureItem, {
dataHook: dataHooks.feature,
key: index,
index: index,
image: feature.image,
title: feature.title,
text: feature.text
});
})));
}
}]);
return FeatureList;
}(React.Component);
var FeatureItem = function FeatureItem(_ref) {
var dataHook = _ref.dataHook,
index = _ref.index,
image = _ref.image,
title = _ref.title,
text = _ref.text;
return /*#__PURE__*/React.createElement("div", {
className: classes.featureItem,
"data-hook": dataHook
}, image && /*#__PURE__*/React.createElement("div", {
className: classes.featureItemImageContainer,
"data-hook": "".concat(dataHooks.featureImage).concat(index),
children: image
}), /*#__PURE__*/React.createElement("div", {
className: classes.featureItemTextContainer
}, title && /*#__PURE__*/React.createElement("div", {
className: classes.featureItemTitleContainer
}, /*#__PURE__*/React.createElement(Text, {
dataHook: "".concat(dataHooks.featureTitle).concat(index),
size: "medium",
weight: "bold"
}, title)), text && /*#__PURE__*/React.createElement(Text, {
dataHook: "".concat(dataHooks.featureText).concat(index),
size: "small"
}, text)));
};
FeatureList.displayName = 'FeatureList';
FeatureList.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 features. It accepts following properties:
* * `image` - use to pass a visual representation of a feature
* * `title` - use to specify feature title
* * `text` - use to specify a short feature description.q
*/
features: PropTypes.arrayOf(PropTypes.shape({
image: PropTypes.node,
title: PropTypes.string,
text: PropTypes.string
}))
};
FeatureList.defaultProps = {
cols: 3,
features: []
};
export default FeatureList;