@itwin/core-react
Version:
A react component library of iTwin.js UI general purpose components
36 lines • 1.62 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Loading
*/
import "./LoadingBar.scss";
import classnames from "classnames";
import * as React from "react";
/** A loading bar with optional percentage text.
* @public
* @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/progressindicator#progress-linear iTwinUI progress indicator} instead.
*/
export class LoadingBar extends React.PureComponent {
render() {
const percent = `${percentInRange(this.props.percent)}%`;
const containerClass = classnames(this.props.className, "core-lb");
return (React.createElement("div", { className: containerClass, style: this.props.style },
React.createElement("div", { className: "lb-container", style: { height: this.props.barHeight } },
React.createElement("div", { className: "fill", style: { width: percent } })),
this.props.showPercentage && (React.createElement("span", { className: "percent" }, percent))));
}
}
LoadingBar.defaultProps = {
barHeight: 4,
};
/** Sanity check to keep percentage between 0 & 100
* @internal
*/
export function percentInRange(percent) {
let value = Math.min(percent, 100);
value = Math.max(value, 0);
return value;
}
//# sourceMappingURL=LoadingBar.js.map