wix-style-react
Version:
109 lines (92 loc) • 5.05 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 './SkeletonCircle.st.css';
import { DEFAULT_DIAMETER } from './constants';
import { DEFAULT_SKIN, SKIN_COLOR } from '../SkeletonGroup/constants';
import Box from '../Box';
import { SkeletonGroupContext } from '../SkeletonGroup';
/** SkeletonCircle */
var SkeletonCircle = /*#__PURE__*/function (_React$PureComponent) {
_inherits(SkeletonCircle, _React$PureComponent);
var _super = _createSuper(SkeletonCircle);
function SkeletonCircle() {
_classCallCheck(this, SkeletonCircle);
return _super.apply(this, arguments);
}
_createClass(SkeletonCircle, [{
key: "render",
value: function render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
className = _this$props.className,
diameter = _this$props.diameter,
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-diameter": diameter,
"data-skin": skin
}, /*#__PURE__*/React.createElement(Box, {
width: diameter,
height: diameter,
margin: margin,
marginLeft: marginLeft,
marginRight: marginRight,
marginTop: marginTop,
marginBottom: marginBottom,
backgroundColor: SKIN_COLOR[skin],
className: st(classes.root, {
skin: skin
})
}));
});
}
}]);
return SkeletonCircle;
}(React.PureComponent);
SkeletonCircle.displayName = 'SkeletonCircle';
SkeletonCircle.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 diameter of the box (pixels) */
diameter: 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])
};
SkeletonCircle.defaultProps = {
diameter: DEFAULT_DIAMETER
};
export default SkeletonCircle;