Skip to content

Commit

Permalink
Bug Fix: Fixes #1661 Fixed the TS error while using size prop for <Pr…
Browse files Browse the repository at this point in the history
…ogressBar /> (#1666)
  • Loading branch information
viditagrawal56 authored Oct 16, 2023
1 parent d82ac23 commit 8498b32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SIZES } from "../../../constants";
import { getStyle } from "../../../helpers/typesciptCssModulesHelper";
import PercentageLabel from "../PercentageLabel/PercentageLabel";
import { ProgressBarStyle, ProgressBarType } from "./LinearProgressBarConstants";
import { calculatePercentage, getProgressBarClassNames } from "./LinearProgressBarHelpers";
import { calculatePercentage, getProgressBarClassNames, Size } from "./LinearProgressBarHelpers";
import Bar from "./Bar/Bar";
import { VibeComponent, VibeComponentProps, withStaticProps } from "../../../types";
import { ComponentDefaultTestId } from "../../../tests/constants";
Expand Down Expand Up @@ -43,7 +43,7 @@ interface LinearProgressBarProps extends VibeComponentProps {
/**
* Determine the progress bar height (Supported options exposed through `LinearProgressBar.sizes`)
*/
size?: typeof SIZES;
size?: Size;
/**
* Show progress bar progression in percentages
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
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;
Expand Down

0 comments on commit 8498b32

Please sign in to comment.