@beydesign/storybook 0.0.82 → 0.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,8 @@ import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
|
5
5
|
export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, currentValue = 40, maxValue = 100, fillColor = 'var(--colors-light-background-bg-brand)', backgroundColor = 'var(--colors-light-background-bg-white)', text = 'used', textColor = 'var(--colors-light-text-text-primary)', style, }) => {
|
|
6
6
|
let errorText = '';
|
|
7
7
|
const calculateFill = () => {
|
|
8
|
+
if (currentValue > maxValue)
|
|
9
|
+
return 100;
|
|
8
10
|
return (currentValue / maxValue) * 100;
|
|
9
11
|
};
|
|
10
12
|
if (isNaN(currentValue) || !isFinite(currentValue)) {
|
|
@@ -16,13 +18,13 @@ export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, currentV
|
|
|
16
18
|
else if (currentValue < 0) {
|
|
17
19
|
errorText = 'Invalid current value';
|
|
18
20
|
}
|
|
19
|
-
else if (currentValue > maxValue) {
|
|
20
|
-
errorText = 'Current value is greater than max value';
|
|
21
|
-
}
|
|
22
21
|
else if (mode === ProgressIndicatorMode.Percentage) {
|
|
23
22
|
if (maxValue > 100 || maxValue < 0) {
|
|
24
23
|
errorText = 'Invalid max value for percentage mode';
|
|
25
24
|
}
|
|
25
|
+
else if (currentValue > maxValue) {
|
|
26
|
+
errorText = 'Current value is greater than max value for percentage mode';
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
if (errorText) {
|
|
28
30
|
return (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, children: errorText }));
|