@@ -27,6 +27,8 @@ Props description:
27274) percents - display progress in percents
28285) colorizeProgress - change the color of the progress bar depending on its value
29296) 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
3032*/
3133
3234interface ProgressViewerProps {
@@ -38,6 +40,8 @@ interface ProgressViewerProps {
3840 size ?: ProgressViewerSize ;
3941 colorizeProgress ?: boolean ;
4042 inverseColorize ?: boolean ;
43+ warningThreshold ?: number ;
44+ dangerThreshold ?: number ;
4145}
4246
4347export function ProgressViewer ( {
@@ -49,10 +53,11 @@ export function ProgressViewer({
4953 size = PROGRESS_VIEWER_SIZE_IDS . xs ,
5054 colorizeProgress,
5155 inverseColorize,
56+ warningThreshold = 60 ,
57+ dangerThreshold = 80 ,
5258} : ProgressViewerProps ) {
5359 let fillWidth = Math . round ( ( parseFloat ( String ( value ) ) / parseFloat ( String ( capacity ) ) ) * 100 ) ;
5460 fillWidth = fillWidth > 100 ? 100 : fillWidth ;
55-
5661 let valueText : number | string | undefined = Math . round ( Number ( value ) ) ,
5762 capacityText : number | string | undefined = capacity ,
5863 divider = '/' ;
@@ -66,9 +71,9 @@ export function ProgressViewer({
6671
6772 let bg = inverseColorize ? 'scarlet' : 'apple' ;
6873 if ( colorizeProgress ) {
69- if ( fillWidth > 60 && fillWidth <= 80 ) {
74+ if ( fillWidth > warningThreshold && fillWidth <= dangerThreshold ) {
7075 bg = 'saffron' ;
71- } else if ( fillWidth > 80 ) {
76+ } else if ( fillWidth > dangerThreshold ) {
7277 bg = inverseColorize ? 'apple' : 'scarlet' ;
7378 }
7479 }
0 commit comments