wix-style-react
Version:
64 lines (53 loc) • 2.68 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 { classes } from './ProgressBar.st.css';
import Heading from '../../Heading';
var ProgressBar = /*#__PURE__*/function (_React$PureComponent) {
_inherits(ProgressBar, _React$PureComponent);
var _super = _createSuper(ProgressBar);
function ProgressBar() {
_classCallCheck(this, ProgressBar);
return _super.apply(this, arguments);
}
_createClass(ProgressBar, [{
key: "render",
value: function render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
progress = _this$props.progress;
return /*#__PURE__*/React.createElement("div", {
"data-hook": dataHook,
className: classes.root
}, /*#__PURE__*/React.createElement(Heading, {
appearance: "H6"
}, "".concat(progress, "%")), /*#__PURE__*/React.createElement("span", {
className: classes.bar
}, /*#__PURE__*/React.createElement("span", {
className: classes.value,
style: {
width: progress + '%'
}
}), /*#__PURE__*/React.createElement("span", {
className: classes.leftover,
style: {
width: 100 - progress + '%'
}
})));
}
}]);
return ProgressBar;
}(React.PureComponent);
ProgressBar.propTypes = {
/** Applied as data-hook HTML attribute that can be used in the tests */
dataHook: PropTypes.string,
/** Percentage of the progress, value should be between 0 to 100 */
progress: PropTypes.number.isRequired
};
export default ProgressBar;