@@ -3,14 +3,11 @@ import React from 'react';
33import { Flex , Progress , Text } from '@gravity-ui/uikit' ;
44
55import type { FormatProgressViewerValues } from '../../../../../components/ProgressViewer/ProgressViewer' ;
6- import { cn } from '../../../../../utils/cn' ;
76import { isNumeric , safeParseNumber } from '../../../../../utils/utils' ;
87
98import { DEFAULT_PROGRESS_WIDTH , MAX_PERCENTAGE , MIN_PERCENTAGE , PROGRESS_SIZES } from './constants' ;
109import i18n from './i18n' ;
1110
12- import './ProgressWrapper.scss' ;
13-
1411interface ProgressWrapperProps {
1512 value ?: number | string ;
1613 capacity ?: number | string ;
@@ -24,8 +21,6 @@ const defaultFormatValues: FormatProgressViewerValues = (value, total) => {
2421 return [ value , total ] ;
2522} ;
2623
27- const b = cn ( 'progress-wrapper' ) ;
28-
2924export function ProgressWrapper ( {
3025 value,
3126 capacity,
@@ -34,15 +29,13 @@ export function ProgressWrapper({
3429 className,
3530 width = DEFAULT_PROGRESS_WIDTH ,
3631} : ProgressWrapperProps ) {
37- // Input validation and error handling
3832 if ( ! isNumeric ( value ) ) {
3933 return < div className = { className } > { i18n ( 'alert_no-data' ) } </ div > ;
4034 }
4135
4236 const numericValue = safeParseNumber ( value ) ;
4337 const numericCapacity = safeParseNumber ( capacity ) ;
4438
45- // Handle edge cases: negative values, zero capacity
4639 if ( numericValue < 0 ) {
4740 return < div className = { className } > { i18n ( 'alert_no-data' ) } </ div > ;
4841 }
@@ -51,38 +44,30 @@ export function ProgressWrapper({
5144 return < div className = { className } > { i18n ( 'alert_no-data' ) } </ div > ;
5245 }
5346
54- // Calculate percentage for uikit Progress with proper bounds checking
5547 const rawPercentage = Math . floor ( ( numericValue / numericCapacity ) * MAX_PERCENTAGE ) ;
5648 const fillWidth = Math . max ( MIN_PERCENTAGE , rawPercentage ) ;
5749 const clampedFillWidth = Math . min ( fillWidth , MAX_PERCENTAGE ) ;
5850
59- // Get formatted display text - match original ProgressViewer exactly
6051 const [ valueText , capacityText ] = React . useMemo ( ( ) => {
6152 if ( formatValues ) {
6253 return formatValues ( Number ( value ) , Number ( capacity ) ) ;
6354 }
6455 return [ value , capacity ] ;
6556 } , [ formatValues , value , capacity ] ) ;
6657
67- // For storage variant, we always use the Figma green color regardless of colorizeProgress
68- // This matches the original ProgressViewer behavior for storage size
69-
70- // Memoize display text to avoid unnecessary recalculations
7158 const displayText = React . useMemo ( ( ) => {
7259 if ( ! isNumeric ( numericCapacity ) || numericCapacity <= 0 ) {
7360 return String ( valueText ) ;
7461 }
7562 return i18n ( 'value_of_capacity' , { value : valueText , capacity : capacityText } ) ;
7663 } , [ valueText , capacityText , numericCapacity ] ) ;
7764
78- // Validate width prop
7965 const validatedWidth = Math . max ( 0 , width ) ;
8066
81- // For storage variant, use Flex layout similar to current ProgressViewer
8267 if ( size === 'storage' ) {
8368 return (
8469 < Flex alignItems = "center" gap = "2" className = { className } >
85- < div className = { b ( 'storage-progress' ) } style = { { width : `${ validatedWidth } px` } } >
70+ < div style = { { width : `${ validatedWidth } px` } } >
8671 < Progress
8772 value = { clampedFillWidth }
8873 theme = "success"
@@ -96,7 +81,6 @@ export function ProgressWrapper({
9681 ) ;
9782 }
9883
99- // Default layout (though we're only using storage variant for now)
10084 return (
10185 < div className = { className } >
10286 < Progress value = { clampedFillWidth } text = { displayText } size = { PROGRESS_SIZES . DEFAULT } />
0 commit comments