@@ -27,6 +27,8 @@ Props description:
27
27
4) percents - display progress in percents
28
28
5) colorizeProgress - change the color of the progress bar depending on its value
29
29
6) inverseColorize - invert the colors of the progress bar
30
+ 7) warningThreshold - the percentage of fullness at which the color of the progress bar changes to yellow
31
+ 8) dangerThreshold - the percentage of fullness at which the color of the progress bar changes to red
30
32
*/
31
33
32
34
interface ProgressViewerProps {
@@ -38,6 +40,8 @@ interface ProgressViewerProps {
38
40
size ?: ProgressViewerSize ;
39
41
colorizeProgress ?: boolean ;
40
42
inverseColorize ?: boolean ;
43
+ warningThreshold ?: number ;
44
+ dangerThreshold ?: number ;
41
45
}
42
46
43
47
export function ProgressViewer ( {
@@ -49,10 +53,11 @@ export function ProgressViewer({
49
53
size = PROGRESS_VIEWER_SIZE_IDS . xs ,
50
54
colorizeProgress,
51
55
inverseColorize,
56
+ warningThreshold = 60 ,
57
+ dangerThreshold = 80 ,
52
58
} : ProgressViewerProps ) {
53
59
let fillWidth = Math . round ( ( parseFloat ( String ( value ) ) / parseFloat ( String ( capacity ) ) ) * 100 ) ;
54
60
fillWidth = fillWidth > 100 ? 100 : fillWidth ;
55
-
56
61
let valueText : number | string | undefined = Math . round ( Number ( value ) ) ,
57
62
capacityText : number | string | undefined = capacity ,
58
63
divider = '/' ;
@@ -66,9 +71,9 @@ export function ProgressViewer({
66
71
67
72
let bg = inverseColorize ? 'scarlet' : 'apple' ;
68
73
if ( colorizeProgress ) {
69
- if ( fillWidth > 60 && fillWidth <= 80 ) {
74
+ if ( fillWidth > warningThreshold && fillWidth <= dangerThreshold ) {
70
75
bg = 'saffron' ;
71
- } else if ( fillWidth > 80 ) {
76
+ } else if ( fillWidth > dangerThreshold ) {
72
77
bg = inverseColorize ? 'apple' : 'scarlet' ;
73
78
}
74
79
}
0 commit comments