UNPKG

wix-style-react

Version:
109 lines (92 loc) 5 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 { st, classes } from './SkeletonLine.st.css'; import { DEFAULT_WIDTH, HEIGHT } from './constants'; import { DEFAULT_SKIN, SKIN_COLOR } from '../SkeletonGroup/constants'; import Box from '../Box'; import { SkeletonGroupContext } from '../SkeletonGroup'; /** SkeletonLine */ var SkeletonLine = /*#__PURE__*/function (_React$PureComponent) { _inherits(SkeletonLine, _React$PureComponent); var _super = _createSuper(SkeletonLine); function SkeletonLine() { _classCallCheck(this, SkeletonLine); return _super.apply(this, arguments); } _createClass(SkeletonLine, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, className = _this$props.className, width = _this$props.width, margin = _this$props.margin, marginLeft = _this$props.marginLeft, marginRight = _this$props.marginRight, marginTop = _this$props.marginTop, marginBottom = _this$props.marginBottom; return /*#__PURE__*/React.createElement(SkeletonGroupContext.Consumer, null, function (context) { var skin = context && context.skin || DEFAULT_SKIN; return /*#__PURE__*/React.createElement("div", { "data-hook": dataHook, className: className, "data-width": width, "data-skin": skin }, /*#__PURE__*/React.createElement(Box, { height: HEIGHT, width: width, margin: margin, marginLeft: marginLeft, marginRight: marginRight, marginTop: marginTop, marginBottom: marginBottom, backgroundColor: SKIN_COLOR[skin], className: st(classes.root, { skin: skin }) })); }); } }]); return SkeletonLine; }(React.PureComponent); SkeletonLine.displayName = 'SkeletonLine'; SkeletonLine.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, /** Sets the width of the box (pixels) */ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets margin on all sides. * Accepts a numeric value (multiplied by spacing unit), predefined spacing value (tiny, small, etc.) * a spacing token (SP1, SP2, etc.) or a string of space-separated values ("3px 3px") */ margin: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets margin on the top. * Accepts a numeric value (multiplied by spacing unit), predefined spacing value (tiny, small, etc.) * a spacing token (SP1, SP2, etc.) or a string of space-separated values ("3px 3px") */ marginTop: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets margin on the right. * Accepts a numeric value (multiplied by spacing unit), predefined spacing value (tiny, small, etc.) * a spacing token (SP1, SP2, etc.) or a string of space-separated values ("3px 3px") */ marginRight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets margin on the bottom. * Accepts a numeric value (multiplied by spacing unit), predefined spacing value (tiny, small, etc.) * a spacing token (SP1, SP2, etc.) or a string of space-separated values ("3px 3px") */ marginBottom: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Sets margin on the left. * Accepts a numeric value (multiplied by spacing unit), predefined spacing value (tiny, small, etc.) * a spacing token (SP1, SP2, etc.) or a string of space-separated values ("3px 3px") */ marginLeft: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) }; SkeletonLine.defaultProps = { width: DEFAULT_WIDTH }; export default SkeletonLine;