2021-07-17 05:53:44 -07:00
|
|
|
interface PercentPillProps {
|
|
|
|
value: number
|
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const PercentPill = (props: PercentPillProps) => {
|
|
|
|
const bg = props.value > 0 ? 'bg-green-500' : 'bg-red-500'
|
|
|
|
const displayValue = props.value.toFixed(props.value > 10 ? 0 : 1)
|
|
|
|
|
2021-07-11 21:26:34 -07:00
|
|
|
return (
|
2021-07-17 05:53:44 -07:00
|
|
|
<div
|
|
|
|
className={`${props.className} ${bg} inline-flex text-xs h-6 mt-1 items-center px-2 py-1 uppercase font-bold rounded-full`}
|
|
|
|
>
|
|
|
|
<p>{displayValue}%</p>
|
2021-07-11 21:26:34 -07:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-07-12 04:47:55 -07:00
|
|
|
export default PercentPill
|