-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.tsx
More file actions
26 lines (22 loc) · 757 Bytes
/
index.tsx
File metadata and controls
26 lines (22 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { FC, ReactNode } from 'react'
import { Progress } from '@oasisprotocol/ui-library/src/components/progress'
import { calculatePercentage } from '../../utils/number-utils'
type LabeledProgresssProps = {
value?: number | string
max?: number | string
label: ReactNode
}
export const LabeledProgress: FC<LabeledProgresssProps> = ({ value, max, label }) => {
const percentage = calculatePercentage(value, max)
if (percentage === null) {
return null
}
return (
<div className="w-full relative">
<Progress value={percentage} className="h-8 bg-muted-foreground rounded-[8px]" />
<span className="absolute inset-y-0 left-3 flex items-center text-white text-xs font-normal">
{label}
</span>
</div>
)
}