@@ -2,29 +2,37 @@ import FlexBox from '@/shared/components/layout/FlexBox';
22import { motion } from 'framer-motion' ;
33
44export interface ProgressBarProps {
5- doneTask : number ;
6- totalTask : number ;
5+ percentage : number ;
6+ totalTask ? : number ;
77 label ?: string ;
8+ showPercentage ?: boolean ;
89}
910
10- const ProgressBar = ( { doneTask, totalTask, label = '작업 완성률' } : ProgressBarProps ) => {
11- const percentage = totalTask > 0 ? Math . min ( Math . round ( ( doneTask / totalTask ) * 100 ) , 100 ) : 0 ;
11+ const ProgressBar = ( { percentage, totalTask, label = '작업 완성률' , showPercentage = false } : ProgressBarProps ) => {
12+ const value = Math . min ( percentage , 100 ) ;
13+ const hasTotalTask = typeof totalTask === 'number' && ! isNaN ( totalTask ) ;
14+ const doneTask = hasTotalTask ? Math . min ( Math . round ( ( percentage / 100 ) * totalTask ) , totalTask ) : null ;
15+
1216 return (
1317 < div className = "flex flex-col gap-2 items-start w-full" >
14- < FlexBox className = "w-full justify-between" >
15- { label && (
16- < div className = "body-1-medium text-primary-normal" >
17- { label } { ' ' }
18- < span className = "ml-2 text-label-alternative" > { `${ Math . min ( doneTask , totalTask ) } /${ totalTask } ` } </ span >
19- </ div >
20- ) }
21- < span className = "title-3-bold text-accent-violet" > { percentage } %</ span >
22- </ FlexBox >
18+ { showPercentage && (
19+ < FlexBox className = "w-full justify-between" >
20+ { label && (
21+ < div className = "body-1-medium text-primary-normal" >
22+ { label } { ' ' }
23+ { hasTotalTask && doneTask !== null && (
24+ < span className = "ml-2 text-label-alternative" > { `${ Math . min ( doneTask , totalTask ) } /${ totalTask } ` } </ span >
25+ ) }
26+ </ div >
27+ ) }
28+ < span className = "title-3-bold text-accent-violet" > { value } %</ span >
29+ </ FlexBox >
30+ ) }
2331 < FlexBox className = "relative w-full rounded-full h-3 bg-fill-normal" >
2432 < motion . div
2533 className = { `absolute h-full top-0 left-0 rounded-full bg-blue-500` }
2634 initial = { { width : 0 } }
27- animate = { { width : `${ percentage } %` } }
35+ animate = { { width : `${ value } %` } }
2836 transition = { { duration : 0.4 , ease : 'easeOut' } }
2937 />
3038 </ FlexBox >
0 commit comments