monday-ui-react-core
Version:
Official monday.com UI resources for application development in React.js
16 lines (12 loc) • 586 B
text/typescript
import { toNumber } from "lodash-es";
import { SIZES } from "./../../../constants/sizes";
import cx from "classnames";
import styles from "./LinearProgressBar.module.scss";
export type Size = (typeof SIZES)[keyof typeof SIZES];
export const calculatePercentage = (value: number, min: number, max: number) => {
const valuePercentage = (toNumber(value - min) / toNumber(max - min)) * 100;
return valuePercentage > 100 ? 100 : valuePercentage;
};
export const getProgressBarClassNames = (value: number) => {
return cx(styles.progressBar, { [styles.completed]: value >= 100 });
};