UNPKG

wix-style-react

Version:
71 lines (58 loc) 3.02 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; 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 { dataHooks } from './constants'; import { st, classes, vars } from './FluidColumns.st.css'; /** A fluid columns component*/ var FluidColumns = /*#__PURE__*/function (_React$PureComponent) { _inherits(FluidColumns, _React$PureComponent); var _super = _createSuper(FluidColumns); function FluidColumns() { _classCallCheck(this, FluidColumns); return _super.apply(this, arguments); } _createClass(FluidColumns, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, className = _this$props.className, cols = _this$props.cols, children = _this$props.children; return /*#__PURE__*/React.createElement("div", { className: st(classes.root, className), "data-hook": dataHook, style: _defineProperty({}, vars.cols, cols) }, React.Children.map(children, function (child, index) { return /*#__PURE__*/React.createElement("div", { key: index, "data-hook": dataHooks.item, className: classes.item }, child); })); } }]); return FluidColumns; }(React.PureComponent); FluidColumns.displayName = 'FluidColumns'; FluidColumns.propTypes = { /** Applied as data-hook HTML attribute that can be used in the tests */ dataHook: PropTypes.string, /** A css class to be applied to the component's root element */ className: PropTypes.string, /** Define the number of columns. It is used for the grid in order to define how many features will be displayed in a row. The default value is 3. */ cols: PropTypes.number, /** Children to render. */ children: PropTypes.node.isRequired }; FluidColumns.defaultProps = { cols: 3 }; export default FluidColumns;