-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
import React from 'react'; | ||
|
||
interface ProgressBarProps { | ||
max: number; | ||
filled: number; | ||
text: string; | ||
numberText?: string; | ||
max: number; | ||
filled: number; | ||
text: string; | ||
numberText?: string; | ||
} | ||
|
||
const ProgressBar: React.FC<ProgressBarProps> = function ({ | ||
max, | ||
filled, | ||
text, | ||
numberText = text | ||
max, | ||
filled, | ||
text, | ||
numberText = text | ||
}) { | ||
const percentage = filled/max * 100 | ||
const percentage = (filled / max) * 100; | ||
|
||
return ( | ||
<div className='border-2 rounded-lg shadow-md'> | ||
<div className='mx-4 my-6'> | ||
<h4 className='sr-only'>Status</h4> | ||
<p className='text-lg font-bold text-gray-900'>{text}</p> | ||
<div aria-hidden='true' className='mt-6'> | ||
<div className='overflow-hidden rounded-full bg-gray-200'> | ||
<div | ||
style={{ width: percentage.toString() + '%' }} | ||
className='h-2 rounded-full bg-indigo-600' | ||
/> | ||
</div> | ||
<div className='mt-6 hidden grid-cols-4 text-sm font-medium text-gray-600 sm:grid'> | ||
<div className='text-indigo-600'> | ||
{'Currently Used: ' + filled.toString() + ' ' + numberText} | ||
</div> | ||
<div className='text-center text-indigo-600'></div> | ||
<div className='text-center'></div> | ||
<div className='text-right'> | ||
{'Maximum Available: ' + max.toString() + ' ' + numberText} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className='border-2 rounded-lg shadow-md'> | ||
<div className='mx-4 my-6'> | ||
<h4 className="sr-only">Status</h4> | ||
<p className="text-lg font-bold text-gray-900">{text}</p> | ||
<div aria-hidden="true" className="mt-6"> | ||
<div className="overflow-hidden rounded-full bg-gray-200"> | ||
<div style={{ width: percentage.toString() + "%" }} className="h-2 rounded-full bg-indigo-600" /> | ||
</div> | ||
<div className="mt-6 hidden grid-cols-4 text-sm font-medium text-gray-600 sm:grid"> | ||
<div className="text-indigo-600">{'Currently Used: ' + filled.toString() + " " + numberText}</div> | ||
<div className="text-center text-indigo-600"></div> | ||
<div className="text-center"></div> | ||
<div className="text-right">{'Maximum Available: ' + max.toString() + " " + numberText}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ProgressBar; | ||
export default ProgressBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters